From 377750be74d6d908e817594885c67cf7bc480ab2 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Fri, 19 Apr 2024 11:36:55 -0400 Subject: [PATCH] enhancement: by default, the script will output symbols, unless the --diff option is provided --- src/miral/CMakeLists.txt | 1 - src/miroil/CMakeLists.txt | 1 - tools/symbols_map_generator/main.py | 21 +++++++-------------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/miral/CMakeLists.txt b/src/miral/CMakeLists.txt index 2f8909a879f..0be4d6529c8 100644 --- a/src/miral/CMakeLists.txt +++ b/src/miral/CMakeLists.txt @@ -150,7 +150,6 @@ add_custom_target( --symbols-map-path="${CMAKE_CURRENT_SOURCE_DIR}/symbols.map" --external-headers-directory="${PROJECT_SOURCE_DIR}/include/miral" --include-dirs "$,:>" - --output-symbols WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}") add_custom_target( diff --git a/src/miroil/CMakeLists.txt b/src/miroil/CMakeLists.txt index 7c9fc3d04a1..654245941de 100644 --- a/src/miroil/CMakeLists.txt +++ b/src/miroil/CMakeLists.txt @@ -97,7 +97,6 @@ add_custom_target( --symbols-map-path="${CMAKE_CURRENT_SOURCE_DIR}/symbols.map" --external-headers-directory="${PROJECT_SOURCE_DIR}/include/miroil" --include-dirs "$,:>" - --output-symbols WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}") add_custom_target( diff --git a/tools/symbols_map_generator/main.py b/tools/symbols_map_generator/main.py index 5933cc87010..28555734794 100755 --- a/tools/symbols_map_generator/main.py +++ b/tools/symbols_map_generator/main.py @@ -290,8 +290,8 @@ def report_symbols_diff(previous_symbols: list[Symbol], new_symbols: set[str], i def main(): parser = argparse.ArgumentParser(description="This tool parses the header files of a provided in the Mir project " "and process a list of new internal and external symbols. " - "To view this list, the user may provide the --diff option. To modify the corresponding " - "symbols.map files automatically, the user may specify the --output_symbols option. " + "By default, the script updates the corresponding symbols.map file automatically. " + "To view this diff only, the user may provide the --diff option. " "The tool uses https://pypi.org/project/libclang/ to process " "the AST of the project's header files.\n\nIf the content of the outputted map " "file appears incorrect, trying using a later version of clang (e.g. clang 19). You can do this " @@ -321,20 +321,16 @@ def main(): required=True) parser.add_argument('--diff', action='store_true', help='if true a diff should be output to the console') - parser.add_argument('--output-symbols', action='store_true', - help='if true, the symbols.map file will be updated with the new new symbols', - dest='output_symbols') parser.add_argument('--include-dirs', type=str, help="colon separated list of directories to search for symbols", required=True, dest='include_dirs') args = parser.parse_args() logging.basicConfig(level=logging.INFO) - if args.output_symbols: - _logger.info("symbols_map_generator is running in 'output symbols' mode") - if args.diff: _logger.info("symbols_map_generator is running in 'diff' mode") + else: + _logger.info("symbols_map_generator is running in 'output symbols' mode") # Point libclang to a file on the system if 'MIR_SYMBOLS_MAP_GENERATOR_CLANG_SO_PATH' in os.environ: @@ -394,8 +390,9 @@ def main(): print("Internal Symbols Diff:") has_changed_symbols = has_changed_symbols or report_symbols_diff(previous_symbols, internal_symbols, True) print("") - - if args.output_symbols: + if has_changed_symbols: + exit(1) + else: _logger.info(f"Outputting the symbols file to: {args.symbols_map_path}") # We now have a list of new external and internal symbols. Our goal now is to add them to the correct stanzas @@ -478,10 +475,6 @@ def main(): ''' f.write(output_str) - - if args.diff and has_changed_symbols: - exit(1) - if __name__ == "__main__":