blob: b05612ebcdcf59ab1973fdbb272f6bc52e4aed61 [file] [log] [blame]
Archana1f1a34a2021-11-17 08:44:07 +05301#!/usr/bin/env python3
Archana6f21e452021-11-23 14:46:51 +05302"""This script is required for the auto generation of the
3 psa_crypto_driver_wrappers.c file"""
Archana1f1a34a2021-11-17 08:44:07 +05304
5import sys
Archana1f1a34a2021-11-17 08:44:07 +05306import os
7import jinja2
8
Archana6f21e452021-11-23 14:46:51 +05309def render(template_path: str) -> str:
10 environment = jinja2.Environment(
11 loader=jinja2.FileSystemLoader(os.path.dirname(template_path)),
12 keep_trailing_newline=True)
13 template = environment.get_template(os.path.basename(template_path))
14 return template.render()
Archana1f1a34a2021-11-17 08:44:07 +053015
Archana6f21e452021-11-23 14:46:51 +053016N = len(sys.argv)
17if N != 2:
18# This is the Root directory.
19 ROOT_DIR = ""
20else:
21# Set the root based on the argument passed.
22 ROOT_DIR = sys.argv[1]
Archana1f1a34a2021-11-17 08:44:07 +053023
Archana6f21e452021-11-23 14:46:51 +053024# Set template file name, output file name from the root directory
25DRIVER_WRAPPER_TEMPLATE_FILENAME = ROOT_DIR +\
26 "scripts/data_files/driver_templates/psa_crypto_driver_wrappers.conf"
27DRIVER_WRAPPER_OUTPUT_FILENAME = ROOT_DIR + "library/psa_crypto_driver_wrappers.c"
Archana1f1a34a2021-11-17 08:44:07 +053028
Archana6f21e452021-11-23 14:46:51 +053029# Render the template
30RESULT = render(DRIVER_WRAPPER_TEMPLATE_FILENAME)
31
32# Write output to file
33OUT_FILE = open(DRIVER_WRAPPER_OUTPUT_FILENAME, "w")
34OUT_FILE.write(RESULT)
35OUT_FILE.close()