From 593ef027feec3417cabd2825db673ee8ce656402 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 4 Aug 2024 19:59:11 +0200 Subject: fix missing defines in compflags for dependency scanners --- .../c++/modules/modules_support/clang/dependency_scanner.lua | 11 ++++++++++- .../c++/modules/modules_support/gcc/dependency_scanner.lua | 6 ++++++ .../c++/modules/modules_support/msvc/dependency_scanner.lua | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'xmake/rules/c++/modules/modules_support') 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) -- cgit v1.3.1