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