diff options
| author | ruki <[email protected]> | 2019-09-06 00:43:05 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-09-05 22:18:30 +0800 |
| commit | cfb90668f507c9b93fa3e53f78f8f46cdb136413 (patch) | |
| tree | 6517400be4e448ffce8c1c8d3ac6d0257ff817ad /xmake/rules/c++/modules/xmake.lua | |
| parent | 5f3ad152caf5509dd6e8a8249872c8969be1d49f (diff) | |
add c++.build.modules
Diffstat (limited to 'xmake/rules/c++/modules/xmake.lua')
| -rw-r--r-- | xmake/rules/c++/modules/xmake.lua | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua index 26421103b..2ecb829fc 100644 --- a/xmake/rules/c++/modules/xmake.lua +++ b/xmake/rules/c++/modules/xmake.lua @@ -20,8 +20,32 @@ -- define rule: c++.build.modules rule("c++.build.modules") - set_extensions(".mpp") + set_extensions(".mpp", ".mxx", ".cppm", ".ixx") + before_load(function (target) + --target:add("cxxflags", "-fprebuilt-module-path=") + end) before_build_files(function (target, sourcebatch, opt) - print(sourcebatch) + + -- imports + import("core.tool.compiler") + + -- attempt to compile the module files as cxx + sourcebatch.sourcekind = "cxx" + sourcebatch.objectfiles = sourcebatch.objectfiles or {} + sourcebatch.dependfiles = sourcebatch.dependfiles or {} + for _, sourcefile in ipairs(sourcebatch.sourcefiles) do + local objectfile = target:objectfile(sourcefile) + table.insert(sourcebatch.objectfiles, objectfile) + table.insert(sourcebatch.dependfiles, target:dependfile(objectfile)) + end + + -- do compile + local compinst = compiler.load("cxx") + if compinst:name() == "clang" then + opt.configs = {cxxflags = {"-fmodules-ts", "--precompile"}} + else + raise("compiler(%s): does not support module!", compinst:name()) + end + import("private.action.build.object")(target, sourcebatch, opt) end) |
