Skip to content

Commit c7e9e36

Browse files
Adjust build systems
Adjust build systems such as we can build Mbed TLS in the default and full configuration. Signed-off-by: Ronald Cron <[email protected]>
1 parent d80134b commit c7e9e36

16 files changed

+40
-27
lines changed

3rdparty/everest/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ add_library(${everest_target}
88
target_include_directories(${everest_target}
99
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
1010
$<BUILD_INTERFACE:${MBEDTLS_DIR}/include>
11+
$<BUILD_INTERFACE:${MBEDTLS_DIR}/tf-psa-crypto/include>
1112
$<INSTALL_INTERFACE:include>
1213
PRIVATE include/everest
1314
include/everest/kremlib

3rdparty/p256-m/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ target_include_directories(${p256m_target}
88
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
99
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/p256-m>
1010
$<BUILD_INTERFACE:${MBEDTLS_DIR}/include>
11+
$<BUILD_INTERFACE:${MBEDTLS_DIR}/tf-psa-crypto/include>
1112
$<INSTALL_INTERFACE:include>
1213
PRIVATE ${MBEDTLS_DIR}/library/)
1314

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ if(ENABLE_TESTING OR ENABLE_PROGRAMS)
349349
target_include_directories(mbedtls_test
350350
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests/include
351351
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
352+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/include
352353
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/library)
353354
# Request C11, needed for memory poisoning tests
354355
set_target_properties(mbedtls_test PROPERTIES C_STANDARD 11)
@@ -359,6 +360,7 @@ if(ENABLE_TESTING OR ENABLE_PROGRAMS)
359360
target_include_directories(mbedtls_test_helpers
360361
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests/include
361362
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
363+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/include
362364
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/library
363365
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/everest/include)
364366

library/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ foreach(target IN LISTS target_libraries)
329329
# of /library (which currently means: under /3rdparty).
330330
target_include_directories(${target}
331331
PUBLIC $<BUILD_INTERFACE:${MBEDTLS_DIR}/include/>
332+
$<BUILD_INTERFACE:${MBEDTLS_DIR}/tf-psa-crypto/include/>
332333
$<INSTALL_INTERFACE:include/>
333334
PRIVATE ${MBEDTLS_DIR}/library/
334335
# Needed to include psa_crypto_driver_wrappers.h

library/Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ CFLAGS ?= -O2
2828
WARNING_CFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral
2929
LDFLAGS ?=
3030

31-
# Include ../include for public headers and . for private headers.
32-
# Note that . needs to be included explicitly for the sake of library
33-
# files that are not in the /library directory (which currently means
31+
# Include ../include, ../tf-psa-crypto/include for public headers and . for
32+
# private headers. Note that . needs to be included explicitly for the sake of
33+
# library files that are not in the /library directory (which currently means
3434
# under /3rdparty).
35-
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I. -I../include -D_FILE_OFFSET_BITS=64
35+
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I. -I../include -I../tf-psa-crypto/include -D_FILE_OFFSET_BITS=64
3636
LOCAL_LDFLAGS =
3737

3838
ifdef DEBUG

programs/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ GENERATED_FILES = psa/psa_constant_names_generated.c test/query_config.c
127127
generated_files: $(GENERATED_FILES)
128128

129129
psa/psa_constant_names_generated.c: $(gen_file_dep) ../scripts/generate_psa_constants.py
130-
psa/psa_constant_names_generated.c: $(gen_file_dep) ../include/psa/crypto_values.h
131-
psa/psa_constant_names_generated.c: $(gen_file_dep) ../include/psa/crypto_extra.h
130+
psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/include/psa/crypto_values.h
131+
psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/include/psa/crypto_extra.h
132132
psa/psa_constant_names_generated.c: $(gen_file_dep) ../tests/suites/test_suite_psa_crypto_metadata.data
133133
psa/psa_constant_names_generated.c:
134134
echo " Gen $@"

programs/psa/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ if(GEN_FILES)
1919
${CMAKE_CURRENT_SOURCE_DIR}/../..
2020
DEPENDS
2121
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_psa_constants.py
22-
${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_values.h
23-
${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_extra.h
22+
${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include/psa/crypto_values.h
23+
${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include/psa/crypto_extra.h
2424
)
2525
else()
2626
link_to_source(psa_constant_names_generated.c)

programs/test/CMakeLists.txt

+8-4
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ if(TEST_CPP)
2525
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
2626
)
2727
add_executable(cpp_dummy_build "${cpp_dummy_build_cpp}")
28-
target_include_directories(cpp_dummy_build PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
28+
target_include_directories(cpp_dummy_build
29+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include
30+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include)
2931
target_link_libraries(cpp_dummy_build ${mbedcrypto_target} ${CMAKE_THREAD_LIBS_INIT})
3032
endif()
3133

3234
if(USE_SHARED_MBEDTLS_LIBRARY AND
3335
NOT ${CMAKE_SYSTEM_NAME} MATCHES "[Ww][Ii][Nn]")
3436
add_executable(dlopen "dlopen.c")
35-
target_include_directories(dlopen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
37+
target_include_directories(dlopen
38+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include
39+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include)
3640
target_link_libraries(dlopen ${CMAKE_DL_LIBS})
3741
endif()
3842

@@ -46,13 +50,13 @@ if(GEN_FILES)
4650
${PERL}
4751
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl
4852
${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h
49-
${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_config.h
53+
${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include/psa/crypto_config.h
5054
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt
5155
${CMAKE_CURRENT_BINARY_DIR}/query_config.c
5256
DEPENDS
5357
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl
5458
${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h
55-
${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_config.h
59+
${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include/psa/crypto_config.h
5660
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt
5761
)
5862
# this file will also be used in another directory, so create a target, see

scripts/common.make

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ WARNING_CFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral
2121
WARNING_CXXFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral
2222
LDFLAGS ?=
2323

24-
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I$(MBEDTLS_TEST_PATH)/include -I$(MBEDTLS_PATH)/include -D_FILE_OFFSET_BITS=64
24+
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I$(MBEDTLS_TEST_PATH)/include -I$(MBEDTLS_PATH)/include -I$(MBEDTLS_PATH)/tf-psa-crypto/include -D_FILE_OFFSET_BITS=64
2525
LOCAL_CXXFLAGS = $(WARNING_CXXFLAGS) -I$(MBEDTLS_PATH)/include -I$(MBEDTLS_PATH)/tests/include -D_FILE_OFFSET_BITS=64
2626
LOCAL_LDFLAGS = ${MBEDTLS_TEST_OBJS} \
2727
-L$(MBEDTLS_PATH)/library \

scripts/generate_psa_constants.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ def generate_psa_constants(header_file_names, output_file_name):
328328
build_tree.chdir_to_root()
329329
# Allow to change the directory where psa_constant_names_generated.c is written to.
330330
OUTPUT_FILE_DIR = sys.argv[1] if len(sys.argv) == 2 else "programs/psa"
331-
generate_psa_constants(['include/psa/crypto_values.h',
332-
'include/psa/crypto_extra.h'],
331+
332+
generate_psa_constants(['tf-psa-crypto/include/psa/crypto_values.h',
333+
'tf-psa-crypto/include/psa/crypto_extra.h'],
333334
OUTPUT_FILE_DIR + '/psa_constant_names_generated.c')

scripts/generate_query_config.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
my ($mbedtls_config_file, $psa_crypto_config_file, $query_config_format_file, $query_config_file);
2727

2828
my $default_mbedtls_config_file = "./include/mbedtls/mbedtls_config.h";
29-
my $default_psa_crypto_config_file = "./include/psa/crypto_config.h";
29+
my $default_psa_crypto_config_file = "./tf-psa-crypto/include/psa/crypto_config.h";
3030
my $default_query_config_format_file = "./scripts/data_files/query_config.fmt";
3131
my $default_query_config_file = "./programs/test/query_config.c";
3232

scripts/generate_visualc_files.pl

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
my $programs_dir = 'programs';
2525
my $mbedtls_header_dir = 'include/mbedtls';
26-
my $psa_header_dir = 'include/psa';
26+
my $psa_header_dir = 'tf-psa-crypto/include/psa';
2727
my $source_dir = 'library';
2828
my $test_source_dir = 'tests/src';
2929
my $test_header_dir = 'tests/include/test';
@@ -44,6 +44,7 @@
4444
# one directory: the compiler will use the first match.
4545
my @include_directories = qw(
4646
include
47+
tf-psa-crypto/include
4748
3rdparty/everest/include/
4849
3rdparty/everest/include/everest
4950
3rdparty/everest/include/everest/vs2013

tests/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ if(GEN_FILES)
126126
${CMAKE_CURRENT_SOURCE_DIR}/../framework/scripts/mbedtls_framework/psa_storage.py
127127
${CMAKE_CURRENT_SOURCE_DIR}/../framework/scripts/mbedtls_framework/test_case.py
128128
${CMAKE_CURRENT_SOURCE_DIR}/../framework/scripts/mbedtls_framework/test_data_generation.py
129-
${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_config.h
130-
${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_values.h
131-
${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_extra.h
129+
${CMAKE_CURRENT_SOURCE_DIR}/../tf-psa-crypto/include/psa/crypto_config.h
130+
${CMAKE_CURRENT_SOURCE_DIR}/../tf-psa-crypto/include/psa/crypto_values.h
131+
${CMAKE_CURRENT_SOURCE_DIR}/../tf-psa-crypto/include/psa/crypto_extra.h
132132
)
133133

134134
else()

tests/Makefile

+7-5
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ generated_psa_test_data: ../framework/scripts/mbedtls_framework/test_data_genera
8484
## file all the time when switching between configurations, don't declare
8585
## crypto_config.h as a dependency. Remove this file from your working tree
8686
## if you've just added or removed an option in crypto_config.h.
87-
#generated_psa_test_data: ../include/psa/crypto_config.h
88-
generated_psa_test_data: ../include/psa/crypto_values.h
89-
generated_psa_test_data: ../include/psa/crypto_extra.h
87+
#generated_psa_test_data: ../tf-psa-crypto/include/psa/crypto_config.h
88+
generated_psa_test_data: ../tf-psa-crypto/include/psa/crypto_values.h
89+
generated_psa_test_data: ../tf-psa-crypto/include/psa/crypto_extra.h
9090
generated_psa_test_data: suites/test_suite_psa_crypto_metadata.data
9191
generated_psa_test_data:
9292
echo " Gen $(GENERATED_PSA_DATA_FILES) ..."
@@ -206,6 +206,8 @@ test: check
206206
# Generate variants of some headers for testing
207207
include/alt-extra/%_alt.h: ../include/%.h
208208
perl -p -e 's/^(# *(define|ifndef) +\w+_)H\b/$${1}ALT_H/' $< >$@
209+
include/alt-extra/%_alt.h: ../tf-psa-crypto/include/%.h
210+
perl -p -e 's/^(# *(define|ifndef) +\w+_)H\b/$${1}ALT_H/' $< >$@
209211

210212
# Generate test library
211213

@@ -254,7 +256,7 @@ libtestdriver1.a:
254256
cp ./libtestdriver1/library/libmbedcrypto.a ../library/libtestdriver1.a
255257

256258
ifdef RECORD_PSA_STATUS_COVERAGE_LOG
257-
include/test/instrument_record_status.h: ../include/psa/crypto.h Makefile
259+
include/test/instrument_record_status.h: ../tf-psa-crypto/include/psa/crypto.h Makefile
258260
echo " Gen $@"
259-
sed <../include/psa/crypto.h >$@ -n 's/^psa_status_t \([A-Za-z0-9_]*\)(.*/#define \1(...) RECORD_STATUS("\1", \1(__VA_ARGS__))/p'
261+
sed <../tf-psa-crypto/include/psa/crypto.h >$@ -n 's/^psa_status_t \([A-Za-z0-9_]*\)(.*/#define \1(...) RECORD_STATUS("\1", \1(__VA_ARGS__))/p'
260262
endif

tests/psa-client-server/psasim/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LIBPSACLIENT := -Llibpsaclient/ -lmbedcrypto -lmbedx509 -lmbedtls
1010
LIBPSASERVER := -Llibpsaserver/ -lmbedcrypto
1111

1212
MBEDTLS_ROOT_PATH = ../../..
13-
COMMON_INCLUDE := -I./include -I$(MBEDTLS_ROOT_PATH)/include
13+
COMMON_INCLUDE := -I./include -I$(MBEDTLS_ROOT_PATH)/include -I$(MBEDTLS_ROOT_PATH)/tf-psa-crypto/include
1414

1515
TEST_BIN = test/psa_client \
1616
test/psa_partition

0 commit comments

Comments
 (0)