summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-07-29 22:48:49 +0800
committerruki <[email protected]>2021-07-29 22:48:49 +0800
commit8a7d3983299862ccb2c1565f91a378ef4586eabf (patch)
treecbd39029ecfddbb87b36d28df1a7ac25899a244a
parente2067d1b58aeec0024ac2f52e7599a4893b15f14 (diff)
improve vala rule
-rw-r--r--xmake/core/project/target.lua32
-rw-r--r--xmake/rules/vala/xmake.lua9
2 files changed, 18 insertions, 23 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 38d207656..30d1ad7b1 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -1545,30 +1545,18 @@ end
-- e.g. cc cxx mm mxx as ...
--
function _instance:sourcekinds()
-
- -- cached? return it directly
- if self._SOURCEKINDS then
- return self._SOURCEKINDS
- end
-
- -- make source kinds
- local sourcekinds = {}
- for _, sourcefile in pairs(self:sourcefiles()) do
-
- -- get source kind
- local sourcekind = self:sourcekind_of(sourcefile)
- if sourcekind then
- table.insert(sourcekinds, sourcekind)
+ local sourcekinds = self._SOURCEKINDS
+ if not sourcekinds then
+ sourcekinds = {}
+ for _, sourcefile in pairs(self:sourcefiles()) do
+ local sourcekind = self:sourcekind_of(sourcefile)
+ if sourcekind then
+ table.insert(sourcekinds, sourcekind)
+ end
end
+ sourcekinds = table.unique(sourcekinds)
+ self._SOURCEKINDS = sourcekinds
end
-
- -- remove repeat
- sourcekinds = table.unique(sourcekinds)
-
- -- cache it
- self._SOURCEKINDS = sourcekinds
-
- -- ok?
return sourcekinds
end
diff --git a/xmake/rules/vala/xmake.lua b/xmake/rules/vala/xmake.lua
index 6de49665c..a2ce76937 100644
--- a/xmake/rules/vala/xmake.lua
+++ b/xmake/rules/vala/xmake.lua
@@ -20,6 +20,13 @@
rule("vala")
set_extensions(".vala")
+ on_load(function (target)
+ -- only vala source files? we need patch c source kind for linker
+ local sourcekinds = target:sourcekinds()
+ if #sourcekinds == 0 then
+ table.insert(sourcekinds, "cc")
+ end
+ end)
before_buildcmd_file(function (target, batchcmds, sourcefile_vala, opt)
-- get valac
@@ -27,7 +34,7 @@ rule("vala")
local valac = assert(find_tool("valac"), "valac not found!")
-- get c source file for vala
- local sourcefile_c = path.join(target:autogendir(), "rules", "vala", path.basename(sourcefile_vala) .. ".c")
+ local sourcefile_c = target:autogenfile((sourcefile_vala:gsub(".vala$", ".c")))
local basedir = path.directory(sourcefile_c)
-- add objectfile