Merge "aconfig: reject consecutive underscores in identifiers"
diff --git a/core/Makefile b/core/Makefile
index 18ba59e..1814f98 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -5403,6 +5403,9 @@
 ifdef BOARD_PREBUILT_DTBOIMAGE
 	$(hide) echo "flash dtbo" >> $@
 endif
+ifneq ($(INSTALLED_DTIMAGE_TARGET),)
+	$(hide) echo "flash dts dt.img" >> $@
+endif
 ifneq ($(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
 	$(hide) echo "flash vendor_kernel_boot" >> $@
 endif
diff --git a/core/definitions.mk b/core/definitions.mk
index 7697211..be40584 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2941,7 +2941,7 @@
 define compress-package
 $(hide) \
   mv $@ $@.uncompressed; \
-  $(MINIGZIP) -c $@.uncompressed > $@.compressed; \
+  $(MINIGZIP) -9 -c $@.uncompressed > $@.compressed; \
   rm -f $@.uncompressed; \
   mv $@.compressed $@;
 endef
diff --git a/core/release_config.bzl b/core/release_config.bzl
index 1346508..805106f 100644
--- a/core/release_config.bzl
+++ b/core/release_config.bzl
@@ -88,6 +88,7 @@
                 partitions.setdefault(partition, []).append(flag["name"])
 
     # Validate values
+    # TODO(joeo): Disallow duplicate values after we've split AOSP and vendor flags.
     values = {}
     for value in all_values:
         if value["name"] not in flag_names:
diff --git a/core/release_config.mk b/core/release_config.mk
index 3cd8b41..1a2d480 100644
--- a/core/release_config.mk
+++ b/core/release_config.mk
@@ -16,6 +16,22 @@
 # -----------------------------------------------------------------
 # Choose the flag files
 # -----------------------------------------------------------------
+# Release configs are defined in reflease_config_map files, which map
+# the short name (e.g. -next) used in lunch to the starlark files
+# defining the build flag values.
+#
+# (If you're thinking about aconfig flags, there is one build flag,
+# RELEASE_DEVICE_CONFIG_VALUE_SETS, that sets which device_config_value_set
+# module to use to set the aconfig flag values.)
+#
+# The short release config names *can* appear multiple times, to allow
+# for AOSP and vendor specific flags under the same name, but the
+# individual flag values must appear in exactly one config.  Vendor
+# does not override AOSP, or anything like that.  This is because
+# vendor code usually includes prebuilts, and having vendor compile
+# with different flags from AOSP increases the likelihood of flag
+# mismatch.
+
 # Do this first, because we're going to unset TARGET_RELEASE before
 # including anyone, so they don't start making conditionals based on it.
 # This logic is in make because starlark doesn't understand optional
@@ -39,17 +55,12 @@
 # $1 config name
 # $2 release config files
 define declare-release-config
-    $(eval # No duplicates)
-    $(if $(filter $(_all_release_configs), $(strip $(1))), \
-        $(error declare-release-config: config $(strip $(1)) declared in: $(_included) Previously declared here: $(_all_release_configs.$(strip $(1)).DECLARED_IN)) \
-    )
-    $(eval # Must have release config files)
     $(if $(strip $(2)),,  \
         $(error declare-release-config: config $(strip $(1)) must have release config files) \
     )
     $(eval _all_release_configs := $(sort $(_all_release_configs) $(strip $(1))))
-    $(eval _all_release_configs.$(strip $(1)).DECLARED_IN := $(_included))
-    $(eval _all_release_configs.$(strip $(1)).FILES := $(strip $(2)))
+    $(eval _all_release_configs.$(strip $(1)).DECLARED_IN := $(_included) $(_all_release_configs.$(strip $(1)).DECLARED_IN))
+    $(eval _all_release_configs.$(strip $(1)).FILES := $(_all_release_configs.$(strip $(1)).FILES) $(strip $(2)))
 endef
 
 # Include the config map files