summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorruki <[email protected]>2023-08-09 13:35:49 +0800
committerGitHub <[email protected]>2023-08-09 13:35:49 +0800
commitcc8c1a35e4b1dd6053b86fd279ce263cffc96321 (patch)
treef6682ffaceb907be68b200d4057c711efbed1ee1 /tests
parent4182b1a29d085d59e1aca2389a2fc7ec53451885 (diff)
parentef2ba39e335136945cec07d04bd5da4bcd1725a8 (diff)
Merge pull request #4052 from xmake-io/rust
Improve rust to support cross build deps
Diffstat (limited to 'tests')
-rw-r--r--tests/projects/rust/cargo_deps_cross_build/Cargo.toml10
-rw-r--r--tests/projects/rust/cargo_deps_cross_build/src/main.rs10
-rw-r--r--tests/projects/rust/cargo_deps_cross_build/xmake.lua14
3 files changed, 34 insertions, 0 deletions
diff --git a/tests/projects/rust/cargo_deps_cross_build/Cargo.toml b/tests/projects/rust/cargo_deps_cross_build/Cargo.toml
new file mode 100644
index 000000000..fdc6c3132
--- /dev/null
+++ b/tests/projects/rust/cargo_deps_cross_build/Cargo.toml
@@ -0,0 +1,10 @@
+[package]
+name = "demo"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+spin = "^0.9"
+
+[target.'cfg(target_arch = "aarch64")'.dependencies]
+aarch64-cpu = "^9.3"
diff --git a/tests/projects/rust/cargo_deps_cross_build/src/main.rs b/tests/projects/rust/cargo_deps_cross_build/src/main.rs
new file mode 100644
index 000000000..c7ce4ff1c
--- /dev/null
+++ b/tests/projects/rust/cargo_deps_cross_build/src/main.rs
@@ -0,0 +1,10 @@
+// src/main.rs
+#![no_main]
+#![no_std]
+
+use core::panic::PanicInfo;
+
+#[panic_handler]
+fn panic(_panic: &PanicInfo<'_>) -> ! {
+ loop {}
+}
diff --git a/tests/projects/rust/cargo_deps_cross_build/xmake.lua b/tests/projects/rust/cargo_deps_cross_build/xmake.lua
new file mode 100644
index 000000000..e02e14f82
--- /dev/null
+++ b/tests/projects/rust/cargo_deps_cross_build/xmake.lua
@@ -0,0 +1,14 @@
+-- rustup target add aarch64-unknown-none
+-- xmake f -a aarch64-unknown-none
+
+set_arch("aarch64-unknown-none")
+add_rules("mode.release", "mode.debug")
+add_requires("cargo::test", {configs = {
+ std = false,
+ main = false,
+ cargo_toml = path.join(os.projectdir(), "Cargo.toml")}})
+
+target("test")
+ set_kind("binary")
+ add_files("src/main.rs")
+ add_packages("cargo::test")