summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/msvc/scanner.lua
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2025-05-05 17:13:25 +0200
committerArthur LAURENT <[email protected]>2025-05-09 15:56:33 +0200
commit5d6d36e0db45d90dfa7f0cdf2937d989de683833 (patch)
tree2d1fbb82ee8d38921af1863fd3ce968f7c5cea75 /xmake/rules/c++/modules/msvc/scanner.lua
parentd88bd9c5ace6c64981420569fb886f7c646135c0 (diff)
(C++ module support) improve jobgraph support
Diffstat (limited to 'xmake/rules/c++/modules/msvc/scanner.lua')
-rw-r--r--xmake/rules/c++/modules/msvc/scanner.lua31
1 files changed, 17 insertions, 14 deletions
diff --git a/xmake/rules/c++/modules/msvc/scanner.lua b/xmake/rules/c++/modules/msvc/scanner.lua
index 07342a55e..20cc29d69 100644
--- a/xmake/rules/c++/modules/msvc/scanner.lua
+++ b/xmake/rules/c++/modules/msvc/scanner.lua
@@ -28,33 +28,36 @@ import("support")
import("builder")
import(".scanner", {inherit = true})
--- generate dependency files
-function generate_dependency_for(target, sourcefile, opt)
+-- scan module dependencies
+function scan_dependency_for(target, sourcefile, opt)
+
local msvc = target:toolchain("msvc")
+ local compinst = target:compiler("cxx")
+ local changed = false
+ local dependfile = target:dependfile(sourcefile)
+ local compflags = compinst:compflags({sourcefile = sourcefile, target = target, sourcekind = "cxx"}) or {}
local scandependenciesflag = support.get_scandependenciesflag(target)
local ifcoutputflag = support.get_ifcoutputflag(target)
local common_flags = {"-TP", scandependenciesflag}
- local dependfile = target:dependfile(sourcefile)
- local compinst = target:compiler("cxx")
- local flags = compinst:compflags({sourcefile = sourcefile, target = target}) or {}
- local changed = false
local fallbackscanner = target:policy("build.c++.modules.fallbackscanner") or
target:policy("build.c++.modules.msvc.fallbackscanner") or
target:policy("build.c++.msvc.fallbackscanner")
depend.on_changed(function ()
- progress.show(opt.progress, "${color.build.target}<%s> generating.module.deps %s", target:fullname(), sourcefile)
- local outputdir = support.get_outputdir(target, sourcefile)
-
- local jsonfile = path.join(outputdir, path.filename(sourcefile) .. ".module.json")
+ if opt.progress and not os.getenv("XMAKE_IN_COMPILE_COMMANDS_PROJECT_GENERATOR") then
+ progress.show(opt.progress, "${color.build.target}<%s> generating.module.deps %s", target:fullname(), sourcefile)
+ end
+
+ local outputdir = support.get_outputdir(target, sourcefile, {scan = true})
+ local jsonfile = path.translate(path.join(outputdir, path.filename(sourcefile) .. ".module.json"))
if scandependenciesflag and not fallbackscanner then
local dependency_flags = {jsonfile, sourcefile, ifcoutputflag, outputdir, "-Fo" .. target:objectfile(sourcefile)}
- local compflags = table.join(flags, common_flags, dependency_flags)
- os.vrunv(compinst:program(), winos.cmdargv(compflags), {envs = msvc:runenvs()})
+ local dependency_flags = table.join(compflags, common_flags, dependency_flags)
+ os.vrunv(compinst:program(), winos.cmdargv(dependency_flags), {envs = msvc:runenvs()})
else
fallback_generate_dependencies(target, jsonfile, sourcefile, function(file)
local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i"))
- os.vrunv(compinst:program(), table.join(flags,
+ os.vrunv(compinst:program(), table.join(compflags,
{"/P", "-TP", file, "/Fi" .. ifile}), {envs = msvc:runenvs()})
local content = io.readfile(ifile)
os.rm(ifile)
@@ -65,7 +68,7 @@ function generate_dependency_for(target, sourcefile, opt)
local dependinfo = io.readfile(jsonfile)
return { moduleinfo = dependinfo }
- end, {dependfile = dependfile, files = {sourcefile}, changed = target:is_rebuilt(), values = flags})
+ end, {dependfile = dependfile, files = {sourcefile}, changed = target:is_rebuilt(), values = compflags})
return changed
end