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 | |
| parent | 6479822a2179db58dab05e0f1b60aa4cf6c48b98 (diff) | |
add includedirs to preprocess stage
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang.lua | 20 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/gcc.lua | 18 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/msvc.lua | 20 |
3 files changed, 54 insertions, 4 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 diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua index 2b65acf27..64199c831 100644 --- a/xmake/rules/c++/modules/modules_support/gcc.lua +++ b/xmake/rules/c++/modules/modules_support/gcc.lua @@ -185,8 +185,24 @@ function generate_dependencies(target, sourcebatch, opt) for _, define in ipairs(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, {get_cppversionflag(target), "-E", "-x", "c++", file, "-o", ifile})) + os.vrunv(compinst:program(), table.join(includedirs, defines, {get_cppversionflag(target), "-E", "-x", "c++", file, "-o", ifile})) local content = io.readfile(ifile) os.rm(ifile) return content diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index 91b7afbc5..d0a052f4b 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -199,8 +199,26 @@ function generate_dependencies(target, sourcebatch, opt) for _, define in ipairs(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 + local includedirs = {} + for i, includedir in pairs(_includedirs) do + table.insert(includedirs, "/I") + table.insert(includedirs, includedir) + end local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i")) - os.vrunv(compinst:program(), table.join(defines, {"/nologo", get_cppversionflag(target), "/P", "-TP", file, "/Fi" .. ifile}), {envs = toolchain:runenvs()}) + os.vrunv(compinst:program(), table.join(includedirs, defines, {"/nologo", get_cppversionflag(target), "/P", "-TP", file, "/Fi" .. ifile}), {envs = toolchain:runenvs()}) local content = io.readfile(ifile) os.rm(ifile) return content |
