Skip to content

Commit

Permalink
Makefile: Drop automatic OP-TEE modules build
Browse files Browse the repository at this point in the history
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 <sumit.garg@linaro.org>
  • Loading branch information
b49020 committed Dec 29, 2023
1 parent ad256a0 commit 86655b1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 135 deletions.
75 changes: 30 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
41 changes: 0 additions & 41 deletions environment

This file was deleted.

49 changes: 0 additions & 49 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 86655b1

Please sign in to comment.