Rev 1.0 of Driver Wrappers code gen
The psa_crypto_driver_wrappers.c is merely rendered with no real templating in version 1.0. Signed-off-by: Archana <archana.madhavan@silabs.com>
This commit is contained in:
parent
68eb2ac960
commit
1f1a34a226
5 changed files with 2414 additions and 7 deletions
32
docs/proposed/psa-driver-wrappers-codegen-migration-guide.md
Normal file
32
docs/proposed/psa-driver-wrappers-codegen-migration-guide.md
Normal file
|
@ -0,0 +1,32 @@
|
|||
Migrating to an auto genrated psa_crypto_driver_wrappers.c file
|
||||
===============================================================
|
||||
|
||||
**This is a specification of work in progress. The implementation is not yet merged into Mbed TLS.**
|
||||
|
||||
This document describes how to migrate to the auto generated psa_crypto_driver_wrappers.c file.
|
||||
It is meant to give the library user migration guidelines while the Mbed TLS project tides over multiple minor revs of version 1.0, after which this will be merged into psa-driver-interface.md.
|
||||
|
||||
## Introduction
|
||||
|
||||
The design of the Driver Wrappers code generation is based on the design proposal https://github.com/ARMmbed/mbedtls/pull/5067
|
||||
During the process of implementation there might be minor variations wrt versioning and broader implementation specific ideas, but the design remains the same.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Python3 and Jinja2 rev 2.10.1
|
||||
|
||||
## Feature Version
|
||||
|
||||
1.0
|
||||
|
||||
### What's critical for a migrating user
|
||||
|
||||
The Driver Wrapper auto generation project is designed to use a python templating library ( Jinja2 ) to render templates based on drivers that are defined using a Driver descrioption JSON file(s).
|
||||
|
||||
While that is the larger goal, for version 1.0 here's what's changed
|
||||
|
||||
#### What's changed
|
||||
|
||||
(1) psa_crypto_driver_wrappers.c will from this point on be auto generated.
|
||||
(2) The auto generation is based on the template file at scripts/codegen_driverwrappers/psa_crypto_driver_wrappers.conf.
|
||||
(3) So while all driver wrapper templating support is yet to come in, the library user will need to patch into the template file as needed.
|
|
@ -290,7 +290,8 @@ libmbedcrypto.dll: $(OBJS_CRYPTO)
|
|||
.PHONY: generated_files
|
||||
GENERATED_FILES = \
|
||||
error.c version_features.c \
|
||||
ssl_debug_helpers_generated.c
|
||||
ssl_debug_helpers_generated.c \
|
||||
psa_crypto_driver_wrappers.c
|
||||
generated_files: $(GENERATED_FILES)
|
||||
|
||||
error.c: ../scripts/generate_errors.pl
|
||||
|
@ -318,6 +319,13 @@ version_features.c:
|
|||
echo " Gen $@"
|
||||
$(PERL) ../scripts/generate_features.pl
|
||||
|
||||
psa_crypto_driver_wrappers.c: ../scripts/codegen_driverwrappers/generate_driver_wrappers.py
|
||||
psa_crypto_driver_wrappers.c:
|
||||
echo " Gen $@"
|
||||
$(PYTHON) ../scripts/codegen_driverwrappers/generate_driver_wrappers.py \
|
||||
"../scripts/codegen_driverwrappers/psa_crypto_driver_wrappers.conf" \
|
||||
"psa_crypto_driver_wrappers.c"
|
||||
|
||||
clean:
|
||||
ifndef WINDOWS
|
||||
rm -f *.o libmbed*
|
||||
|
|
27
scripts/codegen_driverwrappers/generate_driver_wrappers.py
Executable file
27
scripts/codegen_driverwrappers/generate_driver_wrappers.py
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import json
|
||||
import os
|
||||
import jinja2
|
||||
|
||||
def render(tpl_path):
|
||||
path, filename = os.path.split(tpl_path)
|
||||
return jinja2.Environment(
|
||||
loader=jinja2.FileSystemLoader(path or './')
|
||||
).get_template(filename).render()
|
||||
|
||||
n = len(sys.argv)
|
||||
if ( n != 3 ):
|
||||
sys.exit("The template file name and output file name are expected as arguments")
|
||||
# set template file name, output file name
|
||||
driver_wrapper_template_filename = sys.argv[1]
|
||||
driver_wrapper_output_filename = sys.argv[2]
|
||||
|
||||
# render the template
|
||||
result = render(driver_wrapper_template_filename)
|
||||
|
||||
# write output to file
|
||||
outFile = open(driver_wrapper_output_filename,"w")
|
||||
outFile.write(result)
|
||||
outFile.close()
|
2335
scripts/codegen_driverwrappers/psa_crypto_driver_wrappers.conf
Normal file
2335
scripts/codegen_driverwrappers/psa_crypto_driver_wrappers.conf
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,14 @@
|
|||
@rem Generate automatically-generated configuration-independent source files
|
||||
@rem and build scripts.
|
||||
@rem Perl and Python 3 must be on the PATH.
|
||||
perl scripts\generate_errors.pl || exit /b 1
|
||||
perl scripts\generate_query_config.pl || exit /b 1
|
||||
perl scripts\generate_features.pl || exit /b 1
|
||||
@rem Generate automatically-generated configuration-independent source files
|
||||
@rem and build scripts.
|
||||
@rem Perl and Python 3 must be on the PATH.
|
||||
@rem psa_crypto_driver_wrappers.c needs to be generated prior to
|
||||
@rem generate_visualc_files.pl being invoked.
|
||||
python scripts/codegen_driverwrappers/generate_driver_wrappers.py ^
|
||||
"scripts/codegen_driverwrappers/psa_crypto_driver_wrappers.conf" ^
|
||||
"library/psa_crypto_driver_wrappers.c" || exit /b 1
|
||||
perl scripts\generate_errors.pl || exit /b 1
|
||||
perl scripts\generate_query_config.pl || exit /b 1
|
||||
perl scripts\generate_features.pl || exit /b 1
|
||||
python scripts\generate_ssl_debug_helpers.py || exit /b 1
|
||||
perl scripts\generate_visualc_files.pl || exit /b 1
|
||||
python scripts\generate_psa_constants.py || exit /b 1
|
||||
|
|
Loading…
Reference in a new issue