Skip to content

Commit 6c99946

Browse files
authored
Add --preset-vars-file to build-script for easier preset vars handling (#76058)
It's not always convenient to pass preset substitution arguments on an interactive command-line. Sometimes one might also need to generate these vars automatically, outside of a `build-script` invocation and also store those vars in a file for later reuse. This change adds a new optional `--preset-vars-file` customization point to `build-script`, which allows users to pass a a file with newline separated key-value pars for preset variables substitution in addition to passing those in a direct `build-script` invocation.
1 parent 2b1fb8b commit 6c99946

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

utils/build-script

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,13 @@ def parse_preset_args():
495495
help="list all presets and exit",
496496
action=argparse.actions.StoreTrueAction,
497497
nargs=argparse.Nargs.OPTIONAL)
498+
parser.add_argument(
499+
"--preset-vars-file",
500+
help="load preset vars from the specified file",
501+
metavar="PATH",
502+
action="append",
503+
dest="preset_vars_file_names",
504+
default=[])
498505
parser.add_argument(
499506
"--distcc",
500507
help="use distcc",
@@ -589,6 +596,13 @@ def main_preset():
589596
fatal_error("missing --preset option")
590597

591598
args.preset_substitutions = {}
599+
for file in args.preset_vars_file_names:
600+
if os.path.isfile(file):
601+
with open(file, 'r') as f:
602+
for _, line in enumerate(f):
603+
name, value = line.split("=", 1)
604+
args.preset_substitutions[name] = value
605+
592606
for arg in args.preset_substitutions_raw:
593607
name, value = arg.split("=", 1)
594608
args.preset_substitutions[name] = value

0 commit comments

Comments
 (0)