mirror of
https://github.com/Mbed-TLS/mbedtls-framework.git
synced 2026-08-17 16:49:51 +00:00
Add option --list-for-cmake
Similar to `generate_*_tests.py`, let Python rather than Cmake worry about constructing a CMake list. Signed-off-by: Gilles Peskine <[email protected]>
This commit is contained in:
@@ -14,7 +14,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
import typing
|
import typing
|
||||||
from typing import List
|
from typing import Iterator, List
|
||||||
|
|
||||||
from . import build_tree
|
from . import build_tree
|
||||||
from . import typing_util
|
from . import typing_util
|
||||||
@@ -197,13 +197,12 @@ class HeaderGenerator:
|
|||||||
|
|
||||||
def generate_header_files(branch_data: BranchData,
|
def generate_header_files(branch_data: BranchData,
|
||||||
directory: str,
|
directory: str,
|
||||||
list_only: bool = False) -> None:
|
list_only: bool = False) -> Iterator[str]:
|
||||||
"""Generate the header files to include before and after *config.h."""
|
"""Generate the header files to include before and after *config.h."""
|
||||||
for position in Position:
|
for position in Position:
|
||||||
generator = HeaderGenerator(branch_data, position)
|
generator = HeaderGenerator(branch_data, position)
|
||||||
if list_only:
|
yield os.path.join(directory, generator.output_file_name())
|
||||||
print(os.path.join(directory, generator.output_file_name()))
|
if not list_only:
|
||||||
else:
|
|
||||||
generator.write(directory)
|
generator.write(directory)
|
||||||
|
|
||||||
|
|
||||||
@@ -212,10 +211,18 @@ def main(branch_data: BranchData) -> None:
|
|||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
parser.add_argument('--list', action='store_true',
|
parser.add_argument('--list', action='store_true',
|
||||||
help='List generated files and exit')
|
help='List generated files and exit')
|
||||||
|
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='?',
|
parser.add_argument('output_directory', metavar='DIR', nargs='?',
|
||||||
default=os.path.join(root, branch_data.header_directory),
|
default=os.path.join(root, branch_data.header_directory),
|
||||||
help='output file location (default: %(default)s)')
|
help='output file location (default: %(default)s)')
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
generate_header_files(branch_data,
|
list_only = options.list or options.list_for_cmake
|
||||||
options.output_directory,
|
output_files = generate_header_files(branch_data,
|
||||||
list_only=options.list)
|
options.output_directory,
|
||||||
|
list_only=list_only)
|
||||||
|
if options.list_for_cmake:
|
||||||
|
sys.stdout.write(';'.join(output_files))
|
||||||
|
elif options.list:
|
||||||
|
for filename in output_files:
|
||||||
|
print(filename)
|
||||||
|
|||||||
Reference in New Issue
Block a user