diff options
| author | ruki <[email protected]> | 2022-11-01 23:35:02 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-11-01 23:35:02 +0800 |
| commit | 1912c580ec4f817ef40aa44dc893cbf4c1d8db8e (patch) | |
| tree | 47d5ff5309a5ed549c9da407189a2001dd3c5575 /xmake/modules/core | |
| parent | e3f66afa1533661eda37f934357623134dd0e467 (diff) | |
| parent | 3abe482e186a3851f9349d5011e93d8c529de2d8 (diff) | |
Merge pull request #3001 from xmake-io/modules
Incremental compilation support for modules #3000
Diffstat (limited to 'xmake/modules/core')
| -rw-r--r-- | xmake/modules/core/project/depend.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 3 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 14 |
3 files changed, 15 insertions, 4 deletions
diff --git a/xmake/modules/core/project/depend.lua b/xmake/modules/core/project/depend.lua index 632ecd70f..78150c117 100644 --- a/xmake/modules/core/project/depend.lua +++ b/xmake/modules/core/project/depend.lua @@ -29,7 +29,7 @@ import("private.tools.armcc.parse_deps", {alias = "parse_deps_armcc"}) -- load depfiles function _load_depfiles(parser, dependinfo, depfiles) - depfiles = parser(depfiles) + depfiles = parser(depfiles, dependinfo) if depfiles then if dependinfo.files then table.join2(dependinfo.files, depfiles) diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index 31bdce256..7905668a9 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -514,6 +514,7 @@ end -- do compile function _compile(self, sourcefile, objectfile, compflags, opt) + opt = opt or {} local function _compile_fallback() local program, argv = compargv(self, sourcefile, objectfile, compflags, opt) return vstool.iorunv(program, argv, {envs = self:runenvs()}) @@ -524,7 +525,7 @@ function _compile(self, sourcefile, objectfile, compflags, opt) cppinfo = distcc_build_client.singleton():compile(program, argv, {envs = self:runenvs(), preprocess = _preprocess, compile = _compile_preprocessed_file, compile_fallback = _compile_fallback, target = opt.target, tool = self, remote = true}) - elseif build_cache.is_enabled() and build_cache.is_supported(self:kind()) then + elseif build_cache.is_enabled(opt.target) and build_cache.is_supported(self:kind()) then local program, argv = compargv(self, sourcefile, objectfile, compflags, table.join(opt, {rawargs = true})) cppinfo = build_cache.build(program, argv, {envs = self:runenvs(), preprocess = _preprocess, compile = _compile_preprocessed_file, compile_fallback = _compile_fallback, diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 1c3a29c01..a3888ac34 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -555,6 +555,7 @@ end -- do compile function _compile(self, sourcefile, objectfile, compflags, opt) + opt = opt or {} local program, argv = compargv(self, sourcefile, objectfile, compflags) local function _compile_fallback() return os.iorunv(program, argv, {envs = self:runenvs()}) @@ -564,7 +565,7 @@ function _compile(self, sourcefile, objectfile, compflags, opt) cppinfo = distcc_build_client.singleton():compile(program, argv, {envs = self:runenvs(), preprocess = _preprocess, compile = _compile_preprocessed_file, compile_fallback = _compile_fallback, tool = self, remote = true}) - elseif build_cache.is_enabled() and build_cache.is_supported(self:kind()) then + elseif build_cache.is_enabled(opt.target) and build_cache.is_supported(self:kind()) then cppinfo = build_cache.build(program, argv, {envs = self:runenvs(), preprocess = _preprocess, compile = _compile_preprocessed_file, compile_fallback = _compile_fallback, tool = self}) @@ -603,6 +604,13 @@ function _compargv_pch(self, pcheaderfile, pcoutputfile, flags) return self:program(), table.join("-c", pchflags, "-o", pcoutputfile, pcheaderfile) end +-- get modules cache directory +function _modules_cachedir(target) + if target and target.autogendir and target:data("cxx.has_modules") then -- we need ignore option instance + return path.join(target:autogendir(), "rules", "modules", "cache") + end +end + -- make the compile arguments list function compargv(self, sourcefile, objectfile, flags) -- precompiled header? @@ -614,12 +622,13 @@ function compargv(self, sourcefile, objectfile, flags) end -- compile the source file -function compile(self, sourcefile, objectfile, dependinfo, flags) +function compile(self, sourcefile, objectfile, dependinfo, flags, opt) -- ensure the object directory os.mkdir(path.directory(objectfile)) -- compile it + opt = opt or {} local depfile = dependinfo and os.tmpfile() or nil try { @@ -705,6 +714,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) if depfile and os.isfile(depfile) then if dependinfo then dependinfo.depfiles_gcc = io.readfile(depfile, {continuation = "\\"}) + dependinfo.modules_cachedir = _modules_cachedir(opt.target) end -- remove the temporary dependent file |
