diff --git a/programs/Makefile b/programs/Makefile index b48a006bb4..d2cee1cdfa 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -133,13 +133,13 @@ ${MBEDTLS_TEST_OBJS}: GENERATED_FILES = psa/psa_constant_names_generated.c test/query_config.c generated_files: $(GENERATED_FILES) -psa/psa_constant_names_generated.c: $(gen_file_dep) ../scripts/generate_psa_constants.py +psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/scripts/generate_psa_constants.py psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/include/psa/crypto_values.h psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/include/psa/crypto_extra.h psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/tests/suites/test_suite_psa_crypto_metadata.data psa/psa_constant_names_generated.c: echo " Gen $@" - $(PYTHON) ../scripts/generate_psa_constants.py + cd ../tf-psa-crypto; $(PYTHON) ../scripts/generate_psa_constants.py test/query_config.c: $(gen_file_dep) ../scripts/generate_query_config.pl ## The generated file only depends on the options that are present in mbedtls_config.h, diff --git a/tf-psa-crypto/programs/psa/CMakeLists.txt b/tf-psa-crypto/programs/psa/CMakeLists.txt index 3e5daca973..625b6e1291 100644 --- a/tf-psa-crypto/programs/psa/CMakeLists.txt +++ b/tf-psa-crypto/programs/psa/CMakeLists.txt @@ -19,9 +19,9 @@ if(GEN_FILES) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/../../../scripts/generate_psa_constants.py - ${CMAKE_CURRENT_SOURCE_DIR}/../../../tf-psa-crypto/include/psa/crypto_values.h - ${CMAKE_CURRENT_SOURCE_DIR}/../../../tf-psa-crypto/include/psa/crypto_extra.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_psa_constants.py + ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_values.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_extra.h ) else() link_to_source(psa_constant_names_generated.c) diff --git a/tf-psa-crypto/scripts/framework_scripts_path.py b/tf-psa-crypto/scripts/framework_scripts_path.py new file mode 100644 index 0000000000..4d4a440c23 --- /dev/null +++ b/tf-psa-crypto/scripts/framework_scripts_path.py @@ -0,0 +1,17 @@ +"""Add our Python library directory to the module search path. + +Usage: + + import framework_scripts_path # pylint: disable=unused-import +""" + +# Copyright The Mbed TLS Contributors +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# + +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), + os.path.pardir, + 'framework', 'scripts')) diff --git a/scripts/generate_psa_constants.py b/tf-psa-crypto/scripts/generate_psa_constants.py similarity index 96% rename from scripts/generate_psa_constants.py rename to tf-psa-crypto/scripts/generate_psa_constants.py index a63636307a..a22e406e6f 100755 --- a/scripts/generate_psa_constants.py +++ b/tf-psa-crypto/scripts/generate_psa_constants.py @@ -1,13 +1,13 @@ #!/usr/bin/env python3 """Generate psa_constant_names_generated.c -which is included by tf-psa-crypto/programs/psa/psa_constant_names.c. +which is included by programs/psa/psa_constant_names.c. The code generated by this module is only meant to be used in the context of that program. An argument passed to this script will modify the output directory where the file is written: -* by default (no arguments passed): writes to tf-psa-crypto/programs/psa/ +* by default (no arguments passed): writes to programs/psa/ * OUTPUT_FILE_DIR passed: writes to OUTPUT_FILE_DIR/ """ @@ -327,8 +327,8 @@ def generate_psa_constants(header_file_names, output_file_name): if __name__ == '__main__': build_tree.chdir_to_root() # Allow to change the directory where psa_constant_names_generated.c is written to. - OUTPUT_FILE_DIR = sys.argv[1] if len(sys.argv) == 2 else "tf-psa-crypto/programs/psa" + OUTPUT_FILE_DIR = sys.argv[1] if len(sys.argv) == 2 else "programs/psa" - generate_psa_constants(['tf-psa-crypto/include/psa/crypto_values.h', - 'tf-psa-crypto/include/psa/crypto_extra.h'], + generate_psa_constants(['include/psa/crypto_values.h', + 'include/psa/crypto_extra.h'], OUTPUT_FILE_DIR + '/psa_constant_names_generated.c')