diff --git a/CHANGELOG.md b/CHANGELOG.md index 90d8c37..fe35b59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## [0.11.0] 2024-10-11 +## [0.11.1] 2024-03-04 +### Added +- support for new keywords in native commands and new commands available in CMake 3.29 + +## [0.11.0] 2024-01-11 ### Added - Number of workers spawned for formatting multiple files can be changed with `-w/--workers`. By default it will be number of CPUs available in the system but limited to 60 for Windows machines due to [this](https://github.com/python/cpython/issues/89240). diff --git a/gersemi/builtin_commands b/gersemi/builtin_commands index dfd1cf6..ba26f53 100644 --- a/gersemi/builtin_commands +++ b/gersemi/builtin_commands @@ -275,6 +275,8 @@ cmake_find_frameworks ### CMakePackageConfigHelpers configure_package_config_file +generate_apple_architecture_selection_file +generate_apple_platform_selection_file write_basic_package_version_file ### CMakePrintHelpers diff --git a/gersemi/command_invocation_dumpers/condition_syntax_command_invocation_dumper.py b/gersemi/command_invocation_dumpers/condition_syntax_command_invocation_dumper.py index ccb66d2..e5642f7 100644 --- a/gersemi/command_invocation_dumpers/condition_syntax_command_invocation_dumper.py +++ b/gersemi/command_invocation_dumpers/condition_syntax_command_invocation_dumper.py @@ -41,6 +41,9 @@ class IsolateUnaryTests(IsolateUnaryOperators): "IS_SYMLINK", "IS_ABSOLUTE", "DEFINED", + "IS_READABLE", + "IS_WRITABLE", + "IS_EXECUTABLE", ] diff --git a/gersemi/command_invocation_dumpers/ctest_command_dumpers.py b/gersemi/command_invocation_dumpers/ctest_command_dumpers.py index a9a6556..2b13ed4 100644 --- a/gersemi/command_invocation_dumpers/ctest_command_dumpers.py +++ b/gersemi/command_invocation_dumpers/ctest_command_dumpers.py @@ -106,6 +106,8 @@ class CTestTest(ArgumentAwareCommandInvocationDumper): "STOP_TIME", "RETURN_VALUE", "CAPTURE_CMAKE_ERROR", + "INCLUDE_FROM_FILE", + "EXCLUDE_FROM_FILE", ] diff --git a/gersemi/command_invocation_dumpers/module_command_dumpers.py b/gersemi/command_invocation_dumpers/module_command_dumpers.py index 21f1c67..d60b5ab 100644 --- a/gersemi/command_invocation_dumpers/module_command_dumpers.py +++ b/gersemi/command_invocation_dumpers/module_command_dumpers.py @@ -507,6 +507,35 @@ class FortranCInterfaceHeader(ArgumentAwareCommandInvocationDumper): multi_value_keywords = ["SYMBOLS"] +class GenerateAppleArchitectureSelectionFile(ArgumentAwareCommandInvocationDumper): + front_positional_arguments = [""] + one_value_keywords = [ + "INSTALL_DESTINATION", + "INSTALL_PREFIX", + "SINGLE_ARCHITECTURES", + "SINGLE_ARCHITECTURE_INCLUDE_FILES", + "UNIVERSAL_ARCHITECTURES", + "UNIVERSAL_INCLUDE_FILE", + ] + + +class GenerateApplePlatformSelectionFile(ArgumentAwareCommandInvocationDumper): + front_positional_arguments = [""] + one_value_keywords = [ + "INSTALL_DESTINATION", + "INSTALL_PREFIX", + "MACOS_INCLUDE_FILE", + "IOS_INCLUDE_FILE", + "IOS_SIMULATOR_INCLUDE_FILE", + "TVOS_INCLUDE_FILE", + "TVOS_SIMULATOR_INCLUDE_FILE", + "WATCHOS_INCLUDE_FILE", + "WATCHOS_SIMULATOR_INCLUDE_FILE", + "VISIONOS_INCLUDE_FILE", + "VISIONOS_SIMULATOR_INCLUDE_FILE", + ] + + class GenerateExportHeader(ArgumentAwareCommandInvocationDumper): options = ["DEFINE_NO_DEPRECATED"] one_value_keywords = [ @@ -824,6 +853,8 @@ class ExternalDataAddTarget(ArgumentAwareCommandInvocationDumper): "find_package_handle_standard_args": FindPackageHandleStandardArgs, "find_package_check_version": FindPackageCheckVersion, "fortrancinterface_header": FortranCInterfaceHeader, + "generate_apple_architecture_selection_file": GenerateAppleArchitectureSelectionFile, + "generate_apple_platform_selection_file": GenerateApplePlatformSelectionFile, "generate_export_header": GenerateExportHeader, "gtest_add_tests": GTestAddTests, "gtest_discover_tests": GTestDiscoverTests, diff --git a/gersemi/command_invocation_dumpers/multiple_signature_command_invocation_dumper.py b/gersemi/command_invocation_dumpers/multiple_signature_command_invocation_dumper.py index 2de1162..61ba863 100644 --- a/gersemi/command_invocation_dumpers/multiple_signature_command_invocation_dumper.py +++ b/gersemi/command_invocation_dumpers/multiple_signature_command_invocation_dumper.py @@ -7,10 +7,26 @@ from .argument_aware_command_invocation_dumper import ( ArgumentAwareCommandInvocationDumper, ) +from .section_aware_command_invocation_dumper import Sections + + +def create_signature_patch(signature, old_class): + def get(key): + return signature.get(key, []) + + class Impl(old_class): + front_positional_arguments = get("front_positional_arguments") + back_positional_arguments = get("back_positional_arguments") + options = get("options") + one_value_keywords = get("one_value_keywords") + multi_value_keywords = get("multi_value_keywords") + sections = get("sections") + + return Impl class MultipleSignatureCommandInvocationDumper(ArgumentAwareCommandInvocationDumper): - customized_signatures: Dict[Optional[str], Dict[str, Union[List, int]]] = {} + customized_signatures: Dict[Optional[str], Dict[str, Union[List, Sections]]] = {} @contextmanager def _update_signature_characteristics(self, signature): @@ -18,23 +34,12 @@ def _update_signature_characteristics(self, signature): yield return + old_class = type(self) try: - - def get(key): - return signature.get(key, []) - - self.front_positional_arguments = get("front_positional_arguments") - self.back_positional_arguments = get("back_positional_arguments") - self.options = get("options") - self.one_value_keywords = get("one_value_keywords") - self.multi_value_keywords = get("multi_value_keywords") + self.__class__ = create_signature_patch(signature, old_class) yield finally: - delattr(self, "front_positional_arguments") - delattr(self, "back_positional_arguments") - delattr(self, "options") - delattr(self, "one_value_keywords") - delattr(self, "multi_value_keywords") + self.__class__ = old_class def format_command(self, tree): _, arguments = tree.children diff --git a/gersemi/command_invocation_dumpers/project_command_dumpers.py b/gersemi/command_invocation_dumpers/project_command_dumpers.py index 9048440..51dee8c 100644 --- a/gersemi/command_invocation_dumpers/project_command_dumpers.py +++ b/gersemi/command_invocation_dumpers/project_command_dumpers.py @@ -160,15 +160,35 @@ class DefineProperty(ArgumentAwareCommandInvocationDumper): multi_value_keywords = ["BRIEF_DOCS", "FULL_DOCS"] -class Export(MultipleSignatureCommandInvocationDumper): +class Export( + SectionAwareCommandInvocationDumper, MultipleSignatureCommandInvocationDumper +): customized_signatures = { - "EXPORT": dict(one_value_keywords=["EXPORT", "NAMESPACE", "FILE"]), + "EXPORT": dict( + options=["EXPORT_PACKAGE_DEPENDENCIES"], + one_value_keywords=["EXPORT", "NAMESPACE", "FILE"], + ), "TARGETS": dict( options=["APPEND", "EXPORT_LINK_INTERFACE_LIBRARIES"], one_value_keywords=["NAMESPACE", "FILE", "ANDROID_MK"], multi_value_keywords=["TARGETS"], ), "PACKAGE": dict(one_value_keywords=["PACKAGE"]), + "SETUP": dict( + one_value_keywords=["SETUP"], + multi_value_keywords=["PACKAGE_DEPENDENCY", "TARGET"], + sections=dict( + PACKAGE_DEPENDENCY=dict( + front_positional_arguments=[""], + one_value_keywords=["ENABLED"], + multi_value_keywords=["EXTRA_ARGS"], + ), + TARGET=dict( + front_positional_arguments=[""], + one_value_keywords=["XCFRAMEWORK_LOCATION"], + ), + ), + ), } @@ -273,7 +293,11 @@ class Install(TwoWordKeywordIsolator, MultipleSignatureCommandInvocationDumper): one_value_keywords=["CODE", "COMPONENT"], ), "EXPORT": dict( - options=["EXPORT_LINK_INTERFACE_LIBRARIES", "EXCLUDE_FROM_ALL"], + options=[ + "EXPORT_LINK_INTERFACE_LIBRARIES", + "EXCLUDE_FROM_ALL", + "EXPORT_PACKAGE_DEPENDENCIES", + ], one_value_keywords=[ "EXPORT", "DESTINATION", diff --git a/gersemi/command_invocation_dumpers/scripting_command_dumpers.py b/gersemi/command_invocation_dumpers/scripting_command_dumpers.py index 4bb83b5..d0e68be 100644 --- a/gersemi/command_invocation_dumpers/scripting_command_dumpers.py +++ b/gersemi/command_invocation_dumpers/scripting_command_dumpers.py @@ -44,6 +44,7 @@ class CMakeLanguage(TwoWordKeywordIsolator, ArgumentAwareCommandInvocationDumper "GET_CALL", "SET_DEPENDENCY_PROVIDER", "GET_MESSAGE_LOG_LEVEL", + "EXIT", ] multi_value_keywords = [ "DEFER", diff --git a/gersemi/command_invocation_dumpers/section_aware_command_invocation_dumper.py b/gersemi/command_invocation_dumpers/section_aware_command_invocation_dumper.py index 6b8f324..e0e6f47 100644 --- a/gersemi/command_invocation_dumpers/section_aware_command_invocation_dumper.py +++ b/gersemi/command_invocation_dumpers/section_aware_command_invocation_dumper.py @@ -6,21 +6,32 @@ ) +Sections = Dict[str, Dict[str, Iterable[str]]] + + +def create_section_patch(section, old_class): + def get(key): + return section.get(key, []) + + class Impl(old_class): + options = get("options") + one_value_keywords = get("one_value_keywords") + multi_value_keywords = get("multi_value_keywords") + + return Impl + + class SectionAwareCommandInvocationDumper(ArgumentAwareCommandInvocationDumper): sections: Dict[str, Dict[str, Iterable[str]]] = {} @contextmanager def _update_section_characteristics(self, keyword): + old_class = type(self) try: - section = self.sections[keyword] - self.options = section.get("options", []) - self.one_value_keywords = section.get("one_value_keywords", []) - self.multi_value_keywords = section.get("multi_value_keywords", []) + self.__class__ = create_section_patch(self.sections[keyword], old_class) yield finally: - delattr(self, "options") - delattr(self, "one_value_keywords") - delattr(self, "multi_value_keywords") + self.__class__ = old_class def _format_group(self, group) -> str: result = self._try_to_format_into_single_line(group, separator=" ") diff --git a/tests/formatter/export_command.in.cmake b/tests/formatter/export_command.in.cmake index acb9614..21b3155 100644 --- a/tests/formatter/export_command.in.cmake +++ b/tests/formatter/export_command.in.cmake @@ -36,4 +36,8 @@ export(TARGETS FOO BAR BAZ ANDROID_MK FOO) export(TARGETS long_arg____________________________________________________________ ANDROID_MK long_arg____________________________________________________________) -export(TARGETS long_arg____________________________________________________________ long_arg____________________________________________________________ long_arg____________________________________________________________ ANDROID_MK long_arg____________________________________________________________) \ No newline at end of file +export(TARGETS long_arg____________________________________________________________ long_arg____________________________________________________________ long_arg____________________________________________________________ ANDROID_MK long_arg____________________________________________________________) + +export(SETUP foo PACKAGE_DEPENDENCY bar ENABLED AUTO EXTRA_ARGS baz qux foo TARGET bar XCFRAMEWORK_LOCATION baz) + +export(SETUP foo__________________________________________________ PACKAGE_DEPENDENCY bar__________________________________________________ ENABLED AUTO EXTRA_ARGS baz__________________________________________________ qux__________________________________________________ foo__________________________________________________ TARGET bar__________________________________________________ XCFRAMEWORK_LOCATION baz__________________________________________________) diff --git a/tests/formatter/export_command.out.cmake b/tests/formatter/export_command.out.cmake index 172c062..fd76412 100644 --- a/tests/formatter/export_command.out.cmake +++ b/tests/formatter/export_command.out.cmake @@ -93,3 +93,24 @@ export( ANDROID_MK long_arg____________________________________________________________ ) + +export( + SETUP foo + PACKAGE_DEPENDENCY bar ENABLED AUTO EXTRA_ARGS baz qux foo + TARGET bar XCFRAMEWORK_LOCATION baz +) + +export( + SETUP foo__________________________________________________ + PACKAGE_DEPENDENCY + bar__________________________________________________ + ENABLED AUTO + EXTRA_ARGS + baz__________________________________________________ + qux__________________________________________________ + foo__________________________________________________ + TARGET + bar__________________________________________________ + XCFRAMEWORK_LOCATION + baz__________________________________________________ +)