dice: add trusty build rules
Adds the ability to build libdiced_open_dice with the trusty build
system. Besides the various rules.mk files this requires a few changes
to the library itself:
Bindgen changes:
1. The bindgen headers have each been moved to to their own subdir. This
stems from a limitation in the trusty build system whereby you can't
have two rules.mk files in the same directory.
2. A lib.rs has been added for each bindgen target. This remains unused
in the android build, but is needed in the trusty build so we can
include!() the generated bindings.
Test changes:
1. The tests have been wrapped in a module so that they can be
conditionally compiled. The trusty build system doesn't support
building rust test targets on their own. It will attempt to compile
this code as a non-test target.
2. A feature, `trusty`, has been added to the test crate to guard
invoking the trusty test harness initialization macro.
Bug: 369146791
Test: atest libdiced_open_dice_nostd.integration_test
Test: # requires associated trusty changes (see topic) \
trusty/vendor/google/aosp/scripts/build.py qemu-generic-arm64-test-debug \
--test="boot-test:com.android.trusty.rust.diced_open_dice_tests.test" \
Change-Id: Ibaefa21473c1de5882a8a225a06d17f1466b4a7f
diff --git a/libs/dice/open_dice/rules.mk b/libs/dice/open_dice/rules.mk
new file mode 100644
index 0000000..d84468d
--- /dev/null
+++ b/libs/dice/open_dice/rules.mk
@@ -0,0 +1,30 @@
+# 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 := diced_open_dice
+
+MODULE_LIBRARY_DEPS += \
+ $(call FIND_CRATE,coset) \
+ $(call FIND_CRATE,zeroize) \
+ $(LOCAL_DIR)/bindgen/android \
+ $(LOCAL_DIR)/bindgen/dice \
+
+include make/library.mk