Skip to content

Commit

Permalink
Improve consistency of target_link_libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
BlankSpruce committed Jun 29, 2024
1 parent 30f8876 commit 8a16a2e
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 88 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog
## [0.13.4] 2024-06-29
### Fixed
- improve consistency of `target_link_libraries`

## [0.13.3] 2024-06-15
### Added
- support for new keywords in native commands available in CMake 3.30
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.3
rev: 0.13.4
hooks:
- id: gersemi
```
Expand Down
2 changes: 1 addition & 1 deletion gersemi/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
__license__ = "MPL 2.0"
__title__ = "gersemi"
__url__ = "https://github.com/BlankSpruce/gersemi"
__version__ = "0.13.3"
__version__ = "0.13.4"
30 changes: 28 additions & 2 deletions gersemi/command_invocation_dumpers/project_command_dumpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import Iterable, List, Mapping
from gersemi.command_line_formatter import CommandLineFormatter
from gersemi.keyword_with_pairs_formatter import KeywordWithPairsFormatter
from gersemi.keywords import AnyMatcher, KeywordMatcher
Expand All @@ -9,7 +9,6 @@
MultipleSignatureCommandInvocationDumper,
)
from .section_aware_command_invocation_dumper import SectionAwareCommandInvocationDumper
from .target_link_libraries_command_dumper import TargetLinkLibraries
from .two_word_keyword_isolator import TwoWordKeywordIsolator


Expand Down Expand Up @@ -456,6 +455,33 @@ class TargetLinkDirectories(ArgumentAwareCommandInvocationDumper):
multi_value_keywords = ["INTERFACE", "PUBLIC", "PRIVATE"]


_debug_optimized_general: Mapping[KeywordMatcher, Iterable[KeywordMatcher]] = {
"one_value_keywords": ["debug", "optimized", "general"]
}


class TargetLinkLibraries(
SectionAwareCommandInvocationDumper, ArgumentAwareCommandInvocationDumper
):
front_positional_arguments = ["<target>"]
multi_value_keywords = [
"INTERFACE",
"PUBLIC",
"PRIVATE",
"LINK_PRIVATE",
"LINK_PUBLIC",
"LINK_INTERFACE_LIBRARIES",
]
sections = {
"INTERFACE": _debug_optimized_general,
"PUBLIC": _debug_optimized_general,
"PRIVATE": _debug_optimized_general,
"LINK_PRIVATE": _debug_optimized_general,
"LINK_PUBLIC": _debug_optimized_general,
"LINK_INTERFACE_LIBRARIES": _debug_optimized_general,
}


class TargetLinkOptions(ArgumentAwareCommandInvocationDumper):
front_positional_arguments = ["<target>"]
options = ["BEFORE"]
Expand Down

This file was deleted.

4 changes: 3 additions & 1 deletion tests/formatter/target_link_libraries_command.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ target_link_libraries(long_arg__________________________________________________

target_link_libraries(long_arg____________________________________________________________ PUBLIC debug long_arg____________________________________________________________ optimized long_arg____________________________________________________________ general long_arg____________________________________________________________)

target_link_libraries(long_arg____________________________________________________________ PUBLIC long_arg____________________________________________________________ debug long_arg____________________________________________________________ optimized long_arg____________________________________________________________ long_arg____________________________________________________________ general long_arg____________________________________________________________ PRIVATE long_arg____________________________________________________________ debug long_arg____________________________________________________________ optimized long_arg____________________________________________________________ long_arg____________________________________________________________ general long_arg____________________________________________________________ long_arg____________________________________________________________ INTERFACE long_arg____________________________________________________________ debug long_arg____________________________________________________________ optimized long_arg____________________________________________________________ long_arg____________________________________________________________ general long_arg____________________________________________________________ long_arg____________________________________________________________)
target_link_libraries(long_arg____________________________________________________________ PUBLIC long_arg____________________________________________________________ debug long_arg____________________________________________________________ optimized long_arg____________________________________________________________ long_arg____________________________________________________________ general long_arg____________________________________________________________ PRIVATE long_arg____________________________________________________________ debug long_arg____________________________________________________________ optimized long_arg____________________________________________________________ long_arg____________________________________________________________ general long_arg____________________________________________________________ long_arg____________________________________________________________ INTERFACE long_arg____________________________________________________________ debug long_arg____________________________________________________________ optimized long_arg____________________________________________________________ long_arg____________________________________________________________ general long_arg____________________________________________________________ long_arg____________________________________________________________)

target_link_libraries(TGT PUBLIC debug foo optimized long_arg____________________________________________________________ general foo debug long_arg__________________________________________________________)
82 changes: 58 additions & 24 deletions tests/formatter/target_link_libraries_command.out.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,32 +115,44 @@ target_link_libraries(
target_link_libraries(
TGT
PUBLIC
debug long_arg____________________________________________________________
optimized long_arg____________________________________________________________
general long_arg____________________________________________________________
debug
long_arg____________________________________________________________
optimized
long_arg____________________________________________________________
general
long_arg____________________________________________________________
)

target_link_libraries(
TGT
PUBLIC
long_arg____________________________________________________________
debug long_arg____________________________________________________________
optimized long_arg____________________________________________________________
debug
long_arg____________________________________________________________
optimized
long_arg____________________________________________________________
long_arg____________________________________________________________
general long_arg____________________________________________________________
general
long_arg____________________________________________________________
PRIVATE
long_arg____________________________________________________________
debug long_arg____________________________________________________________
optimized long_arg____________________________________________________________
debug
long_arg____________________________________________________________
optimized
long_arg____________________________________________________________
long_arg____________________________________________________________
general long_arg____________________________________________________________
general
long_arg____________________________________________________________
long_arg____________________________________________________________
INTERFACE
long_arg____________________________________________________________
debug long_arg____________________________________________________________
optimized long_arg____________________________________________________________
debug
long_arg____________________________________________________________
optimized
long_arg____________________________________________________________
long_arg____________________________________________________________
general long_arg____________________________________________________________
general
long_arg____________________________________________________________
long_arg____________________________________________________________
)

Expand Down Expand Up @@ -224,31 +236,53 @@ target_link_libraries(
target_link_libraries(
long_arg____________________________________________________________
PUBLIC
debug long_arg____________________________________________________________
optimized long_arg____________________________________________________________
general long_arg____________________________________________________________
debug
long_arg____________________________________________________________
optimized
long_arg____________________________________________________________
general
long_arg____________________________________________________________
)

target_link_libraries(
long_arg____________________________________________________________
PUBLIC
long_arg____________________________________________________________
debug long_arg____________________________________________________________
optimized long_arg____________________________________________________________
debug
long_arg____________________________________________________________
optimized
long_arg____________________________________________________________
long_arg____________________________________________________________
general long_arg____________________________________________________________
general
long_arg____________________________________________________________
PRIVATE
long_arg____________________________________________________________
debug long_arg____________________________________________________________
optimized long_arg____________________________________________________________
debug
long_arg____________________________________________________________
optimized
long_arg____________________________________________________________
long_arg____________________________________________________________
general long_arg____________________________________________________________
general
long_arg____________________________________________________________
long_arg____________________________________________________________
INTERFACE
long_arg____________________________________________________________
debug long_arg____________________________________________________________
optimized long_arg____________________________________________________________
debug
long_arg____________________________________________________________
optimized
long_arg____________________________________________________________
long_arg____________________________________________________________
general long_arg____________________________________________________________
general
long_arg____________________________________________________________
long_arg____________________________________________________________
)

target_link_libraries(
TGT
PUBLIC
debug foo
optimized
long_arg____________________________________________________________
general foo
debug long_arg__________________________________________________________
)

0 comments on commit 8a16a2e

Please sign in to comment.