Skip to content

Commit 406aa7c

Browse files
committed
(C++ modules support) make flag order coherent between different compilers
1 parent 22fcfc6 commit 406aa7c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

xmake/rules/c++/modules/clang/builder.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ end
5353

5454
function _compile_one_step(target, module, opt)
5555
-- get flags
56+
local module_outputflag = support.get_moduleoutputflag(target)
5657
if module_outputflag then
5758
local flags = _make_modulebuildflags(target, module, {bmi = true, objectfile = true})
5859
if opt and opt.batchcmds then
@@ -101,7 +102,7 @@ function _compile(target, flags, sourcefile, outputfile, opt)
101102
local dryrun = option.get("dry-run")
102103
local compinst = target:compiler("cxx")
103104
local compflags = compinst:compflags({sourcefile = sourcefile, target = target, sourcekind = "cxx"})
104-
flags = table.join(flags or {}, compflags or {})
105+
flags = table.join(compflags or {}, flags or {})
105106

106107
local bmifile = opt and opt.bmifile
107108

@@ -122,7 +123,7 @@ function _batchcmds_compile(batchcmds, target, flags, sourcefile, outputfile, op
122123
opt = opt or {}
123124
local compinst = target:compiler("cxx")
124125
local compflags = compinst:compflags({sourcefile = sourcefile, target = target, sourcekind = "cxx"})
125-
flags = table.join("-c", compflags or {}, flags, {"-o", outputfile, opt.bmifile or sourcefile})
126+
flags = table.join("-c", compflags or {}, flags or {}, {"-o", outputfile, opt.bmifile or sourcefile})
126127
batchcmds:compilev(flags, {compiler = compinst, sourcekind = "cxx"})
127128
end
128129

xmake/rules/c++/modules/gcc/builder.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function _compile(target, flags, sourcefile, outputfile)
5151
local dryrun = option.get("dry-run")
5252
local compinst = target:compiler("cxx")
5353
local compflags = compinst:compflags({sourcefile = sourcefile, target = target, sourcekind = "cxx"})
54-
flags = table.join(compflags or {}, flags)
54+
flags = table.join(compflags or {}, flags or {})
5555

5656
-- trace
5757
if option.get("verbose") then
@@ -69,7 +69,7 @@ end
6969
function _batchcmds_compile(batchcmds, target, flags, sourcefile, outputfile)
7070
local compinst = target:compiler("cxx")
7171
local compflags = compinst:compflags({sourcefile = sourcefile, target = target, sourcekind = "cxx"})
72-
flags = table.join("-c", compflags or {}, flags, {"-o", outputfile, sourcefile})
72+
flags = table.join("-c", compflags or {}, flags or {}, {"-o", outputfile, sourcefile})
7373
batchcmds:compilev(flags, {compiler = compinst, sourcekind = "cxx"})
7474
end
7575

xmake/rules/c++/modules/msvc/builder.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function _batchcmds_compile(batchcmds, target, flags, sourcefile, outputfile)
129129
opt = opt or {}
130130
local compinst = target:compiler("cxx")
131131
local compflags = compinst:compflags({sourcefile = sourcefile, target = target, sourcekind = "cxx"})
132-
flags = table.join("/c", compflags or {}, outputfile and "-Fo" .. outputfile or {}, flags or {}, sourcefile or {})
132+
flags = table.join("/c", compflags or {}, flags or {}, outputfile and "-Fo" .. outputfile or {}, sourcefile or {})
133133
batchcmds:compilev(flags, {compiler = compinst, sourcekind = "cxx"})
134134
end
135135

0 commit comments

Comments
 (0)