Skip to content

Commit b86e2b4

Browse files
Use the read_bool helper instead of custom implementation
Summary: The `read_bool` utility function handles the custom written functionality (which predates the helper being moved to prelude). Additionally, the helper guards against typos. 1. use the helper 2. set a default of `None`, and remove setting of the default in call sites 3. rename `_maybe_read_bool` to `_read_bool` Reviewed By: watwars Differential Revision: D90029218 fbshipit-source-id: 6f91d823925acfd42dd72979b0abe2d383f0d368
1 parent 9f32719 commit b86e2b4

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

prelude/apple/apple_bundle_config.bzl

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@
66
# of this source tree. You may select, at your option, one of the
77
# above-listed licenses.
88

9+
load("@prelude//utils:buckconfig.bzl", "read_bool")
910
load(":apple_code_signing_types.bzl", "CodeSignConfiguration")
1011

11-
def _maybe_get_bool(config: str, default: [None, bool]) -> [None, bool]:
12-
result = read_root_config("apple", config, None)
13-
if result == None:
14-
return default
15-
return result.lower() == "true"
12+
def _read_bool(config: str, default: [None, bool] = None) -> [None, bool]:
13+
return read_bool("apple", config, default = default, required = False, root_cell = True)
1614

1715
def _get_code_signing_configuration() -> str:
18-
is_dry_run = _maybe_get_bool("dry_run_code_signing", False)
16+
is_dry_run = _read_bool("dry_run_code_signing", False)
1917

2018
# This is a kill switch for the feature, it can also be disabled by setting
2119
# `apple.fast_adhoc_signing_enabled=false` in a global buckconfig file.
22-
is_fast_adhoc_signing_enabled = _maybe_get_bool("fast_adhoc_signing_enabled", True)
20+
is_fast_adhoc_signing_enabled = _read_bool("fast_adhoc_signing_enabled", True)
2321

24-
is_codesign_execution_bypass_enabled = _maybe_get_bool("codesign_execution_bypass", False)
22+
is_codesign_execution_bypass_enabled = _read_bool("codesign_execution_bypass", False)
2523
if is_dry_run and is_codesign_execution_bypass_enabled:
2624
fail("Dry run and execution bypass are mutually exclusive, pick one")
2725

@@ -39,18 +37,18 @@ def _get_code_signing_configuration() -> str:
3937
def apple_bundle_config() -> dict[str, typing.Any]:
4038
return {
4139
"_bundling_cache_buster": read_root_config("apple", "bundling_cache_buster", None),
42-
"_bundling_log_file_enabled": _maybe_get_bool("bundling_log_file_enabled", True),
40+
"_bundling_log_file_enabled": _read_bool("bundling_log_file_enabled", True),
4341
"_bundling_log_file_level": read_root_config("apple", "bundling_log_file_level", None),
4442
"_code_signing_configuration": _get_code_signing_configuration(),
4543
"_codesign_command_override": read_root_config("apple", "codesign_command_override", None),
4644
"_codesign_identities_command_override": read_root_config("apple", "codesign_identities_command_override", None),
4745
"_codesign_type": read_root_config("apple", "codesign_type_override", None),
48-
"_compile_resources_locally_override": _maybe_get_bool("compile_resources_locally_override", None),
49-
"_embed_provisioning_profile_when_adhoc_code_signing": _maybe_get_bool("embed_provisioning_profile_when_adhoc_code_signing", None),
50-
"_fast_provisioning_profile_parsing_enabled": _maybe_get_bool("fast_provisioning_profile_parsing_enabled", False),
51-
"_incremental_bundling_enabled": _maybe_get_bool("incremental_bundling_enabled", True),
52-
"_info_plist_identify_build_system_default": _maybe_get_bool("info_plist_identify_build_system", True),
53-
"_profile_bundling_enabled": _maybe_get_bool("profile_bundling_enabled", False),
54-
"_skip_adhoc_resigning_scrubbed_frameworks_override": _maybe_get_bool("skip_adhoc_resigning_scrubbed_frameworks_override", None),
55-
"_use_entitlements_when_adhoc_code_signing": _maybe_get_bool("use_entitlements_when_adhoc_code_signing", None),
46+
"_compile_resources_locally_override": _read_bool("compile_resources_locally_override"),
47+
"_embed_provisioning_profile_when_adhoc_code_signing": _read_bool("embed_provisioning_profile_when_adhoc_code_signing"),
48+
"_fast_provisioning_profile_parsing_enabled": _read_bool("fast_provisioning_profile_parsing_enabled", False),
49+
"_incremental_bundling_enabled": _read_bool("incremental_bundling_enabled", True),
50+
"_info_plist_identify_build_system_default": _read_bool("info_plist_identify_build_system", True),
51+
"_profile_bundling_enabled": _read_bool("profile_bundling_enabled", False),
52+
"_skip_adhoc_resigning_scrubbed_frameworks_override": _read_bool("skip_adhoc_resigning_scrubbed_frameworks_override"),
53+
"_use_entitlements_when_adhoc_code_signing": _read_bool("use_entitlements_when_adhoc_code_signing"),
5654
}

0 commit comments

Comments
 (0)