summaryrefslogtreecommitdiff
path: root/xmake/rules/vala/xmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-07-29 22:43:45 +0800
committerruki <[email protected]>2021-07-29 22:43:45 +0800
commite2067d1b58aeec0024ac2f52e7599a4893b15f14 (patch)
tree783e31fb7410f9e2eb17a47fbb6b7a6b1c09a74b /xmake/rules/vala/xmake.lua
parent6acd768b2f692c49ddc89b5fffdfed0bf75744dc (diff)
impl vala rule
Diffstat (limited to 'xmake/rules/vala/xmake.lua')
-rw-r--r--xmake/rules/vala/xmake.lua33
1 files changed, 31 insertions, 2 deletions
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)