diff --git a/sdk/build/BUILD.gn b/sdk/build/BUILD.gn index af7d589..eda9e72 100644 --- a/sdk/build/BUILD.gn +++ b/sdk/build/BUILD.gn @@ -31,6 +31,14 @@ copy("tee_ndk_cmake") { outputs = [ "$ndk_os_irrelevant_out_dir/build/teekit/cmake/{{source_file_part}}" ] } +copy("tee_ndk_cmake_ide") { + sources = [ + "./cmake_ide/common.cmake", + "./cmake_ide/common_flags.cmake", + ] + outputs = [ "$ndk_os_irrelevant_out_dir/build/teekit/cmake_ide/{{source_file_part}}" ] +} + copy("tee_ndk_config") { sources = [ "config/config_ta_public.ini", @@ -95,6 +103,7 @@ group("tee_ndk_ta_linux_compile") { deps = [ ":tee_ndk_make", ":tee_ndk_cmake", + ":tee_ndk_cmake_ide", ":tee_ndk_config", ":tee_ndk_script", ":tee_ndk_ld", diff --git a/sdk/build/cmake_ide/common.cmake b/sdk/build/cmake_ide/common.cmake new file mode 100644 index 0000000..9f54614 --- /dev/null +++ b/sdk/build/cmake_ide/common.cmake @@ -0,0 +1,34 @@ +# Copyright (C) 2026 Huawei Technologies Co., Ltd. +# Licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +set(TEE_OH_PATH $ENV{TEE_OH_PATH}) +set(TEE_OH_BUILD_PATH $ENV{TEE_OH_BUILD_PATH}) + +include (${TEE_OH_BUILD_PATH}/cmake_ide/common_flags.cmake) + +set(COMMON_INCLUDES_FLAGS + ${COMMON_INCLUDES_FLAGS} + "-I${TEE_OH_PATH}/sysroot/usr/include/TEEKit/tee" +) + +if (NOT "${TARGET_IS_ARM64}" STREQUAL "y") + message(FATAL_ERROR "32-bit TA compilation is not supported") + +else() + list(APPEND COMMON_INCLUDES_FLAGS + "-I${TEE_OH_PATH}/sysroot/usr/include/" + "-I${TEE_OH_PATH}/sysroot/usr/include/aarch64-linux-ohos/" + ) + + list(APPEND COMMON_LDFLAGS + "-T${TEE_OH_BUILD_PATH}/ld/ta_link_64.ld" + ) +endif() diff --git a/sdk/build/cmake_ide/common_flags.cmake b/sdk/build/cmake_ide/common_flags.cmake new file mode 100644 index 0000000..50641e5 --- /dev/null +++ b/sdk/build/cmake_ide/common_flags.cmake @@ -0,0 +1,80 @@ +# Copyright (C) 2026 Huawei Technologies Co., Ltd. +# Licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +list(APPEND COMMON_LDFLAGS + "-s" + "-z" "text" + "-z" "now" + "-z" "relro" + "-z" "noexecstack" + "-shared" +) +if ("${CONFIG_GCC}" STREQUAL "n") + list(APPEND COMMON_LDFLAGS + "-z" "max-page-size=4096" + "--execute-only" + ) +endif() +set(COMMON_LDFLAGS ${COMMON_LDFLAGS} CACHE INTERNAL "") + +list(APPEND COMMON_CFLAGS + -Wall + -Werror + -Wdate-time + -Wfloat-equal + -Wshadow + -fno-short-enums + -fno-omit-frame-pointer + -Wstack-protector + --param ssp-buffer-size=4 + -Wextra + -nostdinc + -march=armv8-a + -fPIC + -fno-common + -fsigned-char + -DCONFIG_AUTH_TERMINAL + -pipe +) +if ("${CONFIG_GCC}" STREQUAL "y") + list(APPEND COMMON_CFLAGS + -W + -fstack-protector + -Os + -fno-peephole + -fno-peephole2 + ) +else() + list(APPEND COMMON_CFLAGS + -fstack-protector-strong + -funwind-tables + -Oz + -munaligned-access + -fmax-type-align=1 + -flto + -fvisibility=default + -fsanitize=cfi + -fno-exceptions + -ftrivial-auto-var-init=zero + -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang + ) + if ("${TARGET_IS_ARM64}" STREQUAL "n") + list(APPEND COMMON_CFLAGS + --target=arm-linux-gnu + -mfloat-abi=soft + ) + else() + list(APPEND COMMON_CFLAGS + --target=aarch64-linux-gnu + ) + endif() +endif() +set(COMMON_CFLAGS ${COMMON_CFLAGS} CACHE INTERNAL "")