diff options
| author | ruki <[email protected]> | 2024-04-07 23:57:16 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-04-07 23:57:16 +0800 |
| commit | 1cdbbde962a0699c21be76529ec2493f18b21feb (patch) | |
| tree | 57a0f5c9481bef399d0567fc3c3ccfe2a3b70c94 /xmake/rules/cppfront/xmake.lua | |
| parent | 7e0f8751549ed166fefa13afb300527b76bb190a (diff) | |
| parent | 0539773b74bcc7eabab6f16a8d1760c79bf75a14 (diff) | |
Merge pull request #4943 from shaoxie1986/dev
Add cppfront's header(*.h2) support
Diffstat (limited to 'xmake/rules/cppfront/xmake.lua')
| -rw-r--r-- | xmake/rules/cppfront/xmake.lua | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/xmake/rules/cppfront/xmake.lua b/xmake/rules/cppfront/xmake.lua index 90153df85..b90222aa9 100644 --- a/xmake/rules/cppfront/xmake.lua +++ b/xmake/rules/cppfront/xmake.lua @@ -18,9 +18,38 @@ -- @file xmake.lua -- +rule("cppfront.build.h2") + set_extensions(".h2") + + on_buildcmd_file(function (target, batchcmds, sourcefile_h2, opt) + + -- get cppfront + import("lib.detect.find_tool") + local cppfront = assert(find_tool("cppfront", {check = "-h"}), "cppfront not found!") + + -- get h header file for h2 + local sourcefile_h = target:autogenfile((sourcefile_h2:gsub(".h2$", ".h"))) + local basedir = path.directory(sourcefile_h) + + -- add commands + local argv = {"-o", path(sourcefile_h), path(sourcefile_h2)} + batchcmds:show_progress(opt.progress, "${color.build.object}compiling.h2 %s", sourcefile_h2) + batchcmds:mkdir(basedir) + batchcmds:vrunv(cppfront.program, argv) + + -- add deps + batchcmds:add_depfiles(sourcefile_h2) + batchcmds:set_depmtime(os.mtime(sourcefile_h)) + batchcmds:set_depcache(target:dependfile(sourcefile_h)) + end) + -- define rule: cppfront.build -rule("cppfront.build") +rule("cppfront.build.cpp2") set_extensions(".cpp2") + + -- .h2 must compile before .cpp2 + add_deps("cppfront.build.h2", {order = true}) + on_load(function (target) -- only cppfront source files? we need to patch cxx source kind for linker local sourcekinds = target:sourcekinds() @@ -66,8 +95,11 @@ rule("cppfront.build") -- define rule: cppfront rule("cppfront") + -- add_build.h2 rules + add_deps("cppfront.build.h2") + -- add build rules - add_deps("cppfront.build") + add_deps("cppfront.build.cpp2") -- set compiler runtime, e.g. vs runtime add_deps("utils.compiler.runtime") |
