diff options
| author | Arthur LAURENT <[email protected]> | 2022-12-01 17:00:40 +0100 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2022-12-01 17:00:40 +0100 |
| commit | daca55898c15cf8e486e29d55ebb11dfb0e6190b (patch) | |
| tree | 6d21c2cfe07409d24a2daa18e63beb15bd8f3f59 /xmake/rules/c++/modules/modules_support/clang.lua | |
| parent | 6479822a2179db58dab05e0f1b60aa4cf6c48b98 (diff) | |
add includedirs to preprocess stage
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/clang.lua')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 6f8b87303..5fb5e4389 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -219,11 +219,27 @@ function generate_dependencies(target, sourcebatch, opt) common.fallback_generate_dependencies(target, jsonfile, sourcefile, function(file) local compinst = target:compiler("cxx") local defines = {} - for _, define in ipairs(target:get("defines")) do + for _, define in pairs(target:get("defines")) do table.insert(defines, "-D" .. define) end + local includedirs = {} + for _, dep in ipairs(target:orderdeps()) do + local includedir = dep:get("sysincludedirs") or dep:get("includedirs") + if includedir then + table.join2(includedirs, includedir) + end + end + for _, pkg in pairs(target:pkgs()) do + local includedir = pkg:get("sysincludedirs") or pkg:get("includedirs") + if includedir then + table.join2(includedirs, includedir) + end + end + for i, includedir in pairs(includedirs) do + includedirs[i] = "-I" .. includedir + end local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i")) - os.vrunv(compinst:program(), table.join(defines, {"-E", "-x", "c++", file, "-o", ifile})) + os.vrunv(compinst:program(), table.join(includedirs, defines, {"-E", "-x", "c++", file, "-o", ifile})) local content = io.readfile(ifile) os.rm(ifile) return content |
