summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Crane <cranes@google.com>2024-03-06 05:28:41 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-03-06 05:28:41 +0000
commitde622dc74e944b155364a74257c8aa771c4dba6b (patch)
treedde6916d7bb419680aa130fe6045d21fdd299efa
parent16438b286dcde0f62fd07caf14108acea5519434 (diff)
parent99496dd8668173968f00e99edfaf49e7a32acad5 (diff)
downloadsample-temp_319669529.tar.gz
skel2: Add Rust staticlib dependency am: 99496dd866temp_319669529
Original change: https://android-review.googlesource.com/c/trusty/app/sample/+/2985576 Change-Id: I1aa3f0c68a93d2db76cd3bce26415bc8f79aea24 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--skel2/rules.mk1
-rw-r--r--skel2/rust/rules.mk29
-rw-r--r--skel2/rust/src/lib.rs20
-rw-r--r--skel2/skel_app.c5
-rw-r--r--usertests-inc.mk1
5 files changed, 56 insertions, 0 deletions
diff --git a/skel2/rules.mk b/skel2/rules.mk
index 74857f6..cf3c57c 100644
--- a/skel2/rules.mk
+++ b/skel2/rules.mk
@@ -24,5 +24,6 @@ MODULE_SRCS += \
MODULE_LIBRARY_DEPS += \
trusty/user/base/lib/libc-trusty \
+ trusty/user/app/sample/skel2/rust \
include make/trusted_app.mk
diff --git a/skel2/rust/rules.mk b/skel2/rust/rules.mk
new file mode 100644
index 0000000..89711bf
--- /dev/null
+++ b/skel2/rust/rules.mk
@@ -0,0 +1,29 @@
+# Copyright (C) 2024 The Android Open Source Project
+#
+# 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.
+#
+
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
+MODULE := $(LOCAL_DIR)
+
+MODULE_SRCS := $(LOCAL_DIR)/src/lib.rs
+
+MODULE_CRATE_NAME := staticlib_test
+
+MODULE_RUST_CRATE_TYPES := staticlib
+
+MODULE_LIBRARY_DEPS += \
+ external/rust/crates/zerocopy-derive
+
+include make/library.mk
diff --git a/skel2/rust/src/lib.rs b/skel2/rust/src/lib.rs
new file mode 100644
index 0000000..5908864
--- /dev/null
+++ b/skel2/rust/src/lib.rs
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#[no_mangle]
+extern "C" fn in_rust_staticlib(x: i32) -> i32 {
+ x * x
+}
diff --git a/skel2/skel_app.c b/skel2/skel_app.c
index b86ca82..317c344 100644
--- a/skel2/skel_app.c
+++ b/skel2/skel_app.c
@@ -14,10 +14,15 @@
* limitations under the License.
*/
+#include <assert.h>
#include <stdio.h>
+int in_rust_staticlib(int);
+
int main(void) {
printf("Hello world from skeleton app 2\n");
+ assert(in_rust_staticlib(5) == 25);
+
return 0;
}
diff --git a/usertests-inc.mk b/usertests-inc.mk
index 0562bdf..d81dd05 100644
--- a/usertests-inc.mk
+++ b/usertests-inc.mk
@@ -30,6 +30,7 @@ TRUSTY_USER_TESTS += \
trusty/user/app/sample/spi/swspi-srv \
trusty/user/app/sample/spi/swspi-test \
trusty/user/app/sample/skel_rust \
+ trusty/user/app/sample/skel2 \
trusty/user/app/sample/rust_no_std \
TRUSTY_RUST_USER_TESTS += \