_makefile¶
rhiza_hooks._makefile
¶
Read the targets a repository's makefiles define.
Two hooks need this: check_makefile_targets asks whether the recommended
targets are present, and check_workflow_make_targets asks whether every target
CI invokes exists. Both questions start from the same parse, so the parser lives
here rather than in either hook.
The placement is deliberate. A console script's public surface is its main();
when one entrypoint imports a helper out of another, the dependency between the two
CLIs is invisible from either one's interface, and a change made for the sake of one
hook's command line silently reaches the other. A _-prefixed leaf module states
the shared part explicitly and imports nothing from the package.
collect_targets(repo_root)
¶
Return every target defined by the root Makefile and its includes, transitively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_root
|
Path
|
Root directory of the repository. |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
Set of target names. Empty when there is no Makefile at all. |
Source code in rhiza_hooks/_makefile.py
extract_targets(content)
¶
Extract target names from Makefile content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
Contents of a Makefile |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
Set of target names found |