Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 1 | #/** @file |
| 2 | # * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. |
| 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 | |
| 31 | list(APPEND CMAKE_MODULE_PATH ${PSA_ROOT_DIR}/tools/cmake) |
| 32 | include("common/Utils") |
| 33 | include(${PSA_ROOT_DIR}/tools/cmake/common/CMakeSettings.cmake) |
| 34 | |
| 35 | # list of supported suites |
| 36 | list(APPEND PSA_SUITES |
| 37 | "IPC" |
| 38 | "CRYPTO" |
| 39 | "PROTECTED_STORAGE" |
| 40 | "INTERNAL_TRUSTED_STORAGE" |
| 41 | "INITIAL_ATTESTATION" |
| 42 | ) |
| 43 | |
| 44 | # list of ipc files required |
| 45 | list(APPEND PSA_IPC_FILES |
| 46 | "psa/client.h" |
| 47 | "psa/service.h" |
Jaykumar Pitambarbhai Patel | 1c2b028 | 2019-11-06 11:29:13 +0530 | [diff] [blame] | 48 | "psa/lifecycle.h" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 49 | "psa_manifest/sid.h" |
| 50 | "psa_manifest/pid.h" |
Jaykumar Pitambarbhai Patel | 1c2b028 | 2019-11-06 11:29:13 +0530 | [diff] [blame] | 51 | "psa_manifest/driver_partition_psa.h" |
| 52 | "psa_manifest/client_partition_psa.h" |
| 53 | "psa_manifest/server_partition_psa.h" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 54 | ) |
| 55 | |
| 56 | # list of crypto files required |
| 57 | list(APPEND PSA_CRYPTO_FILES |
| 58 | "psa/crypto.h" |
| 59 | ) |
| 60 | |
| 61 | # list of protected_storage files required |
| 62 | list(APPEND PSA_PROTECTED_STORAGE_FILES |
| 63 | "psa/protected_storage.h" |
| 64 | ) |
| 65 | |
| 66 | # list of internal_trusted_storage files required |
| 67 | list(APPEND PSA_INTERNAL_TRUSTED_STORAGE_FILES |
| 68 | "psa/internal_trusted_storage.h" |
| 69 | ) |
| 70 | |
| 71 | # list of initial_attestation files required |
| 72 | list(APPEND PSA_INITIAL_ATTESTATION_FILES |
| 73 | "psa/initial_attestation.h" |
| 74 | "psa/crypto.h" |
| 75 | ) |
| 76 | |
| 77 | # list of supported toolchains |
| 78 | list(APPEND PSA_TOOLCHAIN_SUPPORT |
| 79 | GNUARM |
| 80 | ARMCLANG |
| 81 | HOST_GCC |
| 82 | ) |
| 83 | |
| 84 | # list of suported CPU arch |
| 85 | list(APPEND PSA_CPU_ARCH_SUPPORT |
| 86 | armv8m_ml |
| 87 | armv8m_bl |
| 88 | armv7m |
| 89 | ) |
| 90 | |
| 91 | # list of VERBOSE options |
| 92 | list(APPEND PSA_VERBOSE_OPTIONS 1 2 3 4 5) |
| 93 | |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame^] | 94 | # list of PLATFORM_PSA_ISOLATION_LEVEL options |
| 95 | list(APPEND PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS 1 2 3) |
| 96 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 97 | message(STATUS "[PSA] : ----------Process input arguments- start-------------") |
| 98 | |
| 99 | # Check for TARGET command line argument |
| 100 | _check_arguments("TARGET") |
| 101 | # Check for SUTIE command line argument |
| 102 | _check_arguments("SUITE") |
| 103 | # Check for PSA_INCLUDE_PATHS command line argument |
| 104 | _check_arguments("PSA_INCLUDE_PATHS") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 105 | |
| 106 | string(TOLOWER ${SUITE} SUITE_LOWER) |
| 107 | |
| 108 | # Check for valid targets |
| 109 | _get_sub_dir_list(PSA_TARGET_LIST ${PSA_ROOT_DIR}/platform/targets) |
| 110 | if(NOT ${TARGET} IN_LIST PSA_TARGET_LIST) |
| 111 | message(FATAL_ERROR "[PSA] : Error: Unspported value for -DTARGET=, supported targets are : ${PSA_TARGET_LIST}") |
| 112 | endif() |
| 113 | |
| 114 | # Check for the presence of required test suite directories |
| 115 | if((NOT IS_DIRECTORY ${PSA_ROOT_DIR}/dev_apis) OR (NOT IS_DIRECTORY ${PSA_ROOT_DIR}/ff)) |
| 116 | message(STATUS "[PSA] : Error: Could not find architecture test suite directories in psa root path ${PSA_ROOT_DIR}") |
| 117 | endif() |
| 118 | |
| 119 | if(FALSE) |
| 120 | # Check for build directory specified |
| 121 | if(NOT DEFINED BUILD) |
| 122 | set(BUILD ${CMAKE_CURRENT_BINARY_DIR}/BUILD CACHE INTERNAL "Defaulting build directory to ${BUILD}" FORCE) |
| 123 | else() |
| 124 | set(BUILD ${CMAKE_CURRENT_BINARY_DIR}/${BUILD}/BUILD CACHE INTERNAL "Defaulting build directory to ${BUILD}" FORCE) |
| 125 | endif() |
| 126 | endif() |
| 127 | |
| 128 | # Check for valid suite cmake argument passed |
| 129 | if(NOT ${SUITE} IN_LIST PSA_SUITES) |
| 130 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DSUITE=, select one from supported suites which are : ${PSA_SUITES}") |
| 131 | endif() |
| 132 | |
| 133 | # Project variables |
| 134 | set(PSA_TARGET_PRE_BUILD psa_pre_build) |
| 135 | set(PSA_TARGET_GENERATE_DATABASE_PRE psa_generate_database_prerequisite) |
| 136 | set(PSA_TARGET_GENERATE_DATABASE psa_generate_database) |
| 137 | set(PSA_TARGET_GENERATE_DATABASE_POST psa_generate_database_cleanup) |
| 138 | set(PSA_TARGET_QCBOR psa_qcbor) |
| 139 | set(PSA_TARGET_PAL_NSPE_LIB pal_nspe) |
| 140 | set(PSA_TARGET_VAL_NSPE_LIB val_nspe) |
| 141 | set(PSA_TARGET_TEST_COMBINE_LIB test_combine) |
| 142 | set(PSA_TARGET_DRIVER_PARTITION_LIB driver_partition) |
| 143 | set(PSA_TARGET_CLIENT_PARTITION_LIB client_partition) |
| 144 | set(PSA_TARGET_SERVER_PARTITION_LIB server_partition) |
| 145 | if(${SUITE} STREQUAL "IPC") |
| 146 | set(PSA_SUITE_DIR ${PSA_ROOT_DIR}/ff/${SUITE_LOWER}) |
| 147 | set(PSA_SUITE_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/ff/${SUITE_LOWER}) |
| 148 | else() |
| 149 | set(PSA_SUITE_DIR ${PSA_ROOT_DIR}/dev_apis/${SUITE_LOWER}) |
| 150 | set(PSA_SUITE_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/dev_apis/${SUITE_LOWER}) |
| 151 | endif() |
| 152 | set(PSA_TARGET_CONFIG_HEADER_GENERATOR ${PSA_ROOT_DIR}/tools/scripts/target_cfg/targetConfigGen.py) |
| 153 | set(PSA_TESTLIST_GENERATOR ${PSA_ROOT_DIR}/tools/scripts/gen_tests_list.py) |
| 154 | set(TARGET_CONFIGURATION_FILE ${PSA_ROOT_DIR}/platform/targets/${TARGET}/target.cfg) |
| 155 | set(TGT_CONFIG_SOURCE_C ${CMAKE_CURRENT_BINARY_DIR}/targetConfigGen.c) |
| 156 | set(OUTPUT_HEADER target_database.h) |
| 157 | set(DATABASE_TABLE_NAME target_database) |
| 158 | set(DATABASE_TABLE_SECTION_NAME "NOSECTION") |
| 159 | set(TARGET_HEADER_GEN_INCLUDE_PATHS "${PSA_ROOT_DIR}/val/nspe|${PSA_ROOT_DIR}/val/common|${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/common|${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/crypto") |
| 160 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/testsuite.db) |
| 161 | if(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
| 162 | set(PSA_QCBOR_GIT_REPO_LINK https://github.com/laurencelundblade/QCBOR.git) |
| 163 | set(PSA_QCBOR_GIT_REPO_TAG da53227db1488dde0952bdff66c3d904dce270b3) |
| 164 | set(PSA_QCBOR_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR}/src/psa_qcbor/inc) |
| 165 | endif() |
| 166 | set(PSA_TESTLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/testlist.txt) |
| 167 | set(PSA_TEST_ENTRY_LIST_INC ${CMAKE_CURRENT_BINARY_DIR}/test_entry_list.inc) |
| 168 | set(PSA_TEST_ENTRY_FUN_DECLARE_INC ${CMAKE_CURRENT_BINARY_DIR}/test_entry_fn_declare_list.inc) |
| 169 | set(PSA_CLIENT_TEST_LIST_DELCARE_INC ${CMAKE_CURRENT_BINARY_DIR}/client_tests_list_declare.inc) |
| 170 | set(PSA_CLIENT_TEST_LIST_INC ${CMAKE_CURRENT_BINARY_DIR}/client_tests_list.inc) |
| 171 | set(PSA_SERVER_TEST_LIST_DECLARE_INC ${CMAKE_CURRENT_BINARY_DIR}/server_tests_list_declare.inc) |
| 172 | set(PSA_SERVER_TEST_LIST ${CMAKE_CURRENT_BINARY_DIR}/server_tests_list.inc) |
| 173 | |
| 174 | # Validity check for required files for a given suite |
| 175 | if(NOT DEFINED PSA_${SUITE}_FILES) |
| 176 | message(FATAL_ERROR "[PSA] : List of file/s to verify against ${suite} is not defined") |
| 177 | endif() |
| 178 | foreach(file_item ${PSA_${SUITE}_FILES}) |
| 179 | set(PSA_FILE_FOUND FALSE) |
| 180 | foreach(include_path ${PSA_INCLUDE_PATHS}) |
| 181 | if((EXISTS ${include_path}/${file_item}) AND |
| 182 | (NOT PSA_FILE_FOUND)) |
| 183 | set(PSA_FILE_FOUND TRUE) |
| 184 | break() |
| 185 | endif() |
| 186 | endforeach() |
| 187 | if(NOT PSA_FILE_FOUND) |
| 188 | message(FATAL_ERROR "[PSA] : Couldn't find ${file_item} in ${PSA_INCLUDE_PATHS}") |
| 189 | endif() |
| 190 | endforeach() |
| 191 | |
| 192 | # Check for TOOLCHAIN command line argument |
| 193 | if(NOT DEFINED TOOLCHAIN) |
| 194 | set(TOOLCHAIN "GNUARM" CACHE INTERNAL "Compiler used" FORCE) |
| 195 | message(STATUS "[PSA] : Defaulting compiler to ${TOOLCHAIN}") |
| 196 | endif() |
| 197 | |
Gowtham Siddarth | 1d6d469 | 2019-09-16 11:47:29 +0530 | [diff] [blame] | 198 | if(${TOOLCHAIN} STREQUAL "ARMCLANG" OR ${TOOLCHAIN} STREQUAL "GNUARM") |
| 199 | if(NOT DEFINED CPU_ARCH) |
| 200 | message(FATAL_ERROR "[PSA] : Error: -DCPU_ARCH option missing") |
| 201 | else() |
| 202 | # Check for CPU architecture |
| 203 | if(NOT ${CPU_ARCH} IN_LIST PSA_CPU_ARCH_SUPPORT) |
| 204 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DCPU_ARCH=, supported CPU arch are : ${PSA_CPU_ARCH_SUPPORT}") |
| 205 | endif() |
| 206 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 207 | endif() |
| 208 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 209 | # Check for VERBOSE |
| 210 | if(NOT DEFINED VERBOSE) |
| 211 | set(VERBOSE 3 CACHE INTERNAL "Default VERBOSE value" FORCE) |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame^] | 212 | message(STATUS "[PSA] : Defaulting to VERBOSE=${VERBOSE}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 213 | else() |
| 214 | if(NOT ${VERBOSE} IN_LIST PSA_VERBOSE_OPTIONS) |
| 215 | message(FATAL_ERROR "[PSA] : Error: Unspported value for -DVERBOSE=, supported values are : ${PSA_VERBOSE_OPTIONS}") |
| 216 | endif() |
| 217 | endif() |
| 218 | |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame^] | 219 | # Check for PLATFORM_PSA_ISOLATION_LEVEL |
| 220 | if(NOT DEFINED PLATFORM_PSA_ISOLATION_LEVEL) |
| 221 | set(PLATFORM_PSA_ISOLATION_LEVEL 3 CACHE INTERNAL "Default PLATFORM_PSA_ISOLATION_LEVEL value" FORCE) |
| 222 | message(STATUS "[PSA] : Defaulting to PLATFORM_PSA_ISOLATION_LEVEL=${PLATFORM_PSA_ISOLATION_LEVEL}") |
| 223 | else() |
| 224 | if(NOT ${PLATFORM_PSA_ISOLATION_LEVEL} IN_LIST PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS) |
| 225 | message(FATAL_ERROR "[PSA] : Error: Unspported value for -DPLATFORM_PSA_ISOLATION_LEVEL=, supported values are : ${PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS}") |
| 226 | endif() |
| 227 | endif() |
| 228 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 229 | if(NOT DEFINED INCLUDE_PANIC_TESTS) |
| 230 | set(INCLUDE_PANIC_TESTS 0 CACHE INTERNAL "By default panic tests are disabled" FORCE) |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame^] | 231 | message(STATUS "[PSA] : Defaulting to INCLUDE_PANIC_TESTS=${INCLUDE_PANIC_TESTS}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 232 | else() |
| 233 | if(INCLUDE_PANIC_TESTS EQUAL 1) |
| 234 | message(STATUS "[PSA] : Ensure you set watchdog.num to 1 in ${PSA_ROOT_DIR}/platform/targets/${TARGET}/target.cfg") |
| 235 | message(STATUS "[PSA] : To test PSA APIs panic conditions, test harness may require to access watchdog timer " |
| 236 | "to recover from panic and to be able to continue with next test. " |
| 237 | "Ignore this warning if system under test has capability to reset the system " |
| 238 | "when it encounters panic condition.") |
| 239 | endif() |
| 240 | endif() |
| 241 | |
| 242 | if(NOT DEFINED WATCHDOG_AVAILABLE) |
Jaykumar Pitambarbhai Patel | 1c2b028 | 2019-11-06 11:29:13 +0530 | [diff] [blame] | 243 | set(WATCHDOG_AVAILABLE 1 CACHE INTERNAL "Assuming watchdog is available to program by test suite" FORCE) |
| 244 | message(STATUS "[PSA] : Watchdog is available by default") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 245 | endif() |
| 246 | |
| 247 | if((INCLUDE_PANIC_TESTS EQUAL 1) AND |
| 248 | (WATCHDOG_AVAILABLE EQUAL 0)) |
Jaykumar Pitambarbhai Patel | 1c2b028 | 2019-11-06 11:29:13 +0530 | [diff] [blame] | 249 | message(FATAL_ERROR "[PSA]: Panic test execution needs watchdog access. set -DWATCHDOG_AVAILABLE=1") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 250 | endif() |
| 251 | |
| 252 | if(NOT DEFINED SP_HEAP_MEM_SUPP) |
| 253 | set(SP_HEAP_MEM_SUPP 1 CACHE INTERNAL "Are dynamic memory functions available to secure partition?" FORCE) |
| 254 | message(STATUS "[PSA] : Default value for SP_HEAP_MEM_SUPP is ${SP_HEAP_MEM_SUPP}") |
| 255 | endif() |
| 256 | |
| 257 | if(NOT DEFINED TEST_COMBINE_ARCHIVE) |
| 258 | set(TEST_COMBINE_ARCHIVE 1 CACHE INTERNAL "Default option is to create archive" FORCE) |
| 259 | message(STATUS "[PSA] : Default value for TEST_COMBINE_ARCHIVE is ${TEST_COMBINE_ARCHIVE}") |
| 260 | endif() |
| 261 | |
| 262 | message(STATUS "[PSA] : ----------Process input arguments- complete-------------") |
| 263 | |
| 264 | # Create PSA clean list |
| 265 | list(APPEND PSA_CLEAN_LIST |
| 266 | ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_HEADER} |
| 267 | ${PSA_TESTLIST_FILE} |
| 268 | ${PSA_TEST_ENTRY_LIST_INC} |
| 269 | ${PSA_TEST_ENTRY_FUN_DECLARE_INC} |
| 270 | ${PSA_CLIENT_TEST_LIST_DELCARE_INC} |
| 271 | ${PSA_CLIENT_TEST_LIST_INC} |
| 272 | ${PSA_SERVER_TEST_LIST_DECLARE_INC} |
| 273 | ${PSA_SERVER_TEST_LIST} |
| 274 | ) |
| 275 | |
| 276 | # Process testsuite.db |
| 277 | message(STATUS "[PSA] : Creating testlist.txt 'available at ${PSA_TESTLIST_FILE}'") |
| 278 | execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PSA_TESTLIST_GENERATOR} |
| 279 | ${SUITE_LOWER} |
| 280 | ${TESTSUITE_DB} |
| 281 | ${INCLUDE_PANIC_TESTS} |
| 282 | ${PSA_TESTLIST_FILE} |
| 283 | ${PSA_TEST_ENTRY_LIST_INC} |
| 284 | ${PSA_TEST_ENTRY_FUN_DECLARE_INC} |
| 285 | ${PSA_CLIENT_TEST_LIST_DELCARE_INC} |
| 286 | ${PSA_CLIENT_TEST_LIST_INC} |
| 287 | ${PSA_SERVER_TEST_LIST_DECLARE_INC} |
| 288 | ${PSA_SERVER_TEST_LIST}) |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame^] | 289 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 290 | # Creating CMake list variable from file |
| 291 | file(READ ${PSA_TESTLIST_FILE} PSA_TEST_LIST) |
| 292 | string(REGEX REPLACE "\n" ";" PSA_TEST_LIST "${PSA_TEST_LIST}") |
| 293 | |
| 294 | add_custom_target( |
| 295 | ${PSA_TARGET_GENERATE_DATABASE_PRE} |
| 296 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/platform |
| 297 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/val |
| 298 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/partition |
| 299 | COMMAND ${CMAKE_COMMAND} -E make_directory ${PSA_SUITE_OUT_DIR} |
| 300 | ) |
| 301 | |
| 302 | # Generate target files from User provided data base |
| 303 | include(ExternalProject) |
| 304 | ExternalProject_Add( |
| 305 | ${PSA_TARGET_GENERATE_DATABASE} |
| 306 | PREFIX ${CMAKE_CURRENT_BINARY_DIR} |
| 307 | DOWNLOAD_COMMAND "" |
| 308 | UPDATE_COMMAND "" |
| 309 | PATCH_COMMAND "" |
| 310 | BUILD_COMMAND "" |
| 311 | SOURCE_DIR "${PSA_ROOT_DIR}/tools/scripts/target_cfg" |
| 312 | CMAKE_ARGS -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} |
| 313 | -DOUT_DIR=${CMAKE_CURRENT_BINARY_DIR} |
| 314 | -DTARGET=${TARGET} |
| 315 | -DGENERATOR_FILE=${PSA_TARGET_CONFIG_HEADER_GENERATOR} |
| 316 | -DINCLUDE_DIR=${PSA_ROOT_DIR}/val/common |
| 317 | -DTARGET_CONFIGURATION_FILE=${TARGET_CONFIGURATION_FILE} |
| 318 | -DTGT_CONFIG_SOURCE_C=${TGT_CONFIG_SOURCE_C} |
| 319 | -DOUTPUT_HEADER=${OUTPUT_HEADER} |
| 320 | -DDATABASE_TABLE_NAME=${DATABASE_TABLE_NAME} |
| 321 | -DDATABASE_TABLE_SECTION_NAME=${DATABASE_TABLE_SECTION_NAME} |
| 322 | -DTARGET_HEADER_GEN_INCLUDE_PATHS=${TARGET_HEADER_GEN_INCLUDE_PATHS} |
| 323 | LIST_SEPARATOR | |
| 324 | TEST_COMMAND "" |
| 325 | ) |
| 326 | |
| 327 | # Add custom target to clean generated files of the external project |
| 328 | add_custom_target( |
| 329 | ${PSA_TARGET_GENERATE_DATABASE_POST} |
| 330 | COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/src/${PSA_TARGET_GENERATE_DATABASE}-build/ -- clean |
| 331 | ) |
| 332 | |
| 333 | if(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
| 334 | # Cloning CMSIS_5 repo |
| 335 | ExternalProject_Add( |
| 336 | ${PSA_TARGET_QCBOR} |
| 337 | PREFIX ${CMAKE_CURRENT_BINARY_DIR} |
| 338 | GIT_REPOSITORY ${PSA_QCBOR_GIT_REPO_LINK} |
| 339 | GIT_TAG ${PSA_QCBOR_GIT_REPO_TAG} |
| 340 | CONFIGURE_COMMAND "" |
| 341 | UPDATE_COMMAND "" |
| 342 | PATCH_COMMAND "" |
| 343 | BUILD_COMMAND "" |
| 344 | TEST_COMMAND "" |
| 345 | INSTALL_COMMAND "" |
| 346 | ) |
| 347 | endif() |
| 348 | |
| 349 | # Check for supported toolchain/s |
| 350 | if(${TOOLCHAIN} IN_LIST PSA_TOOLCHAIN_SUPPORT) |
| 351 | include(${PSA_ROOT_DIR}/tools/cmake/compiler/${TOOLCHAIN}.cmake) |
| 352 | else() |
| 353 | message(FATAL_ERROR "[PSA] : Error: Unspported value for -DTOOLCHAIN=, supported toolchain are : ${PSA_TOOLCHAIN_SUPPORT}") |
| 354 | endif() |
| 355 | |
| 356 | # Global macro to identify the PSA test suite cmake build |
| 357 | add_definitions(-DPSA_CMAKE_BUILD) |
| 358 | add_definitions(-D${SUITE}) |
| 359 | add_definitions(-DVERBOSE=${VERBOSE}) |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame^] | 360 | add_definitions(-DPLATFORM_PSA_ISOLATION_LEVEL=${PLATFORM_PSA_ISOLATION_LEVEL}) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 361 | |
| 362 | if(${SP_HEAP_MEM_SUPP} EQUAL 1) |
| 363 | add_definitions(-DSP_HEAP_MEM_SUPP) |
| 364 | endif() |
| 365 | |
| 366 | # Build PAL NSPE LIB |
| 367 | include(${PSA_ROOT_DIR}/platform/targets/${TARGET}/target.cmake) |
| 368 | # Build VAL NSPE LIB |
| 369 | #add_definitions(-DVAL_NSPE_BUILD) |
| 370 | include(${PSA_ROOT_DIR}/val/val_nspe.cmake) |
| 371 | # Build test |
| 372 | include(${PSA_SUITE_DIR}/suite.cmake) |
| 373 | if(${SUITE} STREQUAL "IPC") |
| 374 | # Build SPE LIB |
| 375 | include(${PSA_ROOT_DIR}/val/val_spe.cmake) |
| 376 | endif() |
| 377 | |
| 378 | add_dependencies(${PSA_TARGET_GENERATE_DATABASE} ${PSA_TARGET_GENERATE_DATABASE_PRE}) |
| 379 | add_dependencies(${PSA_TARGET_GENERATE_DATABASE_POST} ${PSA_TARGET_GENERATE_DATABASE}) |
| 380 | if(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
| 381 | add_dependencies(${PSA_TARGET_QCBOR} ${PSA_TARGET_GENERATE_DATABASE_POST}) |
| 382 | add_dependencies(${PSA_TARGET_PAL_NSPE_LIB} ${PSA_TARGET_QCBOR}) |
| 383 | else() |
| 384 | add_dependencies(${PSA_TARGET_PAL_NSPE_LIB} ${PSA_TARGET_GENERATE_DATABASE_POST}) |
| 385 | endif() |
| 386 | add_dependencies(${PSA_TARGET_VAL_NSPE_LIB} ${PSA_TARGET_PAL_NSPE_LIB}) |
| 387 | add_dependencies(${PSA_TARGET_TEST_COMBINE_LIB} ${PSA_TARGET_VAL_NSPE_LIB}) |
| 388 | if(${SUITE} STREQUAL "IPC") |
| 389 | add_dependencies(${PSA_TARGET_DRIVER_PARTITION_LIB} ${PSA_TARGET_TEST_COMBINE_LIB}) |
| 390 | add_dependencies(${PSA_TARGET_CLIENT_PARTITION_LIB} ${PSA_TARGET_DRIVER_PARTITION_LIB}) |
| 391 | add_dependencies(${PSA_TARGET_SERVER_PARTITION_LIB} ${PSA_TARGET_CLIENT_PARTITION_LIB}) |
| 392 | endif() |
| 393 | |
| 394 | # Include the files for make clean |
| 395 | foreach(clean_item ${PSA_CLEAN_LIST}) |
| 396 | set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clean_item}) |
| 397 | endforeach() |
| 398 | |
| 399 | set_property(TARGET ${PSA_TARGET_VAL_NSPE_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/val) |
| 400 | set_property(TARGET ${PSA_TARGET_PAL_NSPE_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/platform) |
| 401 | set_property(TARGET ${PSA_TARGET_TEST_COMBINE_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${PSA_SUITE_OUT_DIR}) |
| 402 | if(${SUITE} STREQUAL "IPC") |
| 403 | set_property(TARGET ${PSA_TARGET_DRIVER_PARTITION_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/partition) |
| 404 | set_property(TARGET ${PSA_TARGET_CLIENT_PARTITION_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/partition) |
| 405 | set_property(TARGET ${PSA_TARGET_SERVER_PARTITION_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/partition) |
| 406 | endif() |