From e379af626325b9aa96d7fe2a7fb51a17f49ed8a7 Mon Sep 17 00:00:00 2001 From: inferno0230 Date: Thu, 27 Aug 2026 03:40:37 +0530 Subject: [PATCH] core: Show all conflicting rules in one go Signed-off-by: inferno0230 --- core/base_rules.mk | 6 ++++-- core/main.mk | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/base_rules.mk b/core/base_rules.mk index a736ea48a4..c3105e15f8 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -317,9 +317,11 @@ endif module_id := MODULE.$(if \ $(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),TARGET).$(LOCAL_MODULE_CLASS).$(my_register_name) ifdef $(module_id) -$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id))) -endif +duplicate_module_ids := $(duplicate_module_ids) $(module_id) +duplicate_module_paths.$(module_id) := $(duplicate_module_paths.$(module_id)) $(LOCAL_PATH) +else $(module_id) := $(LOCAL_PATH) +endif # These are the same as local-intermediates-dir / local-generated-sources dir, but faster intermediates.COMMON := $($(my_prefix)OUT_COMMON_INTERMEDIATES)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates diff --git a/core/main.mk b/core/main.mk index 09639aba7c..a9fc7864bc 100644 --- a/core/main.mk +++ b/core/main.mk @@ -315,6 +315,15 @@ define pretty-error $(error $(1)) endef +# Report duplicate module definitions together instead of stopping at the first +# one encountered while including module makefiles. +ifneq ($(strip $(duplicate_module_ids)),) +$(foreach m,$(sort $(duplicate_module_ids)), \ + $(foreach p,$(sort $(duplicate_module_paths.$(m))), \ + $(warning $(p): $(m) already defined by $($(m))))) +$(error Found $(words $(duplicate_module_ids)) duplicate module definition(s)) +endif + # ------------------------------------------------------------------- # Enforce to generate all RRO packages for modules having resource # overlays. -- 2.55.0