From 7082fdc9c44bb0cb4b5b8fa4f96bcd5b0544ea9f Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 14 Nov 2025 14:59:07 +0100 Subject: [PATCH] Make sure to list paths with / even on Windows This is necessary when the tool that consumes the path requires slash-separated paths, notably when it's CMake. I'm not aware of a potential consumer that would require a path using backslashes. Fixes Mbed-TLS/mbedtls#10502. Signed-off-by: Gilles Peskine --- scripts/mbedtls_framework/config_checks_generator.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/mbedtls_framework/config_checks_generator.py b/scripts/mbedtls_framework/config_checks_generator.py index 957099edc..ae7994ebe 100644 --- a/scripts/mbedtls_framework/config_checks_generator.py +++ b/scripts/mbedtls_framework/config_checks_generator.py @@ -10,6 +10,7 @@ See framework/docs/architecture/config-check-framework.md for information. import argparse import enum import os +import posixpath import re import sys import textwrap @@ -256,7 +257,9 @@ def generate_header_files(branch_data: BranchData, """Generate the header files to include before and after *config.h.""" for position in Position: generator = HeaderGenerator(branch_data, position) - yield os.path.join(directory, generator.output_file_name()) + # Make sure to output a path with / even on Windows, so that + # it can be consumed by tools such as CMake. + yield posixpath.join(directory, generator.output_file_name()) if not list_only: generator.write(directory) @@ -280,7 +283,7 @@ def main(branch_data: BranchData) -> None: parser.add_argument('--list-for-cmake', action='store_true', help='List generated files in CMake-friendly format and exit') parser.add_argument('output_directory', metavar='DIR', nargs='?', - default=os.path.join(root, branch_data.header_directory), + default=posixpath.join(root, branch_data.header_directory), help='output file location (default: %(default)s)') options = parser.parse_args() list_only = options.list or options.list_for_cmake