1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Merge pull request #3367 from hug-dev/psa-constants-in-build-dir

Generate PSA constant names in CMake build dir
This commit is contained in:
Gilles Peskine
2020-06-02 12:29:46 +02:00
committed by GitHub
2 changed files with 12 additions and 3 deletions

View File

@ -1,13 +1,19 @@
#!/usr/bin/env python3
"""Generate programs/psa/psa_constant_names_generated.c
"""Generate psa_constant_names_generated.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 programs/psa/
* OUTPUT_FILE_DIR passed: writes to OUTPUT_FILE_DIR/
"""
import os
import re
import sys
OUTPUT_TEMPLATE = '''\
/* Automatically generated by generate_psa_constant.py. DO NOT EDIT. */
@ -395,6 +401,8 @@ def generate_psa_constants(header_file_names, output_file_name):
if __name__ == '__main__':
if not os.path.isdir('programs') and os.path.isdir('../programs'):
os.chdir('..')
# 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 "programs/psa"
generate_psa_constants(['include/psa/crypto_values.h',
'include/psa/crypto_extra.h'],
'programs/psa/psa_constant_names_generated.c')
OUTPUT_FILE_DIR + '/psa_constant_names_generated.c')