diff options
| author | ruki <[email protected]> | 2021-10-12 00:50:59 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-10-12 00:50:59 +0800 |
| commit | 1cb2cb91f9ae2c251b2f1ba1870874570e11516f (patch) | |
| tree | 31e6d0588835f326b3468a1fea3dfc94677491f9 | |
| parent | 2a231e4654c2569c347e27351a28ea6c4e95cf0c (diff) | |
add module cache for clang
| -rw-r--r-- | xmake/rules/c++/modules/build_modulefiles.lua | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/xmake/rules/c++/modules/build_modulefiles.lua b/xmake/rules/c++/modules/build_modulefiles.lua index 4e26f1eca..aa61fc696 100644 --- a/xmake/rules/c++/modules/build_modulefiles.lua +++ b/xmake/rules/c++/modules/build_modulefiles.lua @@ -24,6 +24,9 @@ import("core.tool.compiler") -- build module files using clang function _build_modulefiles_clang(target, sourcebatch, opt) + -- the module cache directory + local cachedir = path.join(target:autogendir(), "rules", "modules", "cache") + -- attempt to compile the module files as cxx sourcebatch.sourcekind = "cxx" sourcebatch.objectfiles = sourcebatch.objectfiles or {} @@ -35,7 +38,8 @@ function _build_modulefiles_clang(target, sourcebatch, opt) end -- compile module files to *.pcm - opt = table.join(opt, {configs = {force = {cxxflags = {opt.modulesflag, "--precompile", "-x c++-module"}}}}) + opt = table.join(opt, {configs = {force = {cxxflags = {opt.modulesflag, + "--precompile", "-x c++-module", "-fmodules-cache-path=" .. cachedir}}}}) import("private.action.build.object").build(target, sourcebatch, opt) -- compile *.pcm to object files @@ -53,7 +57,7 @@ function _build_modulefiles_clang(target, sourcebatch, opt) import("private.action.build.object").build(target, sourcebatch, opt) -- add module files - target:add("cxxflags", opt.modulesflag) + target:add("cxxflags", opt.modulesflag, "-fmodules-cache-path=" .. cachedir) for _, modulefile in ipairs(modulefiles) do target:add("cxxflags", "-fmodule-file=" .. modulefile) end |
