diff options
| author | Arthur LAURENT <[email protected]> | 2024-08-04 19:59:11 +0200 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2024-10-08 13:47:44 +0200 |
| commit | 593ef027feec3417cabd2825db673ee8ce656402 (patch) | |
| tree | 1fd75fe101f806d6a26426bae0bcb5a1e0699d04 /xmake/rules/c++ | |
| parent | fb0286bc3d912dc83a92260db1b82dac2990b971 (diff) | |
fix missing defines in compflags for dependency scanners
Diffstat (limited to 'xmake/rules/c++')
3 files changed, 22 insertions, 1 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 e6f376365..cc189b07b 100644 --- a/xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua +++ b/xmake/rules/c++/modules/modules_support/clang/dependency_scanner.lua @@ -32,6 +32,14 @@ function generate_dependency_for(target, sourcefile, opt) local changed = false local dependfile = target:dependfile(sourcefile) local flags = compinst:compflags({sourcefile = file, 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 progress.show(opt.progress, "${color.build.target}<%s> generating.module.deps %s", target:name(), sourcefile) @@ -51,8 +59,9 @@ function generate_dependency_for(target, sourcefile, opt) local dependency_flags = table.join({"--format=p1689", "--", clang_path, "-x", "c++", "-c", sourcefile, "-o", target:objectfile(sourcefile)}, flags) if sourcefile:match("frozen") then + print(target:fileconfig(sourcefile)) print(os.args(table.join(clangscandeps, dependency_flags))) - assert(false) + -- assert(false) end if option.get("verbose") then print(os.args(table.join(clangscandeps, dependency_flags))) 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 237e22627..2132f4edf 100644 --- a/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua +++ b/xmake/rules/c++/modules/modules_support/gcc/dependency_scanner.lua @@ -37,6 +37,12 @@ function generate_dependency_for(target, sourcefile, opt) local dependfile = target:dependfile(sourcefile) local flags = compinst:compflags({sourcefile = file, 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 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 cd0928f49..ad5b7aaf9 100644 --- a/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua +++ b/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua @@ -38,6 +38,12 @@ function generate_dependency_for(target, sourcefile, opt) local compinst = target:compiler("cxx") local flags = compinst:compflags({sourcefile = file, 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) |
