From ac46287c2e1372b84e33226e6a5a4a2221136314 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Fri, 28 Mar 2025 19:23:53 +0100 Subject: [PATCH 1/3] Fix make_generated_files.py for Windows Signed-off-by: Ronald Cron --- scripts/make_generated_files.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/make_generated_files.py b/scripts/make_generated_files.py index 572b61ac1..46e6ddd4f 100755 --- a/scripts/make_generated_files.py +++ b/scripts/make_generated_files.py @@ -29,6 +29,11 @@ class GenerationScript: output_file_option: Optional[str] = None): """ Path from the root of Mbed TLS or TF-PSA-Crypto of the generation script """ self.script = script + """ Executable to run the script, needed for Windows """ + if script.suffix == ".py": + self.exe = "python" + elif script.suffix == ".pl": + self.exe = "perl" """ List of the default paths from the Mbed TLS or TF-PSA-Crypto root of the files the script generates. @@ -51,8 +56,13 @@ def get_generation_script_files(generation_script: str): generates. It is assumed that the script supports the "--list" option. """ files = [] - output = subprocess.check_output([generation_script, "--list"], - universal_newlines=True) + if generation_script.endswith(".py"): + cmd = ["python"] + elif generation_script.endswith(".pl"): + cmd = ["perl"] + cmd += [generation_script, "--list"] + + output = subprocess.check_output(cmd, universal_newlines=True) for line in output.splitlines(): files.append(Path(line)) @@ -169,7 +179,7 @@ def make_generated_files(generation_scripts: List[GenerationScript]): the Mbed TLS or TF-PSA-Crypto tree. """ for generation_script in generation_scripts: - subprocess.run([str(generation_script.script)], check=True) + subprocess.run([generation_script.exe, str(generation_script.script)], check=True) def check_generated_files(generation_scripts: List[GenerationScript], root: Path): """ @@ -184,7 +194,7 @@ def check_generated_files(generation_scripts: List[GenerationScript], root: Path bak_file.unlink() file.rename(bak_file) - command = [str(generation_script.script)] + command = [generation_script.exe, str(generation_script.script)] if generation_script.output_dir_option is not None: command += [generation_script.output_dir_option, str(root / Path(generation_script.files[0].parent))] From 0af45b5e2786871da678bd864d0c4e0008497005 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Sat, 29 Mar 2025 09:45:15 +0100 Subject: [PATCH 2/3] Add handshake-generated.sh generation Add handshake-generated.sh generation in make_generated_files.py Signed-off-by: Ronald Cron --- scripts/make_generated_files.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/make_generated_files.py b/scripts/make_generated_files.py index 46e6ddd4f..3fe21104c 100755 --- a/scripts/make_generated_files.py +++ b/scripts/make_generated_files.py @@ -155,6 +155,11 @@ if build_tree.looks_like_mbedtls_root(".") and not build_tree.is_mbedtls_3_6(): [Path("tests/opt-testcases/tls13-compat.sh")], None, "--output" ), + GenerationScript( + Path("framework/scripts/generate_tls_handshake_tests.py"), + [Path("tests/opt-testcases/handshake-generated.sh")], + None, "--output" + ), GenerationScript( Path("scripts/generate_visualc_files.pl"), get_generation_script_files("scripts/generate_visualc_files.pl"), From a8e29ac653a720338205f821ef9a4a1106f55126 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Sat, 29 Mar 2025 11:35:05 +0100 Subject: [PATCH 3/3] Fix pylint W0105 warning Fix pylint W0105 warning: framework/scripts/make_generated_files.py:37:8: W0105: String statement has no effect (pointless-string-statement) Signed-off-by: Ronald Cron --- scripts/make_generated_files.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/scripts/make_generated_files.py b/scripts/make_generated_files.py index 3fe21104c..1ca0f2da7 100755 --- a/scripts/make_generated_files.py +++ b/scripts/make_generated_files.py @@ -27,27 +27,25 @@ class GenerationScript: def __init__(self, script: Path, files: List[Path], output_dir_option: Optional[str] = None, output_file_option: Optional[str] = None): - """ Path from the root of Mbed TLS or TF-PSA-Crypto of the generation script """ + # Path from the root of Mbed TLS or TF-PSA-Crypto of the generation script self.script = script - """ Executable to run the script, needed for Windows """ + + # Executable to run the script, needed for Windows if script.suffix == ".py": self.exe = "python" elif script.suffix == ".pl": self.exe = "perl" - """ - List of the default paths from the Mbed TLS or TF-PSA-Crypto root of the - files the script generates. - """ + + # List of the default paths from the Mbed TLS or TF-PSA-Crypto root of the + # files the script generates. self.files = files - """ - Output directory script argument. Can be an empty string in case it is a - positional argument. - """ + + # Output directory script argument. Can be an empty string in case it is a + # positional argument. self.output_dir_option = output_dir_option - """ - Output file script argument. Can be an empty string in case it is a - positional argument. - """ + + # Output file script argument. Can be an empty string in case it is a + # positional argument. self.output_file_option = output_file_option def get_generation_script_files(generation_script: str):