summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-11-11 00:59:01 +0800
committerruki <[email protected]>2021-11-11 00:59:01 +0800
commitbd26b472129bc61043a69ffecbddabbd83eb0650 (patch)
tree730e587c5c2bbb65289f593663b0adcc37afd5f5
parent886c51e8ce29b07adb96d4db0f73e38ce9318990 (diff)
improve target.sourcekinds
-rw-r--r--tests/projects/rust/cxx_call_rust_library/xmake.lua5
-rw-r--r--xmake/core/project/target.lua4
-rw-r--r--xmake/languages/rust/xmake.lua2
-rw-r--r--xmake/rules/rust/xmake.lua8
4 files changed, 13 insertions, 6 deletions
diff --git a/tests/projects/rust/cxx_call_rust_library/xmake.lua b/tests/projects/rust/cxx_call_rust_library/xmake.lua
index b8bc7c9a8..00725b02f 100644
--- a/tests/projects/rust/cxx_call_rust_library/xmake.lua
+++ b/tests/projects/rust/cxx_call_rust_library/xmake.lua
@@ -6,8 +6,7 @@ target("foo")
target("test")
set_kind("binary")
+ add_rules("rust.cxxbridge", {override = true})
add_deps("foo")
add_files("src/main.cc")
- add_files("src/bridge.rs", {rules = "rust.cxxbridge"})
-
-
+ add_files("src/bridge.rs")
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 08ab720c0..c48d64c47 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -1609,8 +1609,8 @@ function _instance:sourcekinds()
local sourcekinds = self._SOURCEKINDS
if not sourcekinds then
sourcekinds = {}
- for _, sourcefile in pairs(self:sourcefiles()) do
- local sourcekind = self:sourcekind_of(sourcefile)
+ for _, sourcebatch in pairs(self:sourcebatches()) do
+ local sourcekind = sourcebatch.sourcekind
if sourcekind then
table.insert(sourcekinds, sourcekind)
end
diff --git a/xmake/languages/rust/xmake.lua b/xmake/languages/rust/xmake.lua
index fef2af363..b07617a61 100644
--- a/xmake/languages/rust/xmake.lua
+++ b/xmake/languages/rust/xmake.lua
@@ -25,7 +25,7 @@ language("rust")
set_targetkinds {binary = "rcld", static = "rcar", shared = "rcsh"}
set_targetflags {binary = "ldflags", static = "arflags", shared = "shflags"}
set_langkinds {rust = "rc"}
- set_mixingkinds("rc")
+ set_mixingkinds("rc", "cc", "cxx")
on_load("load")
on_check_main("check_main")
diff --git a/xmake/rules/rust/xmake.lua b/xmake/rules/rust/xmake.lua
index b823ef753..08fcf11f0 100644
--- a/xmake/rules/rust/xmake.lua
+++ b/xmake/rules/rust/xmake.lua
@@ -18,6 +18,14 @@
-- @file xmake.lua
--
+-- generate bridge.rs.cc/h to call rust library in c++ code
+-- @see https://cxx.rs/build/other.html
+rule("rust.cxxbridge")
+ set_extensions(".rs")
+ before_build_file(function (target, sourcefile, opt)
+ print(sourcefile)
+ end)
+
-- define rule: rust.build
rule("rust.build")
set_sourcekinds("rc")