diff --git a/CHANGELOG.md b/CHANGELOG.md index 86a82b1..fec5a14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog +## [0.13.6] 2024-07-10 +### Fixed +- non-deterministic formatting regression (#32) + ## [0.13.5] 2024-06-29 ### Fixed - improve consistency of `add_executable` diff --git a/README.md b/README.md index 0a00ca3..bd895fe 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,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.13.5 + rev: 0.13.6 hooks: - id: gersemi ``` diff --git a/gersemi/__version__.py b/gersemi/__version__.py index 72d5c87..0121d95 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.13.5" +__version__ = "0.13.6" 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 58489fd..0b3da84 100644 --- a/gersemi/command_invocation_dumpers/multiple_signature_command_invocation_dumper.py +++ b/gersemi/command_invocation_dumpers/multiple_signature_command_invocation_dumper.py @@ -21,7 +21,7 @@ class Impl(old_class): options = get("options") one_value_keywords = get("one_value_keywords") multi_value_keywords = get("multi_value_keywords") - sections = signature.get("sections", {}) + sections = get("sections") return Impl diff --git a/gersemi/command_invocation_dumpers/project_command_dumpers.py b/gersemi/command_invocation_dumpers/project_command_dumpers.py index f8b6879..228ce80 100644 --- a/gersemi/command_invocation_dumpers/project_command_dumpers.py +++ b/gersemi/command_invocation_dumpers/project_command_dumpers.py @@ -175,6 +175,7 @@ class Export( "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=[""], @@ -285,6 +286,7 @@ class Install( "TARGETS", _INCLUDES_DESTINATION, "RUNTIME_DEPENDENCIES", + *_Install_TARGETS_kinds, ], ), "FILES": dict( @@ -315,6 +317,7 @@ class Install( "FILE_PERMISSIONS", "DIRECTORY_PERMISSIONS", "CONFIGURATIONS", + *_Install_DIRECTORY_kinds, ], ), "SCRIPT": dict( @@ -363,6 +366,7 @@ class Install( one_value_keywords=["RUNTIME_DEPENDENCY_SET"], multi_value_keywords=[ "IMPORTED_RUNTIME_ARTIFACTS", + *_Install_IMPORTED_RUNTIME_ARTIFACTS_kinds, ], ), "RUNTIME_DEPENDENCY_SET": dict( @@ -391,6 +395,7 @@ class Install( "POST_INCLUDE_FILES", "POST_EXCLUDE_FILES", "DIRECTORIES", + *_Install_RUNTIME_DEPENDENCY_SET_kinds, ], ), } @@ -459,6 +464,14 @@ class TargetLinkLibraries( SectionAwareCommandInvocationDumper, ArgumentAwareCommandInvocationDumper ): front_positional_arguments = [""] + multi_value_keywords = [ + "INTERFACE", + "PUBLIC", + "PRIVATE", + "LINK_PRIVATE", + "LINK_PUBLIC", + "LINK_INTERFACE_LIBRARIES", + ] sections = { "INTERFACE": _debug_optimized_general, "PUBLIC": _debug_optimized_general, @@ -483,6 +496,7 @@ class TargetPrecompileHeaders(ArgumentAwareCommandInvocationDumper): class TargetSources(SectionAwareCommandInvocationDumper): front_positional_arguments = [""] + multi_value_keywords = ["INTERFACE", "PUBLIC", "PRIVATE"] sections = { "INTERFACE": { "one_value_keywords": ["FILE_SET", "TYPE"], 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 dfa9ba1..0ac069f 100644 --- a/gersemi/command_invocation_dumpers/section_aware_command_invocation_dumper.py +++ b/gersemi/command_invocation_dumpers/section_aware_command_invocation_dumper.py @@ -65,7 +65,6 @@ def _split_multi_value_argument(self, tree): return Tree("section", subarguments) def _split_arguments(self, arguments): - self.multi_value_keywords.extend(self.sections.keys()) preprocessed = super()._split_arguments(arguments) return [ ( diff --git a/tests/formatter/issue_0032_non_deterministic_formatting_set_tll.in.cmake b/tests/formatter/issue_0032_non_deterministic_formatting_set_tll.in.cmake new file mode 100644 index 0000000..e5d98ea --- /dev/null +++ b/tests/formatter/issue_0032_non_deterministic_formatting_set_tll.in.cmake @@ -0,0 +1,6 @@ +### {list_expansion: favour-expansion} +set(list_containing_keyword + PUBLIC + pthread ) + +target_link_libraries(unrelated PRIVATE pthread) diff --git a/tests/formatter/issue_0032_non_deterministic_formatting_set_tll.out.cmake b/tests/formatter/issue_0032_non_deterministic_formatting_set_tll.out.cmake new file mode 100644 index 0000000..27c7552 --- /dev/null +++ b/tests/formatter/issue_0032_non_deterministic_formatting_set_tll.out.cmake @@ -0,0 +1,6 @@ +set(list_containing_keyword + PUBLIC + pthread +) + +target_link_libraries(unrelated PRIVATE pthread) diff --git a/tests/formatter/issue_0032_non_deterministic_formatting_tll_set.in.cmake b/tests/formatter/issue_0032_non_deterministic_formatting_tll_set.in.cmake new file mode 100644 index 0000000..3c59788 --- /dev/null +++ b/tests/formatter/issue_0032_non_deterministic_formatting_tll_set.in.cmake @@ -0,0 +1,6 @@ +### {list_expansion: favour-expansion} +target_link_libraries(unrelated PRIVATE pthread) + +set(list_containing_keyword + PUBLIC + pthread ) diff --git a/tests/formatter/issue_0032_non_deterministic_formatting_tll_set.out.cmake b/tests/formatter/issue_0032_non_deterministic_formatting_tll_set.out.cmake new file mode 100644 index 0000000..c178404 --- /dev/null +++ b/tests/formatter/issue_0032_non_deterministic_formatting_tll_set.out.cmake @@ -0,0 +1,6 @@ +target_link_libraries(unrelated PRIVATE pthread) + +set(list_containing_keyword + PUBLIC + pthread +)