diff options
| author | ruki <[email protected]> | 2021-07-29 22:43:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-07-29 22:43:45 +0800 |
| commit | e2067d1b58aeec0024ac2f52e7599a4893b15f14 (patch) | |
| tree | 783e31fb7410f9e2eb17a47fbb6b7a6b1c09a74b /xmake/rules | |
| parent | 6acd768b2f692c49ddc89b5fffdfed0bf75744dc (diff) | |
impl vala rule
Diffstat (limited to 'xmake/rules')
| -rw-r--r-- | xmake/rules/lex_yacc/lex/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/lex_yacc/yacc/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/vala/xmake.lua | 33 |
3 files changed, 33 insertions, 8 deletions
diff --git a/xmake/rules/lex_yacc/lex/xmake.lua b/xmake/rules/lex_yacc/lex/xmake.lua index cbdb766e4..adc3c49ec 100644 --- a/xmake/rules/lex_yacc/lex/xmake.lua +++ b/xmake/rules/lex_yacc/lex/xmake.lua @@ -23,10 +23,8 @@ rule("lex") set_extensions(".l", ".ll") on_buildcmd_file(function (target, batchcmds, sourcefile_lex, opt) - -- imports - import("lib.detect.find_tool") - -- get lex + import("lib.detect.find_tool") local lex = assert(find_tool("flex") or find_tool("lex"), "lex not found!") -- get c/c++ source file for lex diff --git a/xmake/rules/lex_yacc/yacc/xmake.lua b/xmake/rules/lex_yacc/yacc/xmake.lua index f93db2ccb..70514cadb 100644 --- a/xmake/rules/lex_yacc/yacc/xmake.lua +++ b/xmake/rules/lex_yacc/yacc/xmake.lua @@ -23,10 +23,8 @@ rule("yacc") set_extensions(".y", ".yy") before_buildcmd_file(function (target, batchcmds, sourcefile_yacc, opt) - -- imports - import("lib.detect.find_tool") - -- get yacc + import("lib.detect.find_tool") local yacc = assert(find_tool("bison") or find_tool("yacc"), "yacc/bison not found!") -- get c/c++ source file for yacc diff --git a/xmake/rules/vala/xmake.lua b/xmake/rules/vala/xmake.lua index 11b002a02..6de49665c 100644 --- a/xmake/rules/vala/xmake.lua +++ b/xmake/rules/vala/xmake.lua @@ -20,9 +20,38 @@ rule("vala") set_extensions(".vala") - before_buildcmd_files(function (target, batchcmds, sourcebatch, opt) + before_buildcmd_file(function (target, batchcmds, sourcefile_vala, opt) + + -- get valac import("lib.detect.find_tool") local valac = assert(find_tool("valac"), "valac not found!") - print(sourcebatch) + + -- get c source file for vala + local sourcefile_c = path.join(target:autogendir(), "rules", "vala", path.basename(sourcefile_vala) .. ".c") + local basedir = path.directory(sourcefile_c) + + -- add objectfile + local objectfile = target:objectfile(sourcefile_c) + table.insert(target:objectfiles(), objectfile) + + -- add commands + batchcmds:show_progress(opt.progress, "${color.build.object}compiling.vala %s", sourcefile_vala) + batchcmds:mkdir(basedir) + local argv = {"-C", "-b", basedir} + local packages = target:values("vala.packages") + if packages then + for _, package in ipairs(packages) do + table.insert(argv, "--pkg") + table.insert(argv, package) + end + end + table.insert(argv, sourcefile_vala) + batchcmds:vrunv(valac.program, argv) + batchcmds:compile(sourcefile_c, objectfile) + + -- add deps + batchcmds:add_depfiles(sourcefile_vala) + batchcmds:set_depmtime(os.mtime(objectfile)) + batchcmds:set_depcache(target:dependfile(objectfile)) end) |
