Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 1 | #/** @file |
jothikumar mani | 18b98e0 | 2023-04-05 00:39:23 +0800 | [diff] [blame] | 2 | # * Copyright (c) 2019-2023, Arm Limited or its affiliates. All rights reserved. |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 3 | # * SPDX-License-Identifier : Apache-2.0 |
jothikumar mani | 36b2b86 | 2023-05-05 13:51:27 +0530 | [diff] [blame] | 4 | # * Copyright 2023 NXP |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 5 | # * |
| 6 | # * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # * you may not use this file except in compliance with the License. |
| 8 | # * You may obtain a copy of the License at |
| 9 | # * |
| 10 | # * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # * |
| 12 | # * Unless required by applicable law or agreed to in writing, software |
| 13 | # * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # * See the License for the specific language governing permissions and |
| 16 | # * limitations under the License. |
| 17 | #**/ |
| 18 | |
| 19 | # Set the minimum required version of CMake for the project |
| 20 | cmake_minimum_required(VERSION 3.10) |
| 21 | |
| 22 | # cmake_policy |
| 23 | cmake_policy(SET CMP0057 NEW) |
| 24 | |
| 25 | # Find python interpreter version 3 or greater |
| 26 | find_package(PythonInterp 3 REQUIRED) |
| 27 | # Find Git package |
| 28 | find_package(Git REQUIRED) |
| 29 | |
| 30 | get_filename_component(PSA_ROOT_DIR . ABSOLUTE) |
| 31 | |
Lingkai Dong | 9d4e7df | 2021-01-13 16:57:54 +0000 | [diff] [blame] | 32 | include(${PSA_ROOT_DIR}/tools/cmake/common/Utils.cmake) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 33 | include(${PSA_ROOT_DIR}/tools/cmake/common/CMakeSettings.cmake) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 34 | include(${PSA_ROOT_DIR}/tools/cmake/common/CMakeExternal.cmake) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 35 | |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 36 | if(NOT DEFINED TFM_PROFILE) |
| 37 | message(STATUS "[PSA] : Building Default profile") |
| 38 | list(APPEND PSA_SUITES |
| 39 | "IPC" |
| 40 | "CRYPTO" |
| 41 | "INTERNAL_TRUSTED_STORAGE" |
| 42 | "PROTECTED_STORAGE" |
| 43 | "STORAGE" |
| 44 | "INITIAL_ATTESTATION" |
| 45 | ) |
| 46 | else() |
| 47 | |
| 48 | if("${TFM_PROFILE}" STREQUAL "profile_small") |
| 49 | # list of supported suites |
| 50 | list(APPEND PSA_SUITES |
| 51 | "CRYPTO" |
| 52 | "INTERNAL_TRUSTED_STORAGE" |
| 53 | "INITIAL_ATTESTATION" |
| 54 | ) |
| 55 | else() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 56 | # list of supported suites |
| 57 | list(APPEND PSA_SUITES |
| 58 | "IPC" |
| 59 | "CRYPTO" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 60 | "INTERNAL_TRUSTED_STORAGE" |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 61 | "PROTECTED_STORAGE" |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 62 | "STORAGE" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 63 | "INITIAL_ATTESTATION" |
| 64 | ) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 65 | endif() |
| 66 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 67 | # list of ipc files required |
| 68 | list(APPEND PSA_IPC_FILES |
| 69 | "psa/client.h" |
| 70 | "psa/service.h" |
Jaykumar Pitambarbhai Patel | 1c2b028 | 2019-11-06 11:29:13 +0530 | [diff] [blame] | 71 | "psa/lifecycle.h" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 72 | "psa_manifest/sid.h" |
| 73 | "psa_manifest/pid.h" |
Jaykumar Pitambarbhai Patel | 1c2b028 | 2019-11-06 11:29:13 +0530 | [diff] [blame] | 74 | "psa_manifest/driver_partition_psa.h" |
| 75 | "psa_manifest/client_partition_psa.h" |
| 76 | "psa_manifest/server_partition_psa.h" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 77 | ) |
| 78 | |
| 79 | # list of crypto files required |
| 80 | list(APPEND PSA_CRYPTO_FILES |
| 81 | "psa/crypto.h" |
| 82 | ) |
| 83 | |
| 84 | # list of protected_storage files required |
| 85 | list(APPEND PSA_PROTECTED_STORAGE_FILES |
| 86 | "psa/protected_storage.h" |
| 87 | ) |
| 88 | |
| 89 | # list of internal_trusted_storage files required |
| 90 | list(APPEND PSA_INTERNAL_TRUSTED_STORAGE_FILES |
| 91 | "psa/internal_trusted_storage.h" |
| 92 | ) |
| 93 | |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 94 | # list of storage files required |
| 95 | list(APPEND PSA_STORAGE_FILES |
| 96 | ${PSA_INTERNAL_TRUSTED_STORAGE_FILES} |
| 97 | ${PSA_PROTECTED_STORAGE_FILES} |
| 98 | ) |
| 99 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 100 | # list of initial_attestation files required |
| 101 | list(APPEND PSA_INITIAL_ATTESTATION_FILES |
| 102 | "psa/initial_attestation.h" |
| 103 | "psa/crypto.h" |
| 104 | ) |
| 105 | |
| 106 | # list of supported toolchains |
| 107 | list(APPEND PSA_TOOLCHAIN_SUPPORT |
| 108 | GNUARM |
| 109 | ARMCLANG |
| 110 | HOST_GCC |
jk-arm | 7e6145a | 2021-07-19 19:36:14 +0530 | [diff] [blame] | 111 | GCC_LINUX |
| 112 | INHERIT |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 113 | ) |
| 114 | |
Øyvind Rønningstad | c50804e | 2021-03-12 12:43:25 +0100 | [diff] [blame] | 115 | # list of supported CROSS_COMPILE toolchains |
| 116 | list(APPEND CROSS_COMPILE_TOOLCHAIN_SUPPORT |
| 117 | GNUARM |
jk-arm | 7e6145a | 2021-07-19 19:36:14 +0530 | [diff] [blame] | 118 | ARMCLANG |
| 119 | INHERIT |
Øyvind Rønningstad | c50804e | 2021-03-12 12:43:25 +0100 | [diff] [blame] | 120 | ) |
| 121 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 122 | # list of suported CPU arch |
| 123 | list(APPEND PSA_CPU_ARCH_SUPPORT |
| 124 | armv8m_ml |
| 125 | armv8m_bl |
Dávid Házi | 330c4b1 | 2023-05-03 11:20:02 +0200 | [diff] [blame] | 126 | armv81m_ml |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 127 | armv7m |
jothikumar mani | 4a27416 | 2023-07-18 00:31:22 +0800 | [diff] [blame] | 128 | armv7a |
jotman01 | bed7a15 | 2021-05-25 22:57:17 +0800 | [diff] [blame] | 129 | armv8a |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 130 | ) |
| 131 | |
| 132 | # list of VERBOSE options |
| 133 | list(APPEND PSA_VERBOSE_OPTIONS 1 2 3 4 5) |
| 134 | |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 135 | # list of PLATFORM_PSA_ISOLATION_LEVEL options |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 136 | if("${TFM_PROFILE}" STREQUAL "profile_medium") |
| 137 | list(APPEND PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS 1 2) |
| 138 | else() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 139 | list(APPEND PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS 1 2 3) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 140 | endif() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 141 | |
jk-arm | 01ee3ff | 2021-10-18 22:41:47 +0530 | [diff] [blame] | 142 | #list of INCLUDE_PANIC_TESTS options |
| 143 | list(APPEND PSA_INCLUDE_PANIC_TESTS_OPTIONS 0 1) |
| 144 | |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 145 | # list of available spec version |
| 146 | if("${SUITE}" STREQUAL "STORAGE" OR ${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE" OR ${SUITE} STREQUAL "PROTECTED_STORAGE") |
| 147 | list(APPEND PSA_SPEC_VERSION |
| 148 | 1.0-BETA2 |
| 149 | 1.0 |
| 150 | ) |
| 151 | elseif("${SUITE}" STREQUAL "CRYPTO") |
| 152 | list(APPEND PSA_SPEC_VERSION |
| 153 | 1.0-BETA1 |
| 154 | 1.0-BETA2 |
| 155 | 1.0-BETA3 |
| 156 | ) |
| 157 | elseif("${SUITE}" STREQUAL "INITIAL_ATTESTATION") |
| 158 | list(APPEND PSA_SPEC_VERSION |
| 159 | 1.0-BETA0 |
| 160 | 1.0.0 |
| 161 | 1.0.1 |
| 162 | 1.0.2 |
| 163 | ) |
jk-arm | 957cfea | 2021-06-18 15:52:12 +0530 | [diff] [blame] | 164 | elseif("${SUITE}" STREQUAL "IPC") |
| 165 | list(APPEND PSA_SPEC_VERSION |
| 166 | 1.0 |
| 167 | 1.1 |
| 168 | ) |
jk-arm | 957cfea | 2021-06-18 15:52:12 +0530 | [diff] [blame] | 169 | endif() |
| 170 | |
| 171 | #list of values available for connection based |
| 172 | if(${SUITE} STREQUAL "IPC") |
| 173 | list(APPEND PSA_STATELESS_ROT 0 1) |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 174 | endif() |
| 175 | |
jk-arm | 01ee3ff | 2021-10-18 22:41:47 +0530 | [diff] [blame] | 176 | #list of TESTS_COVERAGE available options |
| 177 | list(APPEND PSA_TESTS_COVERAGE_OPTIONS |
| 178 | "ALL" |
| 179 | "PASS" |
| 180 | ) |
| 181 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 182 | message(STATUS "[PSA] : ----------Process input arguments- start-------------") |
| 183 | |
| 184 | # Check for TARGET command line argument |
| 185 | _check_arguments("TARGET") |
| 186 | # Check for SUTIE command line argument |
| 187 | _check_arguments("SUITE") |
| 188 | # Check for PSA_INCLUDE_PATHS command line argument |
| 189 | _check_arguments("PSA_INCLUDE_PATHS") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 190 | |
| 191 | string(TOLOWER ${SUITE} SUITE_LOWER) |
| 192 | |
| 193 | # Check for valid targets |
| 194 | _get_sub_dir_list(PSA_TARGET_LIST ${PSA_ROOT_DIR}/platform/targets) |
| 195 | if(NOT ${TARGET} IN_LIST PSA_TARGET_LIST) |
Øyvind Rønningstad | abbb727 | 2020-11-09 14:50:54 +0100 | [diff] [blame] | 196 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DTARGET=${TARGET}, supported targets are : ${PSA_TARGET_LIST}") |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 197 | else() |
| 198 | message(STATUS "[PSA] : TARGET is set to ${TARGET}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 199 | endif() |
| 200 | |
| 201 | # Check for the presence of required test suite directories |
| 202 | if((NOT IS_DIRECTORY ${PSA_ROOT_DIR}/dev_apis) OR (NOT IS_DIRECTORY ${PSA_ROOT_DIR}/ff)) |
| 203 | message(STATUS "[PSA] : Error: Could not find architecture test suite directories in psa root path ${PSA_ROOT_DIR}") |
| 204 | endif() |
| 205 | |
| 206 | if(FALSE) |
| 207 | # Check for build directory specified |
| 208 | if(NOT DEFINED BUILD) |
| 209 | set(BUILD ${CMAKE_CURRENT_BINARY_DIR}/BUILD CACHE INTERNAL "Defaulting build directory to ${BUILD}" FORCE) |
| 210 | else() |
| 211 | set(BUILD ${CMAKE_CURRENT_BINARY_DIR}/${BUILD}/BUILD CACHE INTERNAL "Defaulting build directory to ${BUILD}" FORCE) |
| 212 | endif() |
| 213 | endif() |
| 214 | |
| 215 | # Check for valid suite cmake argument passed |
| 216 | if(NOT ${SUITE} IN_LIST PSA_SUITES) |
Øyvind Rønningstad | abbb727 | 2020-11-09 14:50:54 +0100 | [diff] [blame] | 217 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DSUITE=${SUITE}, select one from supported suites which are : ${PSA_SUITES}") |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 218 | else() |
| 219 | message(STATUS "[PSA] : SUITE is set to ${SUITE}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 220 | endif() |
| 221 | |
| 222 | # Project variables |
| 223 | set(PSA_TARGET_PRE_BUILD psa_pre_build) |
| 224 | set(PSA_TARGET_GENERATE_DATABASE_PRE psa_generate_database_prerequisite) |
| 225 | set(PSA_TARGET_GENERATE_DATABASE psa_generate_database) |
| 226 | set(PSA_TARGET_GENERATE_DATABASE_POST psa_generate_database_cleanup) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 227 | if(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 228 | set(PSA_TARGET_QCBOR ${CMAKE_CURRENT_BINARY_DIR}/psa_qcbor CACHE PATH "Location of Q_CBOR sources.") |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 229 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 230 | set(PSA_TARGET_PAL_NSPE_LIB pal_nspe) |
| 231 | set(PSA_TARGET_VAL_NSPE_LIB val_nspe) |
| 232 | set(PSA_TARGET_TEST_COMBINE_LIB test_combine) |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 233 | set(PSA_TARGET_DRIVER_PARTITION_LIB tfm_psa_rot_partition_driver_partition) |
| 234 | set(PSA_TARGET_CLIENT_PARTITION_LIB tfm_app_rot_partition_client_partition) |
| 235 | set(PSA_TARGET_SERVER_PARTITION_LIB tfm_app_rot_partition_server_partition) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 236 | if(${SUITE} STREQUAL "IPC") |
| 237 | set(PSA_SUITE_DIR ${PSA_ROOT_DIR}/ff/${SUITE_LOWER}) |
| 238 | set(PSA_SUITE_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/ff/${SUITE_LOWER}) |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 239 | elseif((${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE") OR (${SUITE} STREQUAL "PROTECTED_STORAGE")) |
| 240 | set(PSA_SUITE_DIR ${PSA_ROOT_DIR}/dev_apis/storage) |
| 241 | set(PSA_SUITE_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/dev_apis/storage) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 242 | else() |
| 243 | set(PSA_SUITE_DIR ${PSA_ROOT_DIR}/dev_apis/${SUITE_LOWER}) |
| 244 | set(PSA_SUITE_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/dev_apis/${SUITE_LOWER}) |
| 245 | endif() |
| 246 | set(PSA_TARGET_CONFIG_HEADER_GENERATOR ${PSA_ROOT_DIR}/tools/scripts/target_cfg/targetConfigGen.py) |
| 247 | set(PSA_TESTLIST_GENERATOR ${PSA_ROOT_DIR}/tools/scripts/gen_tests_list.py) |
| 248 | set(TARGET_CONFIGURATION_FILE ${PSA_ROOT_DIR}/platform/targets/${TARGET}/target.cfg) |
| 249 | set(TGT_CONFIG_SOURCE_C ${CMAKE_CURRENT_BINARY_DIR}/targetConfigGen.c) |
| 250 | set(OUTPUT_HEADER target_database.h) |
| 251 | set(DATABASE_TABLE_NAME target_database) |
| 252 | set(DATABASE_TABLE_SECTION_NAME "NOSECTION") |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 253 | set(TARGET_HEADER_GEN_INCLUDE_PATHS "${PSA_ROOT_DIR}/val/nspe|${PSA_ROOT_DIR}/val/common|${PSA_ROOT_DIR}/platform/targets/common/nspe|${PSA_ROOT_DIR}/platform/targets/common/nspe/crypto|${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe") |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 254 | if(NOT DEFINED SPEC_VERSION) |
| 255 | if(${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE") |
| 256 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/its_testsuite.db) |
| 257 | elseif((${SUITE} STREQUAL "PROTECTED_STORAGE") OR (${SUITE} STREQUAL "STORAGE")) |
| 258 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/ps_testsuite.db) |
jothikumar mani | 18b98e0 | 2023-04-05 00:39:23 +0800 | [diff] [blame] | 259 | elseif(${SUITE} STREQUAL "CRYPTO") |
| 260 | if(DEFINED BESPOKE_SUITE_TESTS) |
| 261 | set(TESTSUITE_DB ${PSA_ROOT_DIR}/platform/targets/${TARGET}/${BESPOKE_SUITE_TESTS}) |
| 262 | else() |
| 263 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/testsuite.db) |
| 264 | endif() |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 265 | else() |
| 266 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/testsuite.db) |
| 267 | endif() |
jothikumar mani | 18b98e0 | 2023-04-05 00:39:23 +0800 | [diff] [blame] | 268 | message(STATUS "[PSA] : Selected test database file : ${TESTSUITE_DB}") |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 269 | else() |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 270 | if(${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE") |
| 271 | if(${SPEC_VERSION} STREQUAL "1.0-BETA2") |
| 272 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/its_1.0-beta2_testsuite.db) |
| 273 | endif() |
| 274 | if(${SPEC_VERSION} STREQUAL "1.0") |
| 275 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/its_1.0_testsuite.db) |
| 276 | endif() |
| 277 | elseif((${SUITE} STREQUAL "PROTECTED_STORAGE") OR (${SUITE} STREQUAL "STORAGE")) |
| 278 | if(${SPEC_VERSION} STREQUAL "1.0-BETA2") |
| 279 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/ps_1.0-beta2_testsuite.db) |
| 280 | endif() |
| 281 | if(${SPEC_VERSION} STREQUAL "1.0") |
| 282 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/ps_1.0_testsuite.db) |
| 283 | endif() |
| 284 | elseif(${SUITE} STREQUAL "CRYPTO") |
| 285 | if(${SPEC_VERSION} STREQUAL "1.0-BETA1") |
| 286 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0-beta1_testsuite.db) |
| 287 | endif() |
| 288 | if(${SPEC_VERSION} STREQUAL "1.0-BETA2") |
| 289 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0-beta2_testsuite.db) |
| 290 | endif() |
| 291 | if(${SPEC_VERSION} STREQUAL "1.0-BETA3") |
| 292 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0-beta3_testsuite.db) |
| 293 | endif() |
| 294 | elseif(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
| 295 | if(${SPEC_VERSION} STREQUAL "1.0-BETA0") |
| 296 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0-beta0_testsuite.db) |
| 297 | endif() |
| 298 | if(${SPEC_VERSION} STREQUAL "1.0.0") |
| 299 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0.0_testsuite.db) |
| 300 | endif() |
| 301 | if(${SPEC_VERSION} STREQUAL "1.0.1") |
| 302 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0.1_testsuite.db) |
| 303 | endif() |
| 304 | if(${SPEC_VERSION} STREQUAL "1.0.2") |
| 305 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0.2_testsuite.db) |
| 306 | endif() |
jk-arm | 957cfea | 2021-06-18 15:52:12 +0530 | [diff] [blame] | 307 | elseif(${SUITE} STREQUAL "IPC") |
| 308 | if(${SPEC_VERSION} STREQUAL "1.1") |
| 309 | if(DEFINED STATELESS_ROT_TESTS) |
| 310 | if(${STATELESS_ROT_TESTS} EQUAL 1) |
| 311 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/stateless_rot_testsuite.db) |
| 312 | else() |
| 313 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/testsuite.db) |
| 314 | endif() |
| 315 | else() |
| 316 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/testsuite.db) |
| 317 | endif() |
| 318 | else() |
| 319 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/testsuite.db) |
| 320 | endif() |
| 321 | endif() |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 322 | endif() |
| 323 | set(PSA_TESTLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/${SUITE_LOWER}_testlist.txt) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 324 | set(PSA_TEST_ENTRY_LIST_INC ${CMAKE_CURRENT_BINARY_DIR}/test_entry_list.inc) |
| 325 | set(PSA_TEST_ENTRY_FUN_DECLARE_INC ${CMAKE_CURRENT_BINARY_DIR}/test_entry_fn_declare_list.inc) |
| 326 | set(PSA_CLIENT_TEST_LIST_DELCARE_INC ${CMAKE_CURRENT_BINARY_DIR}/client_tests_list_declare.inc) |
| 327 | set(PSA_CLIENT_TEST_LIST_INC ${CMAKE_CURRENT_BINARY_DIR}/client_tests_list.inc) |
| 328 | set(PSA_SERVER_TEST_LIST_DECLARE_INC ${CMAKE_CURRENT_BINARY_DIR}/server_tests_list_declare.inc) |
| 329 | set(PSA_SERVER_TEST_LIST ${CMAKE_CURRENT_BINARY_DIR}/server_tests_list.inc) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 330 | if(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 331 | set(PSA_QCBOR_INCLUDE_PATH ${PSA_TARGET_QCBOR}/inc) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 332 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 333 | |
| 334 | # Validity check for required files for a given suite |
| 335 | if(NOT DEFINED PSA_${SUITE}_FILES) |
| 336 | message(FATAL_ERROR "[PSA] : List of file/s to verify against ${suite} is not defined") |
| 337 | endif() |
| 338 | foreach(file_item ${PSA_${SUITE}_FILES}) |
| 339 | set(PSA_FILE_FOUND FALSE) |
| 340 | foreach(include_path ${PSA_INCLUDE_PATHS}) |
| 341 | if((EXISTS ${include_path}/${file_item}) AND |
| 342 | (NOT PSA_FILE_FOUND)) |
| 343 | set(PSA_FILE_FOUND TRUE) |
| 344 | break() |
| 345 | endif() |
| 346 | endforeach() |
| 347 | if(NOT PSA_FILE_FOUND) |
| 348 | message(FATAL_ERROR "[PSA] : Couldn't find ${file_item} in ${PSA_INCLUDE_PATHS}") |
| 349 | endif() |
| 350 | endforeach() |
| 351 | |
| 352 | # Check for TOOLCHAIN command line argument |
| 353 | if(NOT DEFINED TOOLCHAIN) |
| 354 | set(TOOLCHAIN "GNUARM" CACHE INTERNAL "Compiler used" FORCE) |
| 355 | message(STATUS "[PSA] : Defaulting compiler to ${TOOLCHAIN}") |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 356 | else() |
| 357 | message(STATUS "[PSA] : TOOLCHAIN is set to ${TOOLCHAIN}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 358 | endif() |
| 359 | |
Gowtham Siddarth | 1d6d469 | 2019-09-16 11:47:29 +0530 | [diff] [blame] | 360 | if(${TOOLCHAIN} STREQUAL "ARMCLANG" OR ${TOOLCHAIN} STREQUAL "GNUARM") |
| 361 | if(NOT DEFINED CPU_ARCH) |
| 362 | message(FATAL_ERROR "[PSA] : Error: -DCPU_ARCH option missing") |
| 363 | else() |
| 364 | # Check for CPU architecture |
| 365 | if(NOT ${CPU_ARCH} IN_LIST PSA_CPU_ARCH_SUPPORT) |
Øyvind Rønningstad | abbb727 | 2020-11-09 14:50:54 +0100 | [diff] [blame] | 366 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DCPU_ARCH=${CPU_ARCH}, supported CPU arch are : ${PSA_CPU_ARCH_SUPPORT}") |
Gowtham Siddarth | 1d6d469 | 2019-09-16 11:47:29 +0530 | [diff] [blame] | 367 | endif() |
| 368 | endif() |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 369 | message(STATUS "[PSA] : CPU_ARCH is set to ${CPU_ARCH}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 370 | endif() |
| 371 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 372 | # Check for VERBOSE |
| 373 | if(NOT DEFINED VERBOSE) |
| 374 | set(VERBOSE 3 CACHE INTERNAL "Default VERBOSE value" FORCE) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 375 | message(STATUS "[PSA] : Defaulting VERBOSE to ${VERBOSE}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 376 | else() |
| 377 | if(NOT ${VERBOSE} IN_LIST PSA_VERBOSE_OPTIONS) |
Øyvind Rønningstad | abbb727 | 2020-11-09 14:50:54 +0100 | [diff] [blame] | 378 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DVERBOSE=${VERBOSE}, supported values are : ${PSA_VERBOSE_OPTIONS}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 379 | endif() |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 380 | message(STATUS "[PSA] : VERBOSE is set to ${VERBOSE}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 381 | endif() |
| 382 | |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 383 | # Check for PLATFORM_PSA_ISOLATION_LEVEL |
| 384 | if(NOT DEFINED PLATFORM_PSA_ISOLATION_LEVEL) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 385 | if("${TFM_PROFILE}" STREQUAL "profile_medium") |
| 386 | set(PLATFORM_PSA_ISOLATION_LEVEL 2 CACHE INTERNAL "Default PLATFORM_PSA_ISOLATION_LEVEL value" FORCE) |
| 387 | else() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 388 | set(PLATFORM_PSA_ISOLATION_LEVEL 3 CACHE INTERNAL "Default PLATFORM_PSA_ISOLATION_LEVEL value" FORCE) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 389 | endif() |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 390 | if(${SUITE} STREQUAL "IPC") |
| 391 | message(STATUS "[PSA] : Defaulting PLATFORM_PSA_ISOLATION_LEVEL to ${PLATFORM_PSA_ISOLATION_LEVEL}") |
| 392 | endif() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 393 | else() |
| 394 | if(NOT ${PLATFORM_PSA_ISOLATION_LEVEL} IN_LIST PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS) |
Øyvind Rønningstad | abbb727 | 2020-11-09 14:50:54 +0100 | [diff] [blame] | 395 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DPLATFORM_PSA_ISOLATION_LEVEL=${PLATFORM_PSA_ISOLATION_LEVEL}, supported values are : ${PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS}") |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 396 | endif() |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 397 | if(${SUITE} STREQUAL "IPC") |
| 398 | message(STATUS "[PSA] : PLATFORM_PSA_ISOLATION_LEVEL is set to ${PLATFORM_PSA_ISOLATION_LEVEL}") |
| 399 | endif() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 400 | endif() |
| 401 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 402 | if(NOT DEFINED INCLUDE_PANIC_TESTS) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 403 | #By default panic tests are disabled |
| 404 | set(INCLUDE_PANIC_TESTS 0 CACHE INTERNAL "Default INCLUDE_PANIC_TESTS value" FORCE) |
| 405 | message(STATUS "[PSA] : Defaulting INCLUDE_PANIC_TESTS to ${INCLUDE_PANIC_TESTS}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 406 | else() |
jk-arm | 01ee3ff | 2021-10-18 22:41:47 +0530 | [diff] [blame] | 407 | if(NOT ${INCLUDE_PANIC_TESTS} IN_LIST PSA_INCLUDE_PANIC_TESTS_OPTIONS) |
| 408 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DINCLUDE_PANIC_TESTS=${INCLUDE_PANIC_TESTS}, supported values are : ${PSA_INCLUDE_PANIC_TESTS_OPTIONS}") |
| 409 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 410 | if(INCLUDE_PANIC_TESTS EQUAL 1) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 411 | message(STATUS "[PSA] : " |
| 412 | "INCLUDE_PANIC_TESTS set to 1, therefore including PSA APIs panic tests into the regression,\n" |
| 413 | "\tensure that watchdog.num is set to 1 in ${PSA_ROOT_DIR}/platform/targets/${TARGET}/target.cfg") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 414 | endif() |
| 415 | endif() |
| 416 | |
| 417 | if(NOT DEFINED WATCHDOG_AVAILABLE) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 418 | #Assuming watchdog is available to program by test suite |
| 419 | set(WATCHDOG_AVAILABLE 1 CACHE INTERNAL "Default WATCHDOG_AVAILABLE value" FORCE) |
| 420 | message(STATUS "[PSA] : Defaulting WATCHDOG_AVAILABLE to ${WATCHDOG_AVAILABLE}") |
| 421 | else() |
| 422 | message(STATUS "[PSA] : WATCHDOG_AVAILABLE is set to ${WATCHDOG_AVAILABLE}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 423 | endif() |
| 424 | |
| 425 | if((INCLUDE_PANIC_TESTS EQUAL 1) AND |
| 426 | (WATCHDOG_AVAILABLE EQUAL 0)) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 427 | message(WARNING "[PSA]: " |
| 428 | "Note that to test PSA APIs panic conditions, test harness may require to access" |
| 429 | "the watchdog timer in oder to recover from panic and to be able to continue with" |
| 430 | "next test. Ignore this warning if system under test has capability to reset the" |
| 431 | "system when it encounters panic condition.") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 432 | endif() |
| 433 | |
| 434 | if(NOT DEFINED SP_HEAP_MEM_SUPP) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 435 | #Are dynamic memory functions available to secure partition? |
| 436 | set(SP_HEAP_MEM_SUPP 1 CACHE INTERNAL "Default SP_HEAP_MEM_SUPP value" FORCE) |
| 437 | message(STATUS "[PSA] : Defaulting SP_HEAP_MEM_SUPP to ${SP_HEAP_MEM_SUPP}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 438 | endif() |
| 439 | |
Vinay Kumar Kotegowder | ac21899 | 2020-04-03 12:56:00 +0530 | [diff] [blame] | 440 | if(NOT DEFINED SUITE_TEST_RANGE) |
| 441 | set(SUITE_TEST_RANGE_MIN None) |
| 442 | set(SUITE_TEST_RANGE_MAX None) |
| 443 | else() |
| 444 | list(LENGTH SUITE_TEST_RANGE SUITE_TEST_RANGE_LENGTH) |
| 445 | if(${SUITE_TEST_RANGE_LENGTH} GREATER "2") |
| 446 | message(FATAL_ERROR "[PSA] : -DSUITE_TEST_RANGE=<...> value error! accepts two " |
| 447 | " numbers in quotes separated with ';'") |
| 448 | endif() |
| 449 | if(${SUITE_TEST_RANGE_LENGTH} EQUAL "2") |
| 450 | list(GET SUITE_TEST_RANGE 0 SUITE_TEST_RANGE_MIN) |
| 451 | list(GET SUITE_TEST_RANGE 1 SUITE_TEST_RANGE_MAX) |
| 452 | message(STATUS "[PSA] : Testing (${SUITE_TEST_RANGE_MIN}, ${SUITE_TEST_RANGE_MAX}) of ${SUITE} suite") |
| 453 | endif() |
| 454 | if(${SUITE_TEST_RANGE_LENGTH} EQUAL "1") |
| 455 | set(SUITE_TEST_RANGE_MIN ${SUITE_TEST_RANGE}) |
| 456 | set(SUITE_TEST_RANGE_MAX ${SUITE_TEST_RANGE}) |
| 457 | message(STATUS "[PSA] : Testing ${SUITE_TEST_RANGE_MIN} of ${SUITE} suite") |
| 458 | endif() |
| 459 | endif() |
| 460 | |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 461 | if(NOT DEFINED SPEC_VERSION) |
| 462 | message(STATUS "[PSA] : Default spec version") |
| 463 | else() |
| 464 | if(NOT ${SPEC_VERSION} IN_LIST PSA_SPEC_VERSION) |
| 465 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DSPEC_VERSION=${SPEC_VERSION}, supported values are : ${PSA_SPEC_VERSION} for ${SUITE}") |
| 466 | else() |
| 467 | message(STATUS "[PSA] : Testing ${SUITE} for spec version ${SPEC_VERSION}") |
| 468 | endif() |
| 469 | endif() |
| 470 | |
jk-arm | 957cfea | 2021-06-18 15:52:12 +0530 | [diff] [blame] | 471 | if(DEFINED STATELESS_ROT_TESTS) |
| 472 | if(NOT ${STATELESS_ROT_TESTS} IN_LIST PSA_STATELESS_ROT) |
| 473 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DSTATELESS_ROT_TESTS=${STATELESS_ROT_TESTS}, supported values are : ${PSA_STATELESS_ROT}") |
| 474 | elseif(${STATELESS_ROT_TESTS} EQUAL 1) |
| 475 | message(STATUS "[PSA] : Testing ${SUITE} for stateless rot") |
| 476 | elseif(${STATELESS_ROT_TESTS} EQUAL 0) |
| 477 | message(STATUS "[PSA] : Testing ${SUITE} for connection based") |
| 478 | endif() |
| 479 | |
| 480 | if(NOT DEFINED SPEC_VERSION) |
| 481 | message(FATAL_ERROR "[PSA] : Error: SPEC_VERSION is require for STATELESS_ROT_TESTS.") |
| 482 | elseif(${SUITE} STREQUAL "IPC") |
| 483 | if(${SPEC_VERSION} STREQUAL "1.0") |
| 484 | message(FATAL_ERROR "[PSA] : Error: STATELESS_ROT_TESTS is only valid for SPEC_VERSION=1.1.") |
| 485 | elseif(${SPEC_VERSION} STREQUAL "1.1") |
| 486 | add_definitions(-DSPEC_VERSION=11) |
| 487 | if(${STATELESS_ROT_TESTS} EQUAL 1) |
| 488 | add_definitions(-DSTATELESS_ROT=1) |
| 489 | elseif(${STATELESS_ROT_TESTS} EQUAL 0) |
| 490 | add_definitions(-DSTATELESS_ROT=0) |
| 491 | endif() |
| 492 | endif() |
| 493 | else() |
| 494 | message(FATAL_ERROR "[PSA] : Error: STATELESS_ROT_TESTS is only applicable to IPC Test Suite.") |
| 495 | endif() |
| 496 | else() |
| 497 | add_definitions(-DSTATELESS_ROT=0) |
| 498 | if(DEFINED SPEC_VERSION) |
| 499 | if(${SUITE} STREQUAL "IPC") |
| 500 | if(${SPEC_VERSION} STREQUAL "1.0") |
| 501 | add_definitions(-DSPEC_VERSION=10) |
| 502 | endif() |
| 503 | if(${SPEC_VERSION} STREQUAL "1.1") |
| 504 | add_definitions(-DSPEC_VERSION=11) |
| 505 | endif() |
| 506 | endif() |
| 507 | endif() |
| 508 | endif() |
| 509 | |
jk-arm | 01ee3ff | 2021-10-18 22:41:47 +0530 | [diff] [blame] | 510 | if(NOT DEFINED TESTS_COVERAGE) |
| 511 | #By default all tests are included |
| 512 | set(TESTS_COVERAGE "ALL" CACHE INTERNAL "Default TESTS_COVERAGE value" FORCE) |
| 513 | message(STATUS "[PSA] : Defaulting TESTS_COVERAGE to ${TESTS_COVERAGE}") |
| 514 | else() |
| 515 | if(NOT ${TESTS_COVERAGE} IN_LIST PSA_TESTS_COVERAGE_OPTIONS) |
| 516 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DTESTS_COVERAGE=${TESTS_COVERAGE}, supported values are : ${PSA_TESTS_COVERAGE_OPTIONS}") |
| 517 | endif() |
| 518 | if(TESTS_COVERAGE STREQUAL ALL) |
| 519 | message(STATUS "[PSA] : " |
| 520 | "TESTS_COVERAGE set to ALL, therefore all tests are included.") |
| 521 | endif() |
| 522 | if(TESTS_COVERAGE STREQUAL PASS) |
| 523 | message(STATUS "[PSA] : " |
| 524 | "TESTS_COVERAGE set to PASS, therefore known failure tests are not included.") |
| 525 | add_definitions(-DTESTS_COVERAGE) |
| 526 | endif() |
| 527 | endif() |
| 528 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 529 | message(STATUS "[PSA] : ----------Process input arguments- complete-------------") |
| 530 | |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 531 | |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 532 | if((${SUITE} STREQUAL "INITIAL_ATTESTATION") AND (NOT EXISTS ${PSA_TARGET_QCBOR})) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 533 | # Clone QCBOR and move to specified tag |
| 534 | execute_process(COMMAND ${GIT_EXECUTABLE} clone ${PSA_QCBOR_GIT_REPO_LINK} ${PSA_TARGET_QCBOR} |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 535 | RESULT_VARIABLE qcbor_clone_result |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 536 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 537 | if(qcbor_clone_result) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 538 | message(FATAL_ERROR "git clone failed for ${PSA_QCBOR_GIT_REPO_LINK}") |
| 539 | endif() |
| 540 | |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 541 | if(NOT qcbor_clone_result) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 542 | execute_process(COMMAND ${GIT_EXECUTABLE} checkout -q "${PSA_QCBOR_GIT_REPO_TAG}" |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 543 | RESULT_VARIABLE qcbor_checkout_result |
| 544 | WORKING_DIRECTORY ${PSA_TARGET_QCBOR}) |
| 545 | if(qcbor_checkout_result) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 546 | message(FATAL_ERROR "git checkout failed for Repo : ${PSA_QCBOR_GIT_REPO_LINK}, Tag : ${PSA_QCBOR_GIT_REPO_TAG}") |
| 547 | endif() |
| 548 | endif() |
| 549 | endif() |
gowtham siddarth | 1283304 | 2020-02-10 22:11:11 +0530 | [diff] [blame] | 550 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 551 | # Create PSA clean list |
| 552 | list(APPEND PSA_CLEAN_LIST |
| 553 | ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_HEADER} |
| 554 | ${PSA_TESTLIST_FILE} |
| 555 | ${PSA_TEST_ENTRY_LIST_INC} |
| 556 | ${PSA_TEST_ENTRY_FUN_DECLARE_INC} |
| 557 | ${PSA_CLIENT_TEST_LIST_DELCARE_INC} |
| 558 | ${PSA_CLIENT_TEST_LIST_INC} |
| 559 | ${PSA_SERVER_TEST_LIST_DECLARE_INC} |
| 560 | ${PSA_SERVER_TEST_LIST} |
| 561 | ) |
| 562 | |
| 563 | # Process testsuite.db |
| 564 | message(STATUS "[PSA] : Creating testlist.txt 'available at ${PSA_TESTLIST_FILE}'") |
| 565 | execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PSA_TESTLIST_GENERATOR} |
| 566 | ${SUITE_LOWER} |
| 567 | ${TESTSUITE_DB} |
| 568 | ${INCLUDE_PANIC_TESTS} |
jk-arm | 01ee3ff | 2021-10-18 22:41:47 +0530 | [diff] [blame] | 569 | ${TESTS_COVERAGE} |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 570 | ${PSA_TESTLIST_FILE} |
| 571 | ${PSA_TEST_ENTRY_LIST_INC} |
| 572 | ${PSA_TEST_ENTRY_FUN_DECLARE_INC} |
| 573 | ${PSA_CLIENT_TEST_LIST_DELCARE_INC} |
| 574 | ${PSA_CLIENT_TEST_LIST_INC} |
| 575 | ${PSA_SERVER_TEST_LIST_DECLARE_INC} |
Vinay Kumar Kotegowder | ac21899 | 2020-04-03 12:56:00 +0530 | [diff] [blame] | 576 | ${PSA_SERVER_TEST_LIST} |
| 577 | ${SUITE_TEST_RANGE_MIN} |
| 578 | ${SUITE_TEST_RANGE_MAX}) |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 579 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 580 | # Creating CMake list variable from file |
| 581 | file(READ ${PSA_TESTLIST_FILE} PSA_TEST_LIST) |
Vinay Kumar Kotegowder | ac21899 | 2020-04-03 12:56:00 +0530 | [diff] [blame] | 582 | if(NOT PSA_TEST_LIST) |
| 583 | message(FATAL_ERROR "[PSA] : Invalid test number!") |
| 584 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 585 | string(REGEX REPLACE "\n" ";" PSA_TEST_LIST "${PSA_TEST_LIST}") |
| 586 | |
| 587 | add_custom_target( |
| 588 | ${PSA_TARGET_GENERATE_DATABASE_PRE} |
| 589 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/platform |
| 590 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/val |
| 591 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/partition |
| 592 | COMMAND ${CMAKE_COMMAND} -E make_directory ${PSA_SUITE_OUT_DIR} |
| 593 | ) |
| 594 | |
| 595 | # Generate target files from User provided data base |
| 596 | include(ExternalProject) |
| 597 | ExternalProject_Add( |
| 598 | ${PSA_TARGET_GENERATE_DATABASE} |
| 599 | PREFIX ${CMAKE_CURRENT_BINARY_DIR} |
| 600 | DOWNLOAD_COMMAND "" |
| 601 | UPDATE_COMMAND "" |
| 602 | PATCH_COMMAND "" |
jothikumar mani | ed3f1c0 | 2023-04-28 16:17:25 +0800 | [diff] [blame] | 603 | BUILD_ALWAYS TRUE |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 604 | SOURCE_DIR "${PSA_ROOT_DIR}/tools/scripts/target_cfg" |
| 605 | CMAKE_ARGS -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} |
| 606 | -DOUT_DIR=${CMAKE_CURRENT_BINARY_DIR} |
| 607 | -DTARGET=${TARGET} |
| 608 | -DGENERATOR_FILE=${PSA_TARGET_CONFIG_HEADER_GENERATOR} |
| 609 | -DINCLUDE_DIR=${PSA_ROOT_DIR}/val/common |
| 610 | -DTARGET_CONFIGURATION_FILE=${TARGET_CONFIGURATION_FILE} |
| 611 | -DTGT_CONFIG_SOURCE_C=${TGT_CONFIG_SOURCE_C} |
| 612 | -DOUTPUT_HEADER=${OUTPUT_HEADER} |
| 613 | -DDATABASE_TABLE_NAME=${DATABASE_TABLE_NAME} |
| 614 | -DDATABASE_TABLE_SECTION_NAME=${DATABASE_TABLE_SECTION_NAME} |
| 615 | -DTARGET_HEADER_GEN_INCLUDE_PATHS=${TARGET_HEADER_GEN_INCLUDE_PATHS} |
| 616 | LIST_SEPARATOR | |
| 617 | TEST_COMMAND "" |
| 618 | ) |
| 619 | |
| 620 | # Add custom target to clean generated files of the external project |
| 621 | add_custom_target( |
| 622 | ${PSA_TARGET_GENERATE_DATABASE_POST} |
| 623 | COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/src/${PSA_TARGET_GENERATE_DATABASE}-build/ -- clean |
| 624 | ) |
| 625 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 626 | # Check for supported toolchain/s |
| 627 | if(${TOOLCHAIN} IN_LIST PSA_TOOLCHAIN_SUPPORT) |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 628 | if (DEFINED CROSS_COMPILE) |
jk-arm | 7e6145a | 2021-07-19 19:36:14 +0530 | [diff] [blame] | 629 | if(NOT (${TOOLCHAIN} IN_LIST CROSS_COMPILE_TOOLCHAIN_SUPPORT)) |
| 630 | message(FATAL_ERROR "[PSA] : Error: CROSS_COMPILE not supported for this toolchain, supported toolchain are : ${CROSS_COMPILE_TOOLCHAIN_SUPPORT}") |
| 631 | endif() |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 632 | endif() |
jk-arm | 7e6145a | 2021-07-19 19:36:14 +0530 | [diff] [blame] | 633 | include(${PSA_ROOT_DIR}/tools/cmake/compiler/${TOOLCHAIN}.cmake) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 634 | else() |
jk-arm | 7e6145a | 2021-07-19 19:36:14 +0530 | [diff] [blame] | 635 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DTOOLCHAIN=${TOOLCHAIN}, supported toolchain are : ${PSA_TOOLCHAIN_SUPPORT}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 636 | endif() |
| 637 | |
| 638 | # Global macro to identify the PSA test suite cmake build |
| 639 | add_definitions(-DPSA_CMAKE_BUILD) |
| 640 | add_definitions(-D${SUITE}) |
| 641 | add_definitions(-DVERBOSE=${VERBOSE}) |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 642 | add_definitions(-DPLATFORM_PSA_ISOLATION_LEVEL=${PLATFORM_PSA_ISOLATION_LEVEL}) |
Vinay Kumar Kotegowder | 52bbfc9 | 2020-07-03 17:23:59 +0530 | [diff] [blame] | 643 | add_definitions(-D${TARGET}) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 644 | if("${TFM_PROFILE}" STREQUAL "profile_small") |
| 645 | message(STATUS "[PSA] : Building SMALL profile") |
| 646 | add_definitions(-DTF_M_PROFILE_SMALL) |
| 647 | elseif("${TFM_PROFILE}" STREQUAL "profile_medium") |
| 648 | message(STATUS "[PSA] : Building MEDIUM profile") |
| 649 | add_definitions(-DTF_M_PROFILE_MEDIUM) |
| 650 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 651 | if(${SP_HEAP_MEM_SUPP} EQUAL 1) |
| 652 | add_definitions(-DSP_HEAP_MEM_SUPP) |
| 653 | endif() |
jotman01 | 38cb53a | 2023-02-14 16:27:06 +0800 | [diff] [blame] | 654 | |
Summer Qin | 937a1ed | 2022-07-13 10:29:26 +0800 | [diff] [blame] | 655 | if(${CC312_LEGACY_DRIVER_API_ENABLED}) |
| 656 | add_definitions(-DCC312_LEGACY_DRIVER_API_ENABLED) |
| 657 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 658 | |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 659 | # Build PAL NSPE LIB |
Bruno De Smet | 593db41 | 2023-03-15 18:47:19 +0100 | [diff] [blame] | 660 | include(${PSA_ROOT_DIR}/platform/targets/common/nspe/pal_nspe.cmake) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 661 | include(${PSA_ROOT_DIR}/platform/targets/${TARGET}/target.cmake) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 662 | # Build VAL NSPE LIB |
| 663 | #add_definitions(-DVAL_NSPE_BUILD) |
| 664 | include(${PSA_ROOT_DIR}/val/val_nspe.cmake) |
| 665 | # Build test |
| 666 | include(${PSA_SUITE_DIR}/suite.cmake) |
| 667 | if(${SUITE} STREQUAL "IPC") |
| 668 | # Build SPE LIB |
| 669 | include(${PSA_ROOT_DIR}/val/val_spe.cmake) |
| 670 | endif() |
| 671 | |
| 672 | add_dependencies(${PSA_TARGET_GENERATE_DATABASE} ${PSA_TARGET_GENERATE_DATABASE_PRE}) |
| 673 | add_dependencies(${PSA_TARGET_GENERATE_DATABASE_POST} ${PSA_TARGET_GENERATE_DATABASE}) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 674 | add_dependencies(${PSA_TARGET_PAL_NSPE_LIB} ${PSA_TARGET_GENERATE_DATABASE_POST}) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 675 | add_dependencies(${PSA_TARGET_VAL_NSPE_LIB} ${PSA_TARGET_PAL_NSPE_LIB}) |
| 676 | add_dependencies(${PSA_TARGET_TEST_COMBINE_LIB} ${PSA_TARGET_VAL_NSPE_LIB}) |
| 677 | if(${SUITE} STREQUAL "IPC") |
| 678 | add_dependencies(${PSA_TARGET_DRIVER_PARTITION_LIB} ${PSA_TARGET_TEST_COMBINE_LIB}) |
| 679 | add_dependencies(${PSA_TARGET_CLIENT_PARTITION_LIB} ${PSA_TARGET_DRIVER_PARTITION_LIB}) |
| 680 | add_dependencies(${PSA_TARGET_SERVER_PARTITION_LIB} ${PSA_TARGET_CLIENT_PARTITION_LIB}) |
| 681 | endif() |
| 682 | |
| 683 | # Include the files for make clean |
| 684 | foreach(clean_item ${PSA_CLEAN_LIST}) |
| 685 | set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clean_item}) |
| 686 | endforeach() |
| 687 | |
| 688 | set_property(TARGET ${PSA_TARGET_VAL_NSPE_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/val) |
| 689 | set_property(TARGET ${PSA_TARGET_PAL_NSPE_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/platform) |
| 690 | set_property(TARGET ${PSA_TARGET_TEST_COMBINE_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${PSA_SUITE_OUT_DIR}) |
| 691 | if(${SUITE} STREQUAL "IPC") |
| 692 | set_property(TARGET ${PSA_TARGET_DRIVER_PARTITION_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/partition) |
| 693 | set_property(TARGET ${PSA_TARGET_CLIENT_PARTITION_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/partition) |
| 694 | set_property(TARGET ${PSA_TARGET_SERVER_PARTITION_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/partition) |
| 695 | endif() |