From a84973cff36a0abf0096f2689f85722bf74e0ecc Mon Sep 17 00:00:00 2001 From: Blank Spruce <32396809+BlankSpruce@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:49:58 +0200 Subject: [PATCH] Add support for CMake 3.31 --- CHANGELOG.md | 7 +++++ README.md | 2 +- gersemi/__version__.py | 2 +- gersemi/builtin_commands | 1 + .../module_command_dumpers.py | 12 ++++++-- .../project_command_dumpers.py | 1 + .../scripting_command_dumpers.py | 22 ++++++++++++++ tests/formatter/cmake_pkg_config.in.cmake | 5 ++++ tests/formatter/cmake_pkg_config.out.cmake | 30 +++++++++++++++++++ 9 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 tests/formatter/cmake_pkg_config.in.cmake create mode 100644 tests/formatter/cmake_pkg_config.out.cmake diff --git a/CHANGELOG.md b/CHANGELOG.md index d9d048e..55e1331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ # Changelog +## [0.16.1] 2024-10-14 +### Added +- support for new keywords in native commands available in CMake 3.31 + +### Fixed +- incorrect keywords in `bison_target` and `flex_target` (#37) + ## [0.16.0] 2024-10-11 ### Changed - removed dependency to `dataclasses` package (#36) diff --git a/README.md b/README.md index 7f6a859..66bbb2a 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ You can use gersemi with a pre-commit hook by adding the following to `.pre-comm ```yaml repos: - repo: https://github.com/BlankSpruce/gersemi - rev: 0.15.1 + rev: 0.16.1 hooks: - id: gersemi ``` diff --git a/gersemi/__version__.py b/gersemi/__version__.py index 6c4c8ca..5a454dc 100644 --- a/gersemi/__version__.py +++ b/gersemi/__version__.py @@ -4,4 +4,4 @@ __license__ = "MPL 2.0" __title__ = "gersemi" __url__ = "https://github.com/BlankSpruce/gersemi" -__version__ = "0.16.0" +__version__ = "0.16.1" diff --git a/gersemi/builtin_commands b/gersemi/builtin_commands index a4dec3e..713f43b 100644 --- a/gersemi/builtin_commands +++ b/gersemi/builtin_commands @@ -10,6 +10,7 @@ cmake_language cmake_minimum_required cmake_parse_arguments cmake_path +cmake_pkg_config cmake_policy configure_file continue diff --git a/gersemi/command_invocation_dumpers/module_command_dumpers.py b/gersemi/command_invocation_dumpers/module_command_dumpers.py index 059566c..e668c18 100644 --- a/gersemi/command_invocation_dumpers/module_command_dumpers.py +++ b/gersemi/command_invocation_dumpers/module_command_dumpers.py @@ -532,10 +532,13 @@ class GenerateAppleArchitectureSelectionFile(ArgumentAwareCommandInvocationDumpe one_value_keywords = [ "INSTALL_DESTINATION", "INSTALL_PREFIX", + "UNIVERSAL_INCLUDE_FILE", + "ERROR_VARIABLE", + ] + multi_value_keywords = [ "SINGLE_ARCHITECTURES", "SINGLE_ARCHITECTURE_INCLUDE_FILES", "UNIVERSAL_ARCHITECTURES", - "UNIVERSAL_INCLUDE_FILE", ] @@ -547,12 +550,14 @@ class GenerateApplePlatformSelectionFile(ArgumentAwareCommandInvocationDumper): "MACOS_INCLUDE_FILE", "IOS_INCLUDE_FILE", "IOS_SIMULATOR_INCLUDE_FILE", + "IOS_CATALYST_INCLUDE_FILE", "TVOS_INCLUDE_FILE", "TVOS_SIMULATOR_INCLUDE_FILE", "WATCHOS_INCLUDE_FILE", "WATCHOS_SIMULATOR_INCLUDE_FILE", "VISIONOS_INCLUDE_FILE", "VISIONOS_SIMULATOR_INCLUDE_FILE", + "ERROR_VARIABLE", ] @@ -595,16 +600,17 @@ class GTestDiscoverTests( "WORKING_DIRECTORY", "TEST_PREFIX", "TEST_SUFFIX", + "TEST_FILTER", "TEST_LIST", "DISCOVERY_TIMEOUT", "XML_OUTPUT_DIR", "DISCOVERY_MODE", - "TEST_FILTER", ] - multi_value_keywords = ["EXTRA_ARGS", "PROPERTIES"] + multi_value_keywords = ["EXTRA_ARGS", "PROPERTIES", "DISCOVERY_EXTRA_ARGS"] keyword_formatters = { "EXTRA_ARGS": "_format_command_line", "PROPERTIES": "_format_keyword_with_pairs", + "DISCOVERY_EXTRA_ARGS": "_format_command_line", } diff --git a/gersemi/command_invocation_dumpers/project_command_dumpers.py b/gersemi/command_invocation_dumpers/project_command_dumpers.py index 228ce80..55f4497 100644 --- a/gersemi/command_invocation_dumpers/project_command_dumpers.py +++ b/gersemi/command_invocation_dumpers/project_command_dumpers.py @@ -21,6 +21,7 @@ class AddCustomCommand(CommandLineFormatter, MultipleSignatureCommandInvocationD "USES_TERMINAL", "COMMAND_EXPAND_LISTS", "DEPENDS_EXPLICIT_ONLY", + "CODEGEN", ], one_value_keywords=[ "MAIN_DEPENDENCY", diff --git a/gersemi/command_invocation_dumpers/scripting_command_dumpers.py b/gersemi/command_invocation_dumpers/scripting_command_dumpers.py index 6cf5324..41c03b2 100644 --- a/gersemi/command_invocation_dumpers/scripting_command_dumpers.py +++ b/gersemi/command_invocation_dumpers/scripting_command_dumpers.py @@ -204,6 +204,26 @@ class CMakePath(TwoWordKeywordIsolator, MultipleSignatureCommandInvocationDumper } +class CMakePkgConfig(ArgumentAwareCommandInvocationDumper): + options = ["REQUIRED", "EXACT", "QUIET"] + one_value_keywords = [ + "STRICTNESS", + "ENV_MODE", + "DISABLE_UNINSTALLED", + "PC_SYSROOT_DIR", + "TOP_BUILD_DIR", + "ALLOW_SYSTEM_INCLUDES", + "ALLOW_SYSTEM_LIBS", + ] + multi_value_keywords = [ + "EXTRACT", + "PC_LIBDIR", + "PC_PATH", + "SYSTEM_INCLUDE_DIRS", + "SYSTEM_LIBRARY_DIRS", + ] + + class CMakePolicy(MultipleSignatureCommandInvocationDumper): customized_signatures = { "VERSION": dict(front_positional_arguments=["..."]), @@ -490,6 +510,7 @@ class File(TwoWordKeywordIsolator, MultipleSignatureCommandInvocationDumper): "COMPRESSION", "COMPRESSION_LEVEL", "MTIME", + "WORKING_DIRECTORY", ], multi_value_keywords=["PATHS"], ), @@ -964,6 +985,7 @@ class Unset(ArgumentAwareCommandInvocationDumper): "cmake_minimum_required": CMakeMinimumRequired, "cmake_parse_arguments": CMakeParseArguments, "cmake_path": CMakePath, + "cmake_pkg_config": CMakePkgConfig, "cmake_policy": CMakePolicy, "configure_file": ConfigureFile, "elseif": ConditionSyntaxCommandInvocationDumper, diff --git a/tests/formatter/cmake_pkg_config.in.cmake b/tests/formatter/cmake_pkg_config.in.cmake new file mode 100644 index 0000000..e142ca3 --- /dev/null +++ b/tests/formatter/cmake_pkg_config.in.cmake @@ -0,0 +1,5 @@ +cmake_pkg_config(EXTRACT foo REQUIRED ENV_MODE PKGCONF PC_PATH /foo/bar /foo/baz /bar /baz) + +cmake_pkg_config(EXTRACT foo REQUIRED ENV_MODE PKGCONF PC_PATH /foo/bar /foo/baz /bar /baz /foo__________________________________________________) + +cmake_pkg_config(EXTRACT foo 1.2.3 REQUIRED ENV_MODE PKGCONF PC_PATH /foo/bar /foo/baz /bar /baz /foo__________________________________________________) diff --git a/tests/formatter/cmake_pkg_config.out.cmake b/tests/formatter/cmake_pkg_config.out.cmake new file mode 100644 index 0000000..c5e6949 --- /dev/null +++ b/tests/formatter/cmake_pkg_config.out.cmake @@ -0,0 +1,30 @@ +cmake_pkg_config( + EXTRACT foo + REQUIRED + ENV_MODE PKGCONF + PC_PATH /foo/bar /foo/baz /bar /baz +) + +cmake_pkg_config( + EXTRACT foo + REQUIRED + ENV_MODE PKGCONF + PC_PATH + /foo/bar + /foo/baz + /bar + /baz + /foo__________________________________________________ +) + +cmake_pkg_config( + EXTRACT foo 1.2.3 + REQUIRED + ENV_MODE PKGCONF + PC_PATH + /foo/bar + /foo/baz + /bar + /baz + /foo__________________________________________________ +)