-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.5.0 - Automatic build regeneration support
- Loading branch information
Showing
22 changed files
with
209 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
major: 2 | ||
minor: 4 | ||
patch: 2 | ||
minor: 5 | ||
patch: 0 | ||
entry: mbs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
Test the 'commands.compile_config' module. | ||
""" | ||
|
||
# internal | ||
from tests.resources import resource | ||
|
||
# module under test | ||
from yambs import PKG_NAME | ||
from yambs.entry import main as yambs_main | ||
|
||
|
||
def test_compile_config_command_basic(): | ||
"""Test the 'compile_config' command.""" | ||
|
||
base = [ | ||
PKG_NAME, | ||
"compile_config", | ||
str(resource("compile_config_out.json")), | ||
] | ||
|
||
in1 = str(resource("compile_config_in1.yaml")) | ||
|
||
assert yambs_main(base + [in1]) == 0 | ||
assert yambs_main(base + ["-e", in1]) == 0 | ||
assert yambs_main(base + ["-e", "-u", in1]) == 0 | ||
assert yambs_main(base + ["-u", in1]) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
a: 1 | ||
b: 2 | ||
c: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
d: 4 | ||
e: 5 | ||
f: 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"a": 1, | ||
"b": 2, | ||
"c": 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
""" | ||
An entry-point for the 'compile_config' command. | ||
""" | ||
|
||
# built-in | ||
from argparse import ArgumentParser as _ArgumentParser | ||
from argparse import Namespace as _Namespace | ||
from pathlib import Path | ||
|
||
# third-party | ||
from vcorelib.args import CommandFunction as _CommandFunction | ||
from vcorelib.dict import MergeStrategy, merge_dicts | ||
from vcorelib.io import ARBITER, DEFAULT_INCLUDES_KEY | ||
|
||
|
||
def compile_config_cmd(args: _Namespace) -> int: | ||
"""Execute the compile_config command.""" | ||
|
||
merge_strat = MergeStrategy.RECURSIVE | ||
if args.update: | ||
merge_strat = MergeStrategy.UPDATE | ||
|
||
return ( | ||
0 | ||
if ARBITER.encode( | ||
args.output, | ||
merge_dicts( | ||
[ | ||
ARBITER.decode( | ||
file, | ||
require_success=True, | ||
includes_key=args.includes_key, | ||
expect_overwrite=args.expect_overwrite, | ||
strategy=merge_strat, | ||
).data | ||
for file in args.inputs | ||
], | ||
expect_overwrite=args.expect_overwrite, | ||
strategy=merge_strat, | ||
), | ||
)[0] | ||
else 1 | ||
) | ||
|
||
|
||
def add_compile_config_cmd(parser: _ArgumentParser) -> _CommandFunction: | ||
"""Add dist-command arguments to its parser.""" | ||
|
||
parser.add_argument( | ||
"-i", | ||
"--includes-key", | ||
default=DEFAULT_INCLUDES_KEY, | ||
help="top-level key to use for included files (default: %(default)s)", | ||
) | ||
|
||
parser.add_argument( | ||
"-u", | ||
"--update", | ||
action="store_true", | ||
help=( | ||
"whether or not to use the 'update' merge strategy " | ||
"(instead of 'recursive')" | ||
), | ||
) | ||
|
||
parser.add_argument( | ||
"-e", | ||
"--expect-overwrite", | ||
action="store_true", | ||
help="allow configuration files to overwrite data when loaded", | ||
) | ||
|
||
parser.add_argument("output", type=Path, help="file to write") | ||
parser.add_argument("inputs", nargs="+", type=Path, help="files to read") | ||
|
||
return compile_config_cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
rule compile_commands | ||
command = ninja -t compdb > compile_commands.json | ||
build compdb: compile_commands | ||
build compdb: compile_commands | regen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
############################################################################### | ||
|
||
# regeneration logic | ||
|
||
rule compile_config | ||
command = {{entry}} compile_config $out $in | ||
|
||
build $include_dir/compiled_config.json: compile_config {{config_file}} | ||
build check_config: phony $include_dir/compiled_config.json | ||
|
||
rule native | ||
command = {{entry}} native -n -c $in | ||
|
||
build | build.ninja: native {{config_file}} | check_config | ||
build regen: phony build.ninja | ||
|
||
############################################################################### |
Oops, something went wrong.