This is an automated email from the ASF dual-hosted git repository. zfc pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git
commit 7eaa7cc3cf0fac6744743480803d114d41ce06bd Author: Zhaofeng Chen <[email protected]> AuthorDate: Tue Aug 12 00:48:12 2025 +0000 makefile: explicit selection example category --- .github/workflows/reuse_test.yml | 12 ++--- Makefile | 32 ++++++++----- examples/Makefile | 98 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 17 deletions(-) diff --git a/.github/workflows/reuse_test.yml b/.github/workflows/reuse_test.yml index 37338bc..9272d6c 100644 --- a/.github/workflows/reuse_test.yml +++ b/.github/workflows/reuse_test.yml @@ -88,25 +88,25 @@ jobs: export ARCH_HOST=arm export ARCH_TA=arm source environment - make -j`nproc` + make examples -j`nproc` # Build OP-TEE Rust examples for Arm 32-bit host and 64-bit TA export ARCH_HOST=arm unset ARCH_TA source environment - make clean && make -j`nproc` + make clean && make examples -j`nproc` # Build OP-TEE Rust examples for Arm 64-bit host and 32-bit TA unset ARCH_HOST export ARCH_TA=arm source environment - make clean && make -j`nproc` + make clean && make examples -j`nproc` # Build OP-TEE Rust examples for Arm 64-bit both host and TA unset ARCH_TA unset ARCH_HOST source environment - make clean && make -j`nproc` + make clean && make examples -j`nproc` - name: Run tests for Arm 64-bit both host and TA run: | source environment @@ -137,7 +137,7 @@ jobs: source environment # Build OP-TEE Rust examples for Arm 64-bit both host and TA - make -j2 + make std-examples -j2 # Build project (cd projects/web3/eth_wallet && make) @@ -173,7 +173,7 @@ jobs: source environment # Build OP-TEE Rust examples for Arm 64-bit both host and TA - make -j2 + make std-examples -j2 # Build project (cd projects/web3/eth_wallet && make) diff --git a/Makefile b/Makefile index 700cd26..396ee8d 100644 --- a/Makefile +++ b/Makefile @@ -34,9 +34,6 @@ endif # export 'q', used by sub-makefiles. export q -EXAMPLES = $(wildcard examples/*) -EXAMPLES_CLEAN = $(EXAMPLES:%=%-clean) - TARGET ?= aarch64-unknown-linux-gnu CROSS_COMPILE ?= aarch64-linux-gnu- @@ -47,7 +44,9 @@ CROSS_COMPILE_TA ?= $(CROSS_COMPILE) TARGET_HOST ?= $(TARGET) TARGET_TA ?= $(TARGET) -.PHONY: all examples $(EXAMPLES) install clean +.PHONY: all examples std-examples no-std-examples \ + install clean examples-clean help + ifneq ($(wildcard $(TA_DEV_KIT_DIR)/host_include/conf.mk),) all: examples else @@ -55,9 +54,12 @@ all: $(q)echo "TA_DEV_KIT_DIR is not correctly defined" && false endif -examples: $(EXAMPLES) -$(EXAMPLES): - $(q)make -C $@ TARGET_HOST=$(TARGET_HOST) \ +# Default examples target - builds no-std examples for backward compatibility +examples: no-std-examples + +# Delegate all examples-related targets to examples/Makefile +std-examples no-std-examples: + $(q)$(MAKE) -C examples $@ TARGET_HOST=$(TARGET_HOST) \ TARGET_TA=$(TARGET_TA) \ CROSS_COMPILE_HOST=$(CROSS_COMPILE_HOST) \ CROSS_COMPILE_TA=$(CROSS_COMPILE_TA) \ @@ -75,11 +77,19 @@ install: examples $(q)mkdir -p ${out-dir}${libdir}/tee-supplicant/plugins/ $(q)find examples/*/plugin/target/$(TARGET_HOST)/ -name *.plugin.so -exec cp {} ${out-dir}${libdir}/tee-supplicant/plugins/ \; -examples-clean: $(EXAMPLES_CLEAN) out-clean -$(EXAMPLES_CLEAN): - $(q)make -C $(@:-clean=) clean +clean: examples-clean out-clean + +examples-clean: + $(q)$(MAKE) -C examples clean out-clean: rm -rf out -clean: $(EXAMPLES_CLEAN) out-clean +help: + @echo "Available targets:" + @echo " examples - Build no-std examples (default, backward compatible)" + @echo " std-examples - Build std examples (std-only + common)" + @echo " no-std-examples - Build no-std examples (no-std-only + common)" + @echo " install - Install built examples to out directory" + @echo " clean - Clean all examples and output directory" + @echo "" \ No newline at end of file diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000..95af841 --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,98 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# Define example categories based on std/no-std support +# STD-only examples (require STD=y to build) +STD_ONLY_EXAMPLES = \ + message_passing_interface-rs \ + serde-rs \ + tls_client-rs \ + tls_server-rs \ + secure_db_abstraction-rs + +# NO-STD-only examples (require STD to be unset to build) +NO_STD_ONLY_EXAMPLES = \ + mnist-rs \ + build_with_optee_utee_sys-rs + +# Common examples (build in both std and no-std modes) +COMMON_EXAMPLES = \ + acipher-rs \ + aes-rs \ + authentication-rs \ + big_int-rs \ + diffie_hellman-rs \ + digest-rs \ + hello_world-rs \ + hotp-rs \ + random-rs \ + secure_storage-rs \ + supp_plugin-rs \ + tcp_client-rs \ + time-rs \ + udp_socket-rs \ + signature_verification-rs \ + client_pool-rs + +# Clean targets +STD_ONLY_EXAMPLES_CLEAN = $(STD_ONLY_EXAMPLES:%=%-clean) +NO_STD_ONLY_EXAMPLES_CLEAN = $(NO_STD_ONLY_EXAMPLES:%=%-clean) +COMMON_EXAMPLES_CLEAN = $(COMMON_EXAMPLES:%=%-clean) + +# Build std examples (std-only + common examples) +std-examples: std-only-examples common-examples + +# Build no-std examples (no-std-only + common examples) +no-std-examples: no-std-only-examples common-examples + +# Build std-only examples +std-only-examples: $(STD_ONLY_EXAMPLES) + +# Build no-std-only examples +no-std-only-examples: $(NO_STD_ONLY_EXAMPLES) + +# Build common examples (always built) +common-examples: $(COMMON_EXAMPLES) + +# Individual example build rules +$(STD_ONLY_EXAMPLES) $(NO_STD_ONLY_EXAMPLES) $(COMMON_EXAMPLES): + $(q)make -C $@ TARGET_HOST=$(TARGET_HOST) \ + TARGET_TA=$(TARGET_TA) \ + CROSS_COMPILE_HOST=$(CROSS_COMPILE_HOST) \ + CROSS_COMPILE_TA=$(CROSS_COMPILE_TA) \ + TA_DEV_KIT_DIR=$(TA_DEV_KIT_DIR) \ + OPTEE_CLIENT_EXPORT=$(OPTEE_CLIENT_EXPORT) + +# Clean targets +clean: $(STD_ONLY_EXAMPLES_CLEAN) $(NO_STD_ONLY_EXAMPLES_CLEAN) $(COMMON_EXAMPLES_CLEAN) + +$(STD_ONLY_EXAMPLES_CLEAN) $(NO_STD_ONLY_EXAMPLES_CLEAN) $(COMMON_EXAMPLES_CLEAN): + $(q)make -C $(@:-clean=) clean + +# Help target +help: + @echo "Available targets:" + @echo " std-examples - Build std examples (std-only + common)" + @echo " no-std-examples - Build no-std examples (no-std-only + common)" + @echo " std-only-examples - Build std-only examples (requires STD=y)" + @echo " no-std-only-examples - Build no-std-only examples (requires STD unset)" + @echo " common-examples - Build examples that work in both modes" + @echo " clean - Clean all examples" + +.PHONY: std-examples no-std-examples std-only-examples no-std-only-examples common-examples \ + $(STD_ONLY_EXAMPLES) $(NO_STD_ONLY_EXAMPLES) $(COMMON_EXAMPLES) \ + $(STD_ONLY_EXAMPLES_CLEAN) $(NO_STD_ONLY_EXAMPLES_CLEAN) $(COMMON_EXAMPLES_CLEAN) clean help --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
