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 <[email protected]>
This commit is contained in:
Gilles Peskine
2025-11-14 14:59:07 +01:00
parent 32e01d4688
commit 7082fdc9c4
@@ -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