blob: e1be320a26105c37243740159bb1dc7f0ae2a991 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#-------------------------------------------------------------------------------
# Copyright (c) 2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.13)
find_package(Python3)
############################### Manifest declaration ###########################
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tfm_manifest_list.yaml.in
${CMAKE_CURRENT_BINARY_DIR}/tfm_manifest_list.yaml @ONLY)
set(MANIFEST_LISTS ${CMAKE_CURRENT_BINARY_DIR}/tfm_manifest_list.yaml)
set(MANIFEST_LISTS ${MANIFEST_LISTS} ${TFM_EXTRA_MANIFEST_LIST_PATH})
if ("${TEST_PSA_API}" STREQUAL "IPC")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tfm_psa_ff_test_manifest_list.yaml.in
${CMAKE_CURRENT_BINARY_DIR}/tfm_psa_ff_test_manifest_list.yaml @ONLY)
set(MANIFEST_LISTS ${MANIFEST_LISTS} ${CMAKE_CURRENT_BINARY_DIR}/tfm_psa_ff_test_manifest_list.yaml)
endif()
############################### File list declaration ##########################
set(GENERATED_FILE_LISTS ${CMAKE_CURRENT_SOURCE_DIR}/tfm_generated_file_list.yaml)
set(GENERATED_FILE_LISTS ${GENERATED_FILE_LISTS} ${TFM_EXTRA_GENERATED_FILE_LIST_PATH})
############################### Dependency generation ##########################
function(parse_field_from_yaml files field output_variable)
set(${output_variable} "" PARENT_SCOPE)
foreach(yaml_file ${files})
# Load the lines that refer to the key we selected
file(STRINGS ${yaml_file} temp_variable REGEX " *\"${field}\":")
# Take only the value of the key
list(TRANSFORM temp_variable REPLACE " *\"${field}\": *" ";")
# Remove all commas
list(TRANSFORM temp_variable REPLACE "," "")
# Remove all quote marks
list(TRANSFORM temp_variable REPLACE "\"" "")
set(${output_variable} ${${output_variable}} ${temp_variable} PARENT_SCOPE)
endforeach()
endfunction()
parse_field_from_yaml("${GENERATED_FILE_LISTS}" template TEMPLATE_FILES)
# Replace relative paths with absolute paths
list(TRANSFORM TEMPLATE_FILES REPLACE "^([^/\\].*)" "${CMAKE_SOURCE_DIR}/\\1")
parse_field_from_yaml("${GENERATED_FILE_LISTS}" output OUTPUT_FILES)
# Replace relative paths with absolute paths
list(TRANSFORM OUTPUT_FILES REPLACE "^([^/\\].*)" "${CMAKE_BINARY_DIR}/generated/\\1")
parse_field_from_yaml("${MANIFEST_LISTS}" manifest MANIFEST_FILES)
# Replace relative paths with absolute paths
list(TRANSFORM MANIFEST_FILES REPLACE "^([^/\\].*)" "${CMAKE_SOURCE_DIR}/\\1")
############################### Command declaration ############################
# Workaround for heap support
if ("${TEST_PSA_API}" STREQUAL "IPC")
execute_process(
WORKING_DIRECTORY ${PSA_ARCH_TESTS_PATH}/api-tests
COMMAND ${Python3_EXECUTABLE} tools/scripts/manifest_update.py
)
endif()
add_custom_target(OUTPUT ${OUTPUT_FILES}
DEPENDS ${TEMPLATE_FILES} ${MANIFEST_FILES}
DEPENDS ${MANIFEST_LISTS}
)
add_custom_command(OUTPUT ${OUTPUT_FILES}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tfm_parse_manifest_list.py
-m ${MANIFEST_LISTS}
-f ${GENERATED_FILE_LISTS}
-o ${CMAKE_BINARY_DIR}/generated
DEPENDS ${TEMPLATE_FILES} ${MANIFEST_FILES}
DEPENDS ${MANIFEST_LISTS}
)
# The files need to be generated before cmake will allow them to be used as
# sources. Due to issue with custom_command scoping the easiest way to do this
# is to run the script at cmake-time if any of the files don't exist.
foreach(output_file ${OUTPUT_FILES})
if(NOT EXISTS ${output_file})
execute_process(
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tfm_parse_manifest_list.py
-m ${MANIFEST_LISTS}
-f ${GENERATED_FILE_LISTS}
-o ${CMAKE_BINARY_DIR}/generated
)
endif()
endforeach()
|