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