|
|
|
@ -111,13 +111,13 @@ def help_line(left, opt, indent, long): |
|
|
|
right = f'{opt["description"]}' |
|
|
|
if long: |
|
|
|
value = get_help(opt) |
|
|
|
if value != "auto" and value != "": |
|
|
|
if value not in {"", "auto"}: |
|
|
|
right += f" [{value}]" |
|
|
|
if "choices" in opt and long: |
|
|
|
choices = "/".join(sorted(opt["choices"])) |
|
|
|
right += f" (choices: {choices})" |
|
|
|
for x in wrap(" " + left, right, indent): |
|
|
|
sh_print(x) |
|
|
|
for line in wrap(" " + left, right, indent): |
|
|
|
sh_print(line) |
|
|
|
|
|
|
|
|
|
|
|
# Return whether the option (a dictionary) can be used with |
|
|
|
@ -144,18 +144,18 @@ def require_arg(opt): |
|
|
|
return not ({"enabled", "disabled"}.intersection(opt["choices"])) |
|
|
|
|
|
|
|
|
|
|
|
def filter_options(json): |
|
|
|
if ":" in json["name"]: |
|
|
|
def filter_options(opt): |
|
|
|
if ":" in opt["name"]: |
|
|
|
return False |
|
|
|
if json["section"] == "user": |
|
|
|
return json["name"] not in SKIP_OPTIONS |
|
|
|
if opt["section"] == "user": |
|
|
|
return opt["name"] not in SKIP_OPTIONS |
|
|
|
else: |
|
|
|
return json["name"] in BUILTIN_OPTIONS |
|
|
|
return opt["name"] in BUILTIN_OPTIONS |
|
|
|
|
|
|
|
|
|
|
|
def load_options(json): |
|
|
|
json = [x for x in json if filter_options(x)] |
|
|
|
return sorted(json, key=lambda x: x["name"]) |
|
|
|
def load_options(opts): |
|
|
|
opts = [opt for opt in opts if filter_options(opt)] |
|
|
|
return sorted(opts, key=lambda opt: opt["name"]) |
|
|
|
|
|
|
|
|
|
|
|
def cli_option(opt): |
|
|
|
@ -223,7 +223,7 @@ def print_parse(options): |
|
|
|
key = cli_option(opt) |
|
|
|
name = opt["name"] |
|
|
|
if require_arg(opt): |
|
|
|
if opt["type"] == "array" and not "choices" in opt: |
|
|
|
if opt["type"] == "array" and "choices" not in opt: |
|
|
|
print(f' --{key}=*) quote_sh "-D{name}=$(meson_option_build_array $2)" ;;') |
|
|
|
else: |
|
|
|
print(f' --{key}=*) quote_sh "-D{name}=$2" ;;') |
|
|
|
@ -241,14 +241,19 @@ def print_parse(options): |
|
|
|
print(" esac") |
|
|
|
print("}") |
|
|
|
|
|
|
|
json_data = sys.stdin.read() |
|
|
|
try: |
|
|
|
options = load_options(json.loads(json_data)) |
|
|
|
except: |
|
|
|
print("Failure in scripts/meson-buildoptions.py parsing stdin as json", |
|
|
|
file=sys.stderr) |
|
|
|
print(json_data, file=sys.stderr) |
|
|
|
sys.exit(1) |
|
|
|
print("# This file is generated by meson-buildoptions.py, do not edit!") |
|
|
|
print_help(options) |
|
|
|
print_parse(options) |
|
|
|
|
|
|
|
def main(): |
|
|
|
json_data = sys.stdin.read() |
|
|
|
try: |
|
|
|
options = load_options(json.loads(json_data)) |
|
|
|
except: |
|
|
|
print("Failure in scripts/meson-buildoptions.py parsing stdin as json", |
|
|
|
file=sys.stderr) |
|
|
|
print(json_data, file=sys.stderr) |
|
|
|
sys.exit(1) |
|
|
|
print("# This file is generated by meson-buildoptions.py, do not edit!") |
|
|
|
print_help(options) |
|
|
|
print_parse(options) |
|
|
|
|
|
|
|
|
|
|
|
sys.exit(main()) |
|
|
|
|