summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-11-11 21:00:59 +0800
committerruki <[email protected]>2021-11-11 21:00:59 +0800
commitcf9d3bacd0b0d47946e517dae67800fa7b8f3e1e (patch)
tree7200891da8490e152d56ade0077b893eeb186fa4
parentd4de88729159b7c331b3b268fdcc67627e9678d4 (diff)
add find_cxxbridge
-rw-r--r--xmake/modules/detect/tools/find_cxxbridge.lua52
-rw-r--r--xmake/rules/rust/build/cxxbridge.lua27
-rw-r--r--xmake/rules/rust/xmake.lua4
3 files changed, 80 insertions, 3 deletions
diff --git a/xmake/modules/detect/tools/find_cxxbridge.lua b/xmake/modules/detect/tools/find_cxxbridge.lua
new file mode 100644
index 000000000..400573fa7
--- /dev/null
+++ b/xmake/modules/detect/tools/find_cxxbridge.lua
@@ -0,0 +1,52 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file find_cxxbridge.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find nim
+--
+-- @param opt the argument options, e.g. {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local nim = find_cxxbridge()
+-- local nim, version = find_cxxbridge({program = "cxxbridge", version = true})
+--
+-- @endcode
+--
+function main(opt)
+
+ -- init options
+ opt = opt or {}
+
+ -- find program
+ local program = find_program(opt.program or "cxxbridge", opt)
+
+ -- find program version
+ local version = nil
+ if program and opt.version then
+ version = find_programver(program, opt)
+ end
+ return program, version
+end
diff --git a/xmake/rules/rust/build/cxxbridge.lua b/xmake/rules/rust/build/cxxbridge.lua
new file mode 100644
index 000000000..909006632
--- /dev/null
+++ b/xmake/rules/rust/build/cxxbridge.lua
@@ -0,0 +1,27 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file cxxbridge.lua
+--
+
+-- imports
+import("core.base.option")
+import("lib.detect.find_tool")
+
+function main(target, batchcmds, sourcefile, opt)
+ print(sourcefile)
+end
diff --git a/xmake/rules/rust/xmake.lua b/xmake/rules/rust/xmake.lua
index 51e27fcc8..b3599e43b 100644
--- a/xmake/rules/rust/xmake.lua
+++ b/xmake/rules/rust/xmake.lua
@@ -22,9 +22,7 @@
-- @see https://cxx.rs/build/other.html
rule("rust.cxxbridge")
set_extensions(".rsx")
- before_buildcmd_file(function (target, batchcmds, sourcefile, opt)
- print(sourcefile)
- end)
+ before_buildcmd_file("build.cxxbridge")
-- define rule: rust.build
rule("rust.build")