diff options
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang.lua | 7 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/common.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/gcc.lua | 6 |
3 files changed, 13 insertions, 4 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index e67bacef1..160c08b25 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -150,7 +150,12 @@ function generate_dependencies(target, sourcebatch, opt) -- no support of p1689 atm local jsonfile = path.translate(path.join(outputdir, path.filename(sourcefile) .. ".json")) - common.fallback_generate_dependencies(target, jsonfile, sourcefile) + common.fallback_generate_dependencies(target, jsonfile, sourcefile, function(file) + local compinst = target:compiler("cxx") + local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i")) + os.vrunv(compinst:program(), {"-E", "-x", "c++", file, "-o", ifile}) + return io.readfile(ifile) + end) changed = true local dependinfo = io.readfile(jsonfile) diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua index 593913887..e91712ffd 100644 --- a/xmake/rules/c++/modules/modules_support/common.lua +++ b/xmake/rules/c++/modules/modules_support/common.lua @@ -376,7 +376,7 @@ end } ] }]] -function fallback_generate_dependencies(target, jsonfile, sourcefile) +function fallback_generate_dependencies(target, jsonfile, sourcefile, preprocess_file) local output = {version = 0, revision = 0, rules = {}} local rule = {outputs = {jsonfile}} rule["primary-output"] = target:objectfile(sourcefile) @@ -385,7 +385,7 @@ function fallback_generate_dependencies(target, jsonfile, sourcefile) local module_name_private local module_deps = {} local module_deps_set = hashset.new() - local sourcecode = io.readfile(sourcefile) + local sourcecode = preprocess_file(sourcefile) sourcecode = sourcecode:gsub("//.-\n", "\n") sourcecode = sourcecode:gsub("/%*.-%*/", "") for _, line in ipairs(sourcecode:split("\n", {plain = true})) do diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua index 20a8437aa..1d26a543e 100644 --- a/xmake/rules/c++/modules/modules_support/gcc.lua +++ b/xmake/rules/c++/modules/modules_support/gcc.lua @@ -145,7 +145,11 @@ function generate_dependencies(target, sourcebatch, opt) local args = {sourcefile, "-MD", "-MT", jsonfile, "-MF", dfile, depfileflag .. jsonfile, trtbdflag, depoutputfile .. target:objectfile(sourcefile), "-o", ifile} os.vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, args), {envs = vcvars}) else - common.fallback_generate_dependencies(target, jsonfile, sourcefile) + common.fallback_generate_dependencies(target, jsonfile, sourcefile, function(file) + local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i")) + os.vrunv(compinst:program(), {"-E", "-x", "c++", file, "-o", ifile}) + return io.readfile(ifile) + end) end changed = true |
