Merge changes Ib89ef776,I5cdc56c7
* changes:
Disable required modules check on darwin
Require required modules to exist
diff --git a/Changes.md b/Changes.md
index 3109e9b..84c8d95 100644
--- a/Changes.md
+++ b/Changes.md
@@ -1,5 +1,15 @@
# Build System Changes for Android.mk Writers
+## `LOCAL_REQUIRED_MODULES` requires listed modules to exist {#BUILD_BROKEN_MISSING_REQUIRED_MODULES}
+
+Modules listed in `LOCAL_REQUIRED_MODULES`, `LOCAL_HOST_REQUIRED_MODULES` and
+`LOCAL_TARGET_REQUIRED_MODULES` need to exist unless `ALLOW_MISSING_DEPENDENCIES`
+is set.
+
+To temporarily relax missing required modules check, use:
+
+`BUILD_BROKEN_MISSING_REQUIRED_MODULES := true`
+
## Changes in system properties settings
### Product variables
diff --git a/core/board_config.mk b/core/board_config.mk
index 391e280..b7d0178 100644
--- a/core/board_config.mk
+++ b/core/board_config.mk
@@ -98,13 +98,14 @@
_build_broken_var_list := \
BUILD_BROKEN_DUP_RULES \
+ BUILD_BROKEN_DUP_SYSPROP \
BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES \
+ BUILD_BROKEN_MISSING_REQUIRED_MODULES \
BUILD_BROKEN_OUTSIDE_INCLUDE_DIRS \
BUILD_BROKEN_PREBUILT_ELF_FILES \
BUILD_BROKEN_TREBLE_SYSPROP_NEVERALLOW \
BUILD_BROKEN_USES_NETWORK \
BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES \
- BUILD_BROKEN_DUP_SYSPROP \
_build_broken_var_list += \
$(foreach m,$(AVAILABLE_BUILD_MODULE_TYPES) \
diff --git a/core/main.mk b/core/main.mk
index fdb2550..83bbac4 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -623,7 +623,6 @@
)
endef
-# TODO(b/7456955): error if a required module doesn't exist.
# Resolve the required module names to 32-bit or 64-bit variant for:
# ALL_MODULES.<*>.REQUIRED_FROM_TARGET
# ALL_MODULES.<*>.REQUIRED_FROM_HOST
@@ -656,7 +655,8 @@
$(if $(and $(module_is_native),$(required_is_shared_library_or_native_test)), \
$(if $(ALL_MODULES.$(m).FOR_2ND_ARCH),$(r_i_2nd),$(r_i)), \
$(r_i) $(r_i_2nd)))) \
- $(eval ### TODO(b/7456955): error if r_m is empty / does not exist) \
+ $(eval r_m := $(foreach r_j,$(r_m),$(if $(ALL_MODULES.$(r_j).PATH),$(r_j)))) \
+ $(if $(r_m),,$(eval _nonexistent_required += $(1)$(comma)$(m)$(comma)$(1)$(comma)$(r_i))) \
$(r_m))) \
$(eval ALL_MODULES.$(m).REQUIRED_FROM_$(1) := $(sort $(r_r))) \
) \
@@ -679,18 +679,37 @@
$(eval r_r := \
$(foreach r_i,$(r), \
$(eval r_m := $(call resolve-bitness-for-modules,$(1),$(r_i))) \
- $(eval ### TODO(b/7456955): error if r_m is empty / does not exist) \
+ $(eval r_m := $(foreach r_j,$(r_m),$(if $(ALL_MODULES.$(r_j).PATH),$(r_j)))) \
+ $(if $(r_m),,$(eval _nonexistent_required += $(2)$(comma)$(m)$(comma)$(1)$(comma)$(r_i))) \
$(r_m))) \
$(eval ALL_MODULES.$(m).$(1)_REQUIRED_FROM_$(2) := $(sort $(r_r))) \
) \
)
endef
+_nonexistent_required :=
$(call select-bitness-of-required-modules,TARGET)
$(call select-bitness-of-required-modules,HOST)
$(call select-bitness-of-required-modules,HOST_CROSS)
$(call select-bitness-of-target-host-required-modules,TARGET,HOST)
$(call select-bitness-of-target-host-required-modules,HOST,TARGET)
+_nonexistent_required := $(sort $(_nonexistent_required))
+
+# HOST OS darwin build is broken, disable this check for darwin for now.
+# TODO(b/162102724): Remove this
+ifeq (,$(filter $(HOST_OS),darwin))
+ifeq (,$(filter true,$(ALLOW_MISSING_DEPENDENCIES) $(BUILD_BROKEN_MISSING_REQUIRED_MODULES)))
+ifneq (,$(_nonexistent_required))
+ $(warning Missing required dependencies:)
+ $(foreach r_i,$(_nonexistent_required), \
+ $(eval r := $(subst $(comma),$(space),$(r_i))) \
+ $(info $(word 1,$(r)) module $(word 2,$(r)) requires non-existent $(word 3,$(r)) module: $(word 4,$(r))) \
+ )
+ $(warning Set BUILD_BROKEN_MISSING_REQUIRED_MODULES := true to bypass this check if this is intentional)
+ $(error Build failed)
+endif # _nonexistent_required != empty
+endif # ALLOW_MISSING_DEPENDENCIES != true && BUILD_BROKEN_MISSING_REQUIRED_MODULES != true
+endif # HOST_OS != darwin
define add-required-deps
$(1): | $(2)