From 4a9e02632afabe99049def11815b5ed523f5c37f Mon Sep 17 00:00:00 2001 From: Archana Date: Sun, 19 Dec 2021 13:34:30 +0530 Subject: [PATCH] Review comments addressed * Updated the default argument to create less noise with argument passing. * Reworded ChangeLog to match MbedTLS documentation/ announcement requirements Signed-off-by: Archana --- ChangeLog.d/Driver_wrapper_codegen_1.0.txt | 11 +++++------ library/CMakeLists.txt | 1 - library/Makefile | 2 +- scripts/generate_driver_wrappers.py | 11 +++++++---- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ChangeLog.d/Driver_wrapper_codegen_1.0.txt b/ChangeLog.d/Driver_wrapper_codegen_1.0.txt index 8e97b01bb..a4d9c5417 100644 --- a/ChangeLog.d/Driver_wrapper_codegen_1.0.txt +++ b/ChangeLog.d/Driver_wrapper_codegen_1.0.txt @@ -1,6 +1,5 @@ -Features - * Add support for driver wrapper codegen 1.0. This autogenerates - the file library/psa_crypto_driver_wrappers.c. Rev 1.0 does not - support any additional templating. For further info on how to - patch into the psa_crypto_driver_wrappers.c refer - docs/proposed/psa-driver-wrappers-codegen-migration-guide.md +Changes + * The file library/psa_crypto_driver_wrappers.c is now generated + from a template. In the future, the generation will support + driver descriptions. For the time being, to customize this file, + see docs/proposed/psa-driver-wrappers-codegen-migration-guide.md diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 3e8190acd..ddede0390 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -164,7 +164,6 @@ if(GEN_FILES) COMMAND ${MBEDTLS_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_driver_wrappers.py - --mbedtls-root ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_driver_wrappers.py diff --git a/library/Makefile b/library/Makefile index 34ed8ffcb..e9c0a1174 100644 --- a/library/Makefile +++ b/library/Makefile @@ -323,7 +323,7 @@ psa_crypto_driver_wrappers.c: ../scripts/generate_driver_wrappers.py psa_crypto_driver_wrappers.c: ../scripts/data_files/driver_templates/psa_crypto_driver_wrappers.c.jinja psa_crypto_driver_wrappers.c: echo " Gen $@" - $(PYTHON) ../scripts/generate_driver_wrappers.py --mbedtls-root .. . + $(PYTHON) ../scripts/generate_driver_wrappers.py clean: ifndef WINDOWS diff --git a/scripts/generate_driver_wrappers.py b/scripts/generate_driver_wrappers.py index c6e280092..42331acc8 100755 --- a/scripts/generate_driver_wrappers.py +++ b/scripts/generate_driver_wrappers.py @@ -49,19 +49,22 @@ def generate_driver_wrapper_file(mbedtls_root: str, output_dir: str) -> None: with open(os.path.join(output_dir, "psa_crypto_driver_wrappers.c"), 'w') as out_file: out_file.write(result) - out_file.close() def main() -> int: """ Main with command line arguments. """ + def_arg_mbedtls_root = build_tree.guess_mbedtls_root() + def_arg_output_dir = os.path.join(def_arg_mbedtls_root, 'library') + parser = argparse.ArgumentParser() - parser.add_argument('--mbedtls-root', nargs='?', default=None, + parser.add_argument('--mbedtls-root', nargs='?', default=def_arg_mbedtls_root, help='root directory of mbedtls source code') parser.add_argument('output_directory', nargs='?', - default='library', help='output file\'s location') + default=def_arg_output_dir, help='output file\'s location') args = parser.parse_args() - mbedtls_root = os.path.abspath(args.mbedtls_root or build_tree.guess_mbedtls_root()) + + mbedtls_root = os.path.abspath(args.mbedtls_root) output_directory = args.output_directory generate_driver_wrapper_file(mbedtls_root, output_directory)