diff options
| author | Arthur LAURENT <[email protected]> | 2025-05-05 17:13:25 +0200 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2025-05-09 15:56:33 +0200 |
| commit | 5d6d36e0db45d90dfa7f0cdf2937d989de683833 (patch) | |
| tree | 2d1fbb82ee8d38921af1863fd3ce968f7c5cea75 /xmake/rules/c++/modules/clang/scanner.lua | |
| parent | d88bd9c5ace6c64981420569fb886f7c646135c0 (diff) | |
(C++ module support) improve jobgraph support
Diffstat (limited to 'xmake/rules/c++/modules/clang/scanner.lua')
| -rw-r--r-- | xmake/rules/c++/modules/clang/scanner.lua | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/xmake/rules/c++/modules/clang/scanner.lua b/xmake/rules/c++/modules/clang/scanner.lua index 2b4738f65..d565cd63e 100644 --- a/xmake/rules/c++/modules/clang/scanner.lua +++ b/xmake/rules/c++/modules/clang/scanner.lua @@ -27,23 +27,25 @@ import("utils.progress") import("support") import(".scanner", {inherit = true}) -function generate_dependency_for(target, sourcefile, opt) +-- scan module dependencies +function scan_dependency_for(target, sourcefile, opt) + local compinst = target:compiler("cxx") local changed = false local dependfile = target:dependfile(sourcefile) - local flags = compinst:compflags({sourcefile = sourcefile, target = target}) or {} - local fallbackscanner = target:policy("build.c++.modules.fallbackscanner") or - target:policy("build.c++.modules.clang.fallbackscanner") or - target:policy("build.c++.clang.fallbackscanner") + local compflags = compinst:compflags({sourcefile = sourcefile, target = target, sourcekind = "cxx"}) depend.on_changed(function() - if opt.progress then + 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) + local outputdir = support.get_outputdir(target, sourcefile, {scan = true}) local jsonfile = path.translate(path.join(outputdir, path.filename(sourcefile) .. ".json")) local has_clangscandepssupport = support.has_clangscandepssupport(target) + local fallbackscanner = target:policy("build.c++.modules.fallbackscanner") or + target:policy("build.c++.modules.clang.fallbackscanner") or + target:policy("build.c++.clang.fallbackscanner") if has_clangscandepssupport and not fallbackscanner then -- We need absolute path of clang to use clang-scan-deps -- See https://clang.llvm.org/docs/StandardCPlusPlusModules.html#possible-issues-failed-to-find-system-headers @@ -53,7 +55,7 @@ function generate_dependency_for(target, sourcefile, opt) end local clangscandeps = support.get_clang_scan_deps(target) local dependency_flags = table.join({"--format=p1689", "--", - clang_path, "-x", "c++", "-c", sourcefile, "-o", target:objectfile(sourcefile)}, flags) + clang_path, "-x", "c++"}, compflags, {"-c", sourcefile, "-o", target:objectfile(sourcefile)}) if option.get("verbose") then print(os.args(table.join(clangscandeps, dependency_flags))) end @@ -67,11 +69,11 @@ function generate_dependency_for(target, sourcefile, opt) end fallback_generate_dependencies(target, jsonfile, sourcefile, function(file) local keepsystemincludesflag = support.get_keepsystemincludesflag(target) - local compflags = table.clone(flags) + local compflags = table.clone(compflags) -- exclude -fmodule* and -std=c++/gnu++* flags because -- when they are set clang try to find bmi of imported modules but they don't exists in this point of compilation table.remove_if(compflags, function(_, flag) - return flag:startswith("-fmodule") or flag:startswith("-std=c++") or flag:startswith("-std=gnu++") + return flag:startswith("-fmodule") or flag:startswith("-fvisibility") or flag:startswith("-std=c++") or flag:startswith("-std=gnu++") end) local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i")) compflags = table.join(compflags or {}, keepsystemincludesflag or {}, {"-E", "-x", "c++", file, "-o", ifile}) @@ -85,7 +87,7 @@ function generate_dependency_for(target, sourcefile, opt) local rawdependinfo = io.readfile(jsonfile) return {moduleinfo = rawdependinfo} - 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 |
