|
21 | 21 | from cachecontrol.caches import FileCache
|
22 | 22 |
|
23 | 23 | from lib.amazon import list_compilers, list_s3_artifacts
|
| 24 | +from lib.config_expand import is_value_type, expand_target |
24 | 25 | from lib.config_safe_loader import ConfigSafeLoader
|
25 | 26 | from lib.library_build_config import LibraryBuildConfig
|
26 | 27 | from lib.library_builder import LibraryBuilder
|
27 | 28 |
|
28 | 29 | VERSIONED_RE = re.compile(r'^(.*)-([0-9.]+)$')
|
29 | 30 |
|
30 |
| -MAX_ITERS = 5 |
31 |
| - |
32 | 31 | NO_DEFAULT = "__no_default__"
|
33 | 32 |
|
34 | 33 | logger = logging.getLogger(__name__)
|
@@ -685,6 +684,9 @@ def __init__(self, install_context: InstallationContext, config: Dict[str, Any])
|
685 | 684 | strip_components = self.config_get("strip_components", 0)
|
686 | 685 | if strip_components:
|
687 | 686 | self.tar_cmd += ['--strip-components', str(strip_components)]
|
| 687 | + extract_only = self.config_get("extract_only", "") |
| 688 | + if extract_only: |
| 689 | + self.tar_cmd += [extract_only] |
688 | 690 | self.strip = self.config_get('strip', False)
|
689 | 691 | self._setup_check_exe(self.install_path)
|
690 | 692 | if self.install_path_symlink:
|
@@ -862,36 +864,6 @@ def targets_from(node, enabled, base_config=None):
|
862 | 864 | return _targets_from(node, enabled, [], "", base_config)
|
863 | 865 |
|
864 | 866 |
|
865 |
| -def is_list_of_strings(value: Any) -> bool: |
866 |
| - return isinstance(value, list) and all(isinstance(x, str) for x in value) |
867 |
| - |
868 |
| - |
869 |
| -# dear god it's late and this can't really be sensible, right? |
870 |
| -def is_list_of_strings_or_lists(value: Any) -> bool: |
871 |
| - return isinstance(value, list) and all(isinstance(x, str) or is_list_of_strings_or_lists(x) for x in value) |
872 |
| - |
873 |
| - |
874 |
| -def is_value_type(value: Any) -> bool: |
875 |
| - return isinstance(value, str) \ |
876 |
| - or isinstance(value, bool) \ |
877 |
| - or isinstance(value, float) \ |
878 |
| - or isinstance(value, int) \ |
879 |
| - or is_list_of_strings(value) \ |
880 |
| - or is_list_of_strings_or_lists(value) |
881 |
| - |
882 |
| - |
883 |
| -def needs_expansion(target): |
884 |
| - for value in target.values(): |
885 |
| - if is_list_of_strings(value): |
886 |
| - for v in value: |
887 |
| - if '{' in v: |
888 |
| - return True |
889 |
| - elif isinstance(value, str): |
890 |
| - if '{' in value: |
891 |
| - return True |
892 |
| - return False |
893 |
| - |
894 |
| - |
895 | 867 | def _targets_from(node, enabled, context, name, base_config):
|
896 | 868 | if not node:
|
897 | 869 | return
|
@@ -932,23 +904,7 @@ def _targets_from(node, enabled, context, name, base_config):
|
932 | 904 | raise RuntimeError(f"Target {target} was parsed as a float. Enclose in quotes")
|
933 | 905 | if isinstance(target, str):
|
934 | 906 | target = {'name': target}
|
935 |
| - target = ChainMap(target, base_config) |
936 |
| - iterations = 0 |
937 |
| - while needs_expansion(target): |
938 |
| - iterations += 1 |
939 |
| - if iterations > MAX_ITERS: |
940 |
| - raise RuntimeError(f"Too many mutual references (in {'/'.join(context)})") |
941 |
| - for key, value in target.items(): |
942 |
| - try: |
943 |
| - if is_list_of_strings(value): |
944 |
| - target[key] = [x.format(**target) for x in value] |
945 |
| - elif isinstance(value, str): |
946 |
| - target[key] = value.format(**target) |
947 |
| - elif isinstance(value, float): |
948 |
| - target[key] = str(value) |
949 |
| - except KeyError as ke: |
950 |
| - raise RuntimeError(f"Unable to find key {ke} in {target[key]} (in {'/'.join(context)})") from ke |
951 |
| - yield target |
| 907 | + yield expand_target(ChainMap(target, base_config), context) |
952 | 908 |
|
953 | 909 |
|
954 | 910 | INSTALLER_TYPES = {
|
|
0 commit comments