Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e8bb798 authored by Cole Faust's avatar Cole Faust
Browse files

Add artifact path requirement support to Starlark

Artifact path requirements requires setting some new variables,
and also dumping the state of the product config variables
after evaluating partial products that set artifact path requirements.

Bug: 188079133
Test: Removed the code that disabled artifacts path requirements from the rbc dashboard script,
      and verified that it was still green for aosp_arm64
Change-Id: I228e35285d788f4c83aa695c0f28b7c7db02544c
parent 04727303
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1351,7 +1351,7 @@ else ifdef FULL_BUILD

  # Verify the artifact path requirements made by included products.
  is_asan := $(if $(filter address,$(SANITIZE_TARGET)),true)
  ifeq (,$(or $(is_asan),$(DISABLE_ARTIFACT_PATH_REQUIREMENTS),$(RBC_PRODUCT_CONFIG),$(RBC_BOARD_CONFIG)))
  ifeq (,$(or $(is_asan),$(DISABLE_ARTIFACT_PATH_REQUIREMENTS)))
    include $(BUILD_SYSTEM)/artifact_path_requirements.mk
  endif
else
+4 −1
Original line number Diff line number Diff line
@@ -263,7 +263,10 @@ endif # Import all or just the current product makefile
# Quick check
$(check-all-products)

ifeq ($(SKIP_ARTIFACT_PATH_REQUIREMENT_PRODUCTS_CHECK),)
# This step was already handled in the RBC product configuration.
# Since the equivalent starlark code will not add the partial products to
# the PRODUCTS variable, it's ok for them to be set before check-all-products
ifeq ($(RBC_PRODUCT_CONFIG)$(SKIP_ARTIFACT_PATH_REQUIREMENT_PRODUCTS_CHECK),)
# Import all the products that have made artifact path requirements, so that we can verify
# the artifacts they produce.
# These are imported after check-all-products because some of them might not be real products.
+26 −8
Original line number Diff line number Diff line
@@ -157,6 +157,13 @@ def _product_configuration(top_pcm_name, top_pcm, input_variables_init):
        handle = __h_new()
        pcm(globals, handle)

        if handle.artifact_path_requirements:
            globals["PRODUCTS."+name+".mk.ARTIFACT_PATH_REQUIREMENTS"] = handle.artifact_path_requirements
            globals["PRODUCTS."+name+".mk.ARTIFACT_PATH_ALLOWED_LIST"] = handle.artifact_path_allowed_list
            globals["PRODUCTS."+name+".mk.ARTIFACT_PATH_REQUIREMENT_IS_RELAXED"] = "true" if handle.artifact_path_requirement_is_relaxed[0] else ""
            globals.setdefault("ARTIFACT_PATH_REQUIREMENT_PRODUCTS", [])
            globals["ARTIFACT_PATH_REQUIREMENT_PRODUCTS"] += [name+".mk"]

        # Now we know everything about this PCM, record it in 'configs'.
        children = handle.inherited_modules
        if _options.trace_modules:
@@ -211,6 +218,10 @@ def _product_configuration(top_pcm_name, top_pcm, input_variables_init):
        _percolate_inherited(configs, pcm_name, cfg, children_names)
        configs[pcm_name] = pcm, cfg, children_names, True

        if (pcm_name + ".mk") in globals.get("ARTIFACT_PATH_REQUIREMENT_PRODUCTS", []):
            for var, val in cfg.items():
                globals["PRODUCTS."+pcm_name+".mk."+var] = val

    # Copy product config variables from the cfg dictionary to the
    # PRODUCTS.<top_level_makefile_name>.<var_name> global variables.
    for var, val in configs[top_pcm_name][1].items():
@@ -419,7 +430,10 @@ def __h_new():
    return struct(
        cfg = dict(),
        inherited_modules = dict(),
        default_list_value = list()
        default_list_value = list(),
        artifact_path_requirements = list(),
        artifact_path_allowed_list = list(),
        artifact_path_requirement_is_relaxed = [False], # as a list so that we can reassign it
    )

def __h_cfg(handle):
@@ -564,13 +578,17 @@ def _notdir(paths):
    """
    return " ".join([__base(w) for w in __words(paths)])

def _require_artifacts_in_path(paths, allowed_paths):
    """TODO."""
    pass

def _require_artifacts_in_path_relaxed(paths, allowed_paths):
    """TODO."""
    pass
def _require_artifacts_in_path(handle, paths, allowed_paths):
    """Equivalent to require-artifacts-in-path in Make."""
    handle.artifact_path_requirements.clear()
    handle.artifact_path_requirements.extend(__words(paths))
    handle.artifact_path_allowed_list.clear()
    handle.artifact_path_allowed_list.extend(__words(allowed_paths))

def _require_artifacts_in_path_relaxed(handle, paths, allowed_paths):
    """Equivalent to require-artifacts-in-path-relaxed in Make."""
    _require_artifacts_in_path(handle, paths, allowed_paths)
    handle.artifact_path_requirement_is_relaxed[0] = True

def _expand_wildcard(pattern):
    """Expands shell wildcard pattern."""