summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/rules/vala/xmake.lua103
1 files changed, 59 insertions, 44 deletions
diff --git a/xmake/rules/vala/xmake.lua b/xmake/rules/vala/xmake.lua
index 85a74d239..cc2811cba 100644
--- a/xmake/rules/vala/xmake.lua
+++ b/xmake/rules/vala/xmake.lua
@@ -58,67 +58,82 @@ rule("vala.build")
target:add("sysincludedirs", path.directory(headerfile), {public = true})
end
end)
- before_buildcmd_file(function (target, batchcmds, sourcefile_vala, opt)
+
+ before_buildcmd_files(function (target, batchcmds, sourcefiles_vala, opt)
-- get valac
import("lib.detect.find_tool")
local valac = assert(find_tool("valac"), "valac not found!")
- -- get c source file for vala
- local sourcefile_c = target:autogenfile((sourcefile_vala:gsub(".vala$", ".c")))
- local basedir = path.directory(sourcefile_c)
+ local sourcefiles_c = {}
+ local argv = {"-C", "-d", target:autogendir()}
+ -- iterating through vala files, otherwise valac would fail when compiling multiple files
+ for _, sourcefile_vala in ipairs(sourcefiles_vala.sourcefiles) do
+ -- get c source file for vala
+ local sourcefile_c = target:autogenfile((sourcefile_vala:gsub(".vala$", ".c")))
+ local basedir = path.directory(sourcefile_c)
+ table.insert(sourcefiles_c, sourcefile_c)
- -- add objectfile
- local objectfile = target:objectfile(sourcefile_c)
- table.insert(target:objectfiles(), objectfile)
+ -- 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", path(basedir)}
- local packages = target:values("vala.packages")
- if packages then
- for _, package in ipairs(packages) do
- table.insert(argv, "--pkg")
- table.insert(argv, path(package))
+ -- add commands
+ batchcmds:mkdir(basedir)
+ local packages = target:values("vala.packages")
+ if packages then
+ for _, package in ipairs(packages) do
+ table.insert(argv, "--pkg")
+ table.insert(argv, path(package))
+ end
end
- end
- if target:is_binary() then
- for _, dep in ipairs(target:orderdeps()) do
- if dep:is_shared() or dep:is_static() then
- local vapifile = dep:data("vala.vapifile")
- if vapifile then
- table.join2(argv, path(vapifile))
+ if target:is_binary() then
+ for _, dep in ipairs(target:orderdeps()) do
+ if dep:is_shared() or dep:is_static() then
+ local vapifile = dep:data("vala.vapifile")
+ if vapifile then
+ table.join2(argv, path(vapifile))
+ end
end
end
+ else
+ local vapifile = target:data("vala.vapifile")
+ if vapifile then
+ table.insert(argv, path(vapifile, function (p) return "--vapi=" .. p end))
+ end
+ local headerfile = target:data("vala.headerfile")
+ if headerfile then
+ table.insert(argv, "-H")
+ table.insert(argv, path(headerfile))
+ end
end
- else
- local vapifile = target:data("vala.vapifile")
- if vapifile then
- table.insert(argv, path(vapifile, function (p) return "--vapi=" .. p end))
+ local vapidir = target:data("vala.vapidir")
+ if vapidir then
+ table.insert(argv, path(vapidir, function (p) return "--vapidir=" .. p end))
end
- local headerfile = target:data("vala.headerfile")
- if headerfile then
- table.insert(argv, "-H")
- table.insert(argv, path(headerfile))
+ local valaflags = target:data("vala.flags")
+ if valaflags then
+ table.join2(argv, valaflags)
end
+ table.insert(argv, path(sourcefile_vala))
end
- local vapidir = target:data("vala.vapidir")
- if vapidir then
- table.insert(argv, path(vapidir, function (p) return "--vapidir=" .. p end))
- end
- local valaflags = target:data("vala.flags")
- if valaflags then
- table.join2(argv, valaflags)
- end
- table.insert(argv, path(sourcefile_vala))
+
+ batchcmds:show_progress(opt.progress, "${color.build.object}compiling.vala")
batchcmds:vrunv(valac.program, argv)
- batchcmds:compile(sourcefile_c, objectfile)
+
+ for _, sourcefile_c in ipairs(sourcefiles_c) do
+ batchcmds:show_progress(opt.progress, "${color.build.object}compiling.c %s", sourcefile_c)
+ batchcmds:compile(sourcefile_c, target:objectfile(sourcefile_c))
+ end
-- add deps
- batchcmds:add_depfiles(sourcefile_vala)
- batchcmds:set_depmtime(os.mtime(objectfile))
- batchcmds:set_depcache(target:dependfile(objectfile))
+ for _, sourcefile_vala in ipairs(sourcefiles_vala.sourcefiles) do
+ batchcmds:add_depfiles(sourcefile_vala)
+ end
+ for _, objectfile in ipairs(target:objectfiles()) do
+ batchcmds:set_depmtime(os.mtime(objectfile))
+ batchcmds:set_depcache(target:dependfile(objectfile))
+ end
end)
after_install(function (target)