mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-06 07:10:41 +00:00
6f21e45b78
Pylint errors are fixed. The Python script is improved to take default arguments when not passed (eg invoked from root of the tree) check-generated-files.sh and CMakeLists.sh updated. Signed-off-by: Archana <archana.madhavan@silabs.com>
36 lines
1.0 KiB
Python
Executable File
36 lines
1.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""This script is required for the auto generation of the
|
|
psa_crypto_driver_wrappers.c file"""
|
|
|
|
import sys
|
|
import os
|
|
import jinja2
|
|
|
|
def render(template_path: str) -> str:
|
|
environment = jinja2.Environment(
|
|
loader=jinja2.FileSystemLoader(os.path.dirname(template_path)),
|
|
keep_trailing_newline=True)
|
|
template = environment.get_template(os.path.basename(template_path))
|
|
return template.render()
|
|
|
|
N = len(sys.argv)
|
|
if N != 2:
|
|
# This is the Root directory.
|
|
ROOT_DIR = ""
|
|
else:
|
|
# Set the root based on the argument passed.
|
|
ROOT_DIR = sys.argv[1]
|
|
|
|
# Set template file name, output file name from the root directory
|
|
DRIVER_WRAPPER_TEMPLATE_FILENAME = ROOT_DIR +\
|
|
"scripts/data_files/driver_templates/psa_crypto_driver_wrappers.conf"
|
|
DRIVER_WRAPPER_OUTPUT_FILENAME = ROOT_DIR + "library/psa_crypto_driver_wrappers.c"
|
|
|
|
# Render the template
|
|
RESULT = render(DRIVER_WRAPPER_TEMPLATE_FILENAME)
|
|
|
|
# Write output to file
|
|
OUT_FILE = open(DRIVER_WRAPPER_OUTPUT_FILENAME, "w")
|
|
OUT_FILE.write(RESULT)
|
|
OUT_FILE.close()
|