summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2024-10-05 18:55:22 +0200
committerArthur LAURENT <[email protected]>2024-10-08 13:47:46 +0200
commit053fcb3bf84a9c60f5aef453e9b20e8671488099 (patch)
treed947f21c31ad71268d96458fa8bbdba1e1942f70 /xmake/rules/c++/modules
parent929d11a6eb75d9b3586afc264a7cc93ca2931eac (diff)
fix flags in dependendy scanners
Diffstat (limited to 'xmake/rules/c++/modules')
-rw-r--r--xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua12
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua16
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua8
3 files changed, 9 insertions, 27 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua
index 5b6d50b1c..fb375fcb7 100644
--- a/xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua
+++ b/xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua
@@ -31,14 +31,8 @@ function generate_dependency_for(target, sourcefile, opt)
local compinst = target:compiler("cxx")
local changed = false
local dependfile = target:dependfile(sourcefile)
- local flags = compinst:compflags({sourcefile = file, target = target}) or {}
+ local flags = compinst:compflags({sourcefile = sourcefile, target = target}) or {}
local fileconfig = target:fileconfig(sourcefile)
- -- fileconfig.defines are not in compflags here so we manually add it
- if fileconfig and fileconfig.defines then
- for _, define in ipairs(fileconfig.defines) do
- table.insert(flags, "-D" .. define)
- end
- end
depend.on_changed(function()
if opt.progress then
@@ -78,8 +72,8 @@ function generate_dependency_for(target, sourcefile, opt)
return flag:startswith("-fmodule") or flag:startswith("-std=c++") or flag:startswith("-std=gnu++")
end)
local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i"))
- local flags = table.join(compflags or {}, keepsystemincludesflag or {}, {"-E", "-x", "c++", file, "-o", ifile})
- os.vrunv(compinst:program(), flags)
+ compflags = table.join(compflags or {}, keepsystemincludesflag or {}, {"-E", "-x", "c++", file, "-o", ifile})
+ os.vrunv(compinst:program(), compflags)
local content = io.readfile(ifile)
os.rm(ifile)
return content
diff --git a/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua
index a2f4f8c7b..11dab5669 100644
--- a/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua
@@ -35,14 +35,8 @@ function generate_dependency_for(target, sourcefile, opt)
local depsfileflag = compiler_support.get_depsfileflag(target)
local depstargetflag = compiler_support.get_depstargetflag(target)
local dependfile = target:dependfile(sourcefile)
- local flags = compinst:compflags({sourcefile = file, target = target}) or {}
+ local flags = compinst:compflags({sourcefile = sourcefile, target = target}) or {}
local changed = false
- -- fileconfig.defines are not in compflags here so we manually add it
- if fileconfig and fileconfig.defines then
- for _, define in ipairs(fileconfig.defines) do
- table.insert(flags, "-D" .. define)
- end
- end
depend.on_changed(function()
if opt.progress then
@@ -55,8 +49,8 @@ function generate_dependency_for(target, sourcefile, opt)
if has_depsflags and not target:policy("build.c++.gcc.fallbackscanner") then
local ifile = path.translate(path.join(outputdir, path.filename(sourcefile) .. ".i"))
local dfile = path.translate(path.join(outputdir, path.filename(sourcefile) .. ".d"))
- local flags = table.join(flags or {}, baselineflags, {sourcefile, "-MT", jsonfile, "-MD", "-MF", dfile, depsformatflag, depsfileflag .. jsonfile, depstargetflag .. target:objectfile(sourcefile), "-o", ifile})
- os.vrunv(compinst:program(), flags)
+ local compflags = table.join(flags or {}, baselineflags, {sourcefile, "-MT", jsonfile, "-MD", "-MF", dfile, depsformatflag, depsfileflag .. jsonfile, depstargetflag .. target:objectfile(sourcefile), "-o", ifile})
+ os.vrunv(compinst:program(), compflags)
os.rm(ifile)
os.rm(dfile)
else
@@ -68,8 +62,8 @@ function generate_dependency_for(target, sourcefile, opt)
-- exclude -fmodule* flags because, when they are set gcc try to find bmi of imported modules but they don't exists a this point of compilation
table.remove_if(compflags, function(_, flag) return flag:startswith("-fmodule") end)
local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i"))
- local flags = table.join(baselineflags, compflags or {}, {file, "-o", ifile})
- os.vrunv(compinst:program(), flags)
+ compflags = table.join(baselineflags, compflags or {}, {file, "-o", ifile})
+ os.vrunv(compinst:program(), compflags)
local content = io.readfile(ifile)
os.rm(ifile)
return content
diff --git a/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua
index ad5b7aaf9..491a27cbf 100644
--- a/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua
@@ -36,14 +36,8 @@ function generate_dependency_for(target, sourcefile, opt)
local common_flags = {"-TP", scandependenciesflag}
local dependfile = target:dependfile(sourcefile)
local compinst = target:compiler("cxx")
- local flags = compinst:compflags({sourcefile = file, target = target}) or {}
+ local flags = compinst:compflags({sourcefile = sourcefile, target = target}) or {}
local changed = false
- -- fileconfig.defines are not in compflags here so we manually add it
- if fileconfig and fileconfig.defines then
- for _, define in ipairs(fileconfig.defines) do
- table.insert(flags, "-D" .. define)
- end
- end
depend.on_changed(function ()
progress.show(opt.progress, "${color.build.target}<%s> generating.module.deps %s", target:name(), sourcefile)