You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by yu...@apache.org on 2024/01/03 14:10:18 UTC
(incubator-teaclave-trustzone-sdk) 05/08: Makefile: Drop automatic OP-TEE modules build
This is an automated email from the ASF dual-hosted git repository.
yuanz pushed a commit to branch no-std
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git
commit 2a1757d4ae3af12c9afdb76e4218ab9ec0d1b236
Author: Sumit Garg <su...@linaro.org>
AuthorDate: Fri Dec 29 18:53:34 2023 +0530
Makefile: Drop automatic OP-TEE modules build
Rather than automatically building OP-TEE OS and OP-TEE Client, we
should ask users to build them for their particular platforms using
whichever OP-TEE release they are targeting.
Users just have to export paths for OP-TEE OS build artifacts via
TA_DEV_KIT_DIR and for OP-TEE Client via OPTEE_CLIENT_EXPORT. This is
the common practice followed by C counterparts like optee_test and
optee_examples. Along with that it make OP-TEE rust examples compatible
with build systems like Yocto etc.
Regarding toolchains, we don't need to fetch them explicitly but rather
users can use the distro cross compiler or the one they have installed
on a particular location via CROSS_COMPILE environment variable.
With that build command simplifies to just following:
$ make CROSS_COMPILE=aarch64-linux-gnu- \
TA_DEV_KIT_DIR=<optee_os>/out/arm-plat-vexpress/export-ta_arm64/ \
OPTEE_CLIENT_EXPORT=<optee_client>/out/export/
Signed-off-by: Sumit Garg <su...@linaro.org>
---
Makefile | 75 +++++++++++++++++++++++++------------------------------------
environment | 41 ---------------------------------
setup.sh | 49 ----------------------------------------
3 files changed, 30 insertions(+), 135 deletions(-)
diff --git a/Makefile b/Makefile
index c92b273..8524854 100644
--- a/Makefile
+++ b/Makefile
@@ -15,71 +15,56 @@
# specific language governing permissions and limitations
# under the License.
-OPTEE_PATH ?= $(OPTEE_DIR)
-OPTEE_BUILD_PATH ?= $(OPTEE_PATH)/build
-OPTEE_OS_PATH ?= $(OPTEE_PATH)/optee_os
-OPTEE_CLIENT_PATH ?= $(OPTEE_PATH)/optee_client
-
-CCACHE ?= $(shell which ccache)
+ifneq ($V,1)
+ q := @
+ echo := @echo
+else
+ q :=
+ echo := @:
+endif
EXAMPLES = $(wildcard examples/*)
EXAMPLES_INSTALL = $(EXAMPLES:%=%-install)
EXAMPLES_CLEAN = $(EXAMPLES:%=%-clean)
ifneq ($(ARCH), arm)
- VENDOR := qemu_v8.mk
- AARCH_CROSS_COMPILE := $(OPTEE_PATH)/toolchains/aarch64/bin/aarch64-linux-gnu-
- HOST_TARGET := aarch64-unknown-linux-gnu
- TA_TARGET := aarch64-unknown-linux-gnu
+ CROSS_COMPILE ?= aarch64-linux-gnu-
+ TARGET := aarch64-unknown-linux-gnu
else
- VENDOR := qemu.mk
- ARCH_CROSS_COMPILE := $(OPTEE_PATH)/toolchains/aarch32/bin/arm-linux-gnueabihf-
- HOST_TARGET := arm-unknown-linux-gnueabihf
- TA_TARGET := arm-unknown-linux-gnueabihf
+ CROSS_COMPILE ?= arm-linux-gnueabihf-
+ TARGET := arm-unknown-linux-gnueabihf
endif
-all: toolchains optee-os optee-client examples
-optee: toolchains optee-os optee-client
-
-toolchains:
- make -C $(OPTEE_BUILD_PATH) -f $(VENDOR) toolchains
-
-optee-os:
- make -C $(OPTEE_BUILD_PATH) -f $(VENDOR) optee-os
+export ARCH
-OPTEE_CLIENT_FLAGS ?= CROSS_COMPILE="$(CCACHE) $(AARCH_CROSS_COMPILE)" \
- CFG_TEE_BENCHMARK=n \
- CFG_TA_TEST_PATH=y \
- WITH_TEEACL=0
-
-optee-client:
- make -C $(OPTEE_CLIENT_PATH) $(OPTEE_CLIENT_FLAGS)
+.PHONY: all
+ifneq ($(wildcard $(TA_DEV_KIT_DIR)/host_include/conf.mk),)
+all: examples examples-install
+else
+all:
+ $(q)echo "TA_DEV_KIT_DIR is not correctly defined" && false
+endif
-examples: $(EXAMPLES) toolchains optee-os optee-client
+examples: $(EXAMPLES)
$(EXAMPLES):
- make -C $@
+ $(q)make -C $@ CROSS_COMPILE=$(CROSS_COMPILE) TA_DEV_KIT_DIR=$(TA_DEV_KIT_DIR) \
+ OPTEE_CLIENT_EXPORT=$(OPTEE_CLIENT_EXPORT)
examples-install: $(EXAMPLES_INSTALL)
-$(EXAMPLES_INSTALL):
- install -D $(@:%-install=%)/host/target/$(HOST_TARGET)/release/$(@:examples/%-install=%) -t out/host/
- install -D $(@:%-install=%)/ta/target/$(TA_TARGET)/release/*.ta -t out/ta/
- if [ -d "$(@:%-install=%)/plugin/target/" ]; then \
- install -D $(@:%-install=%)/plugin/target/$(HOST_TARGET)/release/*.plugin.so -t out/plugin/; \
+$(EXAMPLES_INSTALL): examples
+ install -D $(@:%-install=%)/host/target/$(TARGET)/release/$(@:examples/%-install=%) -t out/host/
+ install -D $(@:%-install=%)/ta/target/$(TARGET)/release/*.ta -t out/ta/
+ $(q)if [ -d "$(@:%-install=%)/plugin/target/" ]; then \
+ install -D $(@:%-install=%)/plugin/target/$(TARGET)/release/*.plugin.so -t out/plugin/; \
fi
-optee-os-clean:
- make -C $(OPTEE_OS_PATH) O=out/arm clean
-
-optee-client-clean:
- make -C $(OPTEE_CLIENT_PATH) $(OPTEE_CLIENT_CLEAN_FLAGS) clean
-
examples-clean: $(EXAMPLES_CLEAN) out-clean
$(EXAMPLES_CLEAN):
- make -C $(@:-clean=) clean
+ $(q)make -C $(@:-clean=) clean
out-clean:
rm -rf out
-.PHONY: clean optee-os-clean optee-client-clean $(EXAMPLES) $(EXAMPLES_CLEAN)
+.PHONY: clean $(EXAMPLES) $(EXAMPLES_CLEAN)
-clean: optee-os-clean optee-client-clean $(EXAMPLES_CLEAN)
+clean: $(EXAMPLES_CLEAN) out-clean
diff --git a/environment b/environment
deleted file mode 100644
index 3216d09..0000000
--- a/environment
+++ /dev/null
@@ -1,41 +0,0 @@
-# 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.
-
-export RUST_TARGET_PATH="$(pwd)"
-export RUST_COMPILER_RT_ROOT=$RUST_TARGET_PATH/rust/rust/src/llvm-project/compiler-rt
-if [ -z "$OPTEE_DIR" ]
-then
- export OPTEE_DIR="$(pwd)/optee"
-fi
-export OPTEE_OS_DIR="$OPTEE_DIR/optee_os"
-export OPTEE_CLIENT_DIR="$OPTEE_DIR/optee_client/out"
-export OPTEE_CLIENT_INCLUDE="$OPTEE_DIR/optee_client/out/export/usr/include"
-if [ "$ARCH" = "arm" ]
-then
- export ARCH="arm"
- export PATH=$PATH:$OPTEE_DIR/toolchains/aarch32/bin
- export VENDOR="qemu.mk"
- export OPTEE_OS_INCLUDE="$OPTEE_DIR/optee_os/out/arm/export-ta_arm32/include"
- export CC=$OPTEE_DIR/toolchains/aarch32/bin/arm-linux-gnueabihf-gcc
-else
- # export ARCH="aarch64" # comment this because currently optee_os cannot be compiled in the aarch64 target
- unset ARCH
- export PATH=$PATH:$OPTEE_DIR/toolchains/aarch64/bin
- export VENDOR="qemu_v8.mk"
- export OPTEE_OS_INCLUDE="$OPTEE_DIR/optee_os/out/arm/export-ta_arm64/include"
- export CC=$OPTEE_DIR/toolchains/aarch64/bin/aarch64-linux-gnu-gcc
-fi
diff --git a/setup.sh b/setup.sh
index fda0e08..7e439d1 100755
--- a/setup.sh
+++ b/setup.sh
@@ -38,52 +38,3 @@ fi
# rustup-wrapped command to trigger installation. We've arbitrarily chosen
# "cargo --version" since it has no other effect.
cargo --version >/dev/null
-
-########################################################
-# initialize submodules: optee_os / optee_client / build
-OPTEE_RELEASE_VERSION=3.20.0
-
-if [[ -z "$OPTEE_DIR" ]] || [[ "$OPTEE_DIR" == "$(pwd)/optee" ]]
-then
- OPTEE_DIR="$(pwd)/optee"
- echo "optee dir: $OPTEE_DIR"
- OPTEE_SUBMODULES=(optee_os optee_client build)
-
- if [ ! -d "$OPTEE_DIR" ]
- then
- mkdir "$OPTEE_DIR"
- else
- rm -r "$OPTEE_DIR"/*
- fi
-
- # download optee release
- echo "Downloading optee release..."
- for submodule in ${OPTEE_SUBMODULES[*]}
- do
- echo "Downloading $submodule..."
- curl --retry 5 -s -S \
- -L "https://github.com/OP-TEE/$submodule/archive/refs/tags/$OPTEE_RELEASE_VERSION.tar.gz" \
- -o "$OPTEE_DIR/$OPTEE_RELEASE_VERSION.tar.gz"
- if [ ! $? -eq 0 ]
- then
- rm "$OPTEE_DIR/$OPTEE_RELEASE_VERSION.tar.gz" && \
- echo "Download failed" && \
- exit 1
- fi
- echo "Uncompressing $submodule..."
- mkdir -p "$OPTEE_DIR/$submodule" && \
- tar zxf "$OPTEE_DIR/$OPTEE_RELEASE_VERSION.tar.gz" \
- -C "$OPTEE_DIR/$submodule" --strip-components 1
- if [ ! $? -eq 0 ]
- then
- rm "$OPTEE_DIR/$OPTEE_RELEASE_VERSION.tar.gz" && \
- rm -r "$OPTEE_DIR/$submodule" && \
- echo "Downloaded file is damaged" && \
- exit 1
- fi
- rm "$OPTEE_DIR/$OPTEE_RELEASE_VERSION.tar.gz"
- done
- echo "Download finished"
-else
- echo "OPTEE_DIR has been set, omit to download optee submodules"
-fi
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org