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/private/tools | |
| 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/private/tools')
| -rw-r--r-- | xmake/modules/private/tools/cl/parse_deps_json.lua | 45 | ||||
| -rw-r--r-- | xmake/modules/private/tools/gcc/parse_deps.lua | 28 |
2 files changed, 67 insertions, 6 deletions
diff --git a/xmake/modules/private/tools/cl/parse_deps_json.lua b/xmake/modules/private/tools/cl/parse_deps_json.lua index f274dc382..459a8b112 100644 --- a/xmake/modules/private/tools/cl/parse_deps_json.lua +++ b/xmake/modules/private/tools/cl/parse_deps_json.lua @@ -80,15 +80,54 @@ function _normailize_dep(dep, projectdir) end -- parse depsfiles from string +-- +--[[ +{ + "Version": "1.2", + "Data": { + "Source": "c:\users\ruki\desktop\user_headerunit\src\main.cpp", + "ProvidedModule": "", + "Includes": [], + "ImportedModules": [ + { + "Name": "hello", + "BMI": "c:\users\ruki\desktop\user_headerunit\src\hello.ifc" + } + ], + "ImportedHeaderUnits": [ + { + "Header": "c:\users\ruki\desktop\user_headerunit\src\header.hpp", + "BMI": "c:\users\ruki\desktop\user_headerunit\src\header.hpp.ifc" + } + ] + } +}]] function main(depsdata) -- decode json data first depsdata = json.decode(depsdata) -- get includes - local includes - if depsdata and depsdata.Data then - includes = depsdata.Data.Includes + local data + if depsdata then + data = depsdata.Data + end + if data then + includes = data.Includes + for _, item in ipairs(data.ImportedModules) do + local bmifile = item.BMI + if bmifile then + includes = includes or {} + table.insert(includes, bmifile) + end + end + for _, item in ipairs(data.ImportedHeaderUnits) do + local bmifile = item.BMI + if bmifile then + includes = includes or {} + table.insert(includes, bmifile) + end + end end -- translate it diff --git a/xmake/modules/private/tools/gcc/parse_deps.lua b/xmake/modules/private/tools/gcc/parse_deps.lua index 3b682753c..3bc067861 100644 --- a/xmake/modules/private/tools/gcc/parse_deps.lua +++ b/xmake/modules/private/tools/gcc/parse_deps.lua @@ -54,7 +54,7 @@ end -- src/tbox/libc/string/../../prefix/../config.h \ -- build/iphoneos/x86_64/release/tbox.config.h \ -- --- with c++ modules: +-- with c++ modules (gcc): -- build/.objs/dependence/linux/x86_64/release/src/foo.mpp.o: src/foo.mpp\ -- build/.objs/dependence/linux/x86_64/release/src/foo.mpp.o gcm.cache/foo.gcm: bar.c++m cat.c++m\ -- foo.c++m: gcm.cache/foo.gcm\ @@ -62,7 +62,7 @@ end -- gcm.cache/foo.gcm:| build/.objs/dependence/linux/x86_64/release/src/foo.mpp.o\ -- CXX_IMPORTS += bar.c++m cat.c++m\ -- -function main(depsdata) +function main(depsdata, opt) -- we assume there is only one valid line local block = 0 @@ -85,7 +85,7 @@ function main(depsdata) end else includefile = includefile:replace(space_placeholder, ' ', plain) - includefile = includefile:split("\n", {plain = true})[1] + includefile = includefile:split("\n", plain)[1] if #includefile > 0 then includefile = _normailize_dep(includefile, projectdir) if includefile then @@ -94,5 +94,27 @@ function main(depsdata) end end end + -- with c++ modules (gcc): + -- CXX_IMPORTS += bar.c++m cat.c++m\ + -- + -- @see https://github.com/xmake-io/xmake/issues/3000 + opt = opt or {} + if opt.modules_cachedir and line:find("CXX_IMPORTS += ", 1, true) then + local modulefiles = line:split("CXX_IMPORTS += ", plain)[2] + if modulefiles then + for _, modulefile in ipairs(modulefiles:split(' ', plain)) do + modulefile = modulefile:replace(".c++m", ".gcm", plain) + if #modulefile > 0 then + if not path.is_absolute(modulefile) then + modulefile = path.absolute(modulefile, opt.modules_cachedir) + end + modulefile = _normailize_dep(modulefile, projectdir) + if modulefile then + results:insert(modulefile) + end + end + end + end + end return results:to_array() end |
