Merge "Remove embedded.mk"
diff --git a/Changes.md b/Changes.md
index b92342e..21a0abe 100644
--- a/Changes.md
+++ b/Changes.md
@@ -1,11 +1,57 @@
# Build System Changes for Android.mk Writers
+## Removing '/' from Valid Module Names {#name_slash}
+
+The build system uses module names in path names in many places. Having an
+extra '/' or '../' being inserted can cause problems -- and not just build
+breaks, but stranger invalid behavior.
+
+In every case we've seen, the fix is relatively simple: move the directory into
+`LOCAL_MODULE_RELATIVE_PATH` (or `LOCAL_MODULE_PATH` if you're still using it).
+If this causes multiple modules to be named the same, use unique module names
+and `LOCAL_MODULE_STEM` to change the installed file name:
+
+``` make
+include $(CLEAR_VARS)
+LOCAL_MODULE := ver1/code.bin
+LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/firmware
+...
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := ver2/code.bin
+LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/firmware
+...
+include $(BUILD_PREBUILT)
+```
+
+Can be rewritten as:
+
+```
+include $(CLEAR_VARS)
+LOCAL_MODULE := ver1_code.bin
+LOCAL_MODULE_STEM := code.bin
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/firmware/ver1
+...
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := ver2_code.bin
+LOCAL_MODULE_STEM := code.bin
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/firmware/ver2
+...
+include $(BUILD_PREBUILT)
+```
+
+You just need to make sure that any other references (`PRODUCT_PACKAGES`,
+`LOCAL_REQUIRED_MODULES`, etc) are converted to the new names.
+
## Valid Module Names {#name}
We've adopted lexical requirements very similar to [Bazel's
requirements](https://docs.bazel.build/versions/master/build-ref.html#name) for
target names. Valid characters are `a-z`, `A-Z`, `0-9`, and the special
-characters `_.+-=,@~/`. This currently applies to `LOCAL_PACKAGE_NAME`,
+characters `_.+-=,@~`. This currently applies to `LOCAL_PACKAGE_NAME`,
`LOCAL_MODULE`, and `LOCAL_MODULE_SUFFIX`, and `LOCAL_MODULE_STEM*`.
Many other characters already caused problems if you used them, so we don't
diff --git a/core/android_manifest.mk b/core/android_manifest.mk
index e52bb2c..08f3f38 100644
--- a/core/android_manifest.mk
+++ b/core/android_manifest.mk
@@ -6,9 +6,9 @@
LOCAL_MANIFEST_FILE := AndroidManifest.xml
endif
ifdef LOCAL_FULL_MANIFEST_FILE
- main_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
+ full_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
else
- main_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
+ full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
endif
LOCAL_STATIC_JAVA_AAR_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_AAR_LIBRARIES))
@@ -32,35 +32,18 @@
endif
endif
-full_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml
-
-ifdef LOCAL_MIN_SDK_VERSION
- $(full_android_manifest): PRIVATE_MIN_SDK_VERSION := $(LOCAL_MIN_SDK_VERSION)
-else ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
- $(full_android_manifest): PRIVATE_MIN_SDK_VERSION := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
-else
- $(full_android_manifest): PRIVATE_MIN_SDK_VERSION := $(DEFAULT_APP_TARGET_SDK)
-endif
-
# Set up rules to merge library manifest files
ifneq (,$(strip $(my_full_libs_manifest_files)))
+main_android_manifest := $(full_android_manifest)
+full_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml
$(full_android_manifest): PRIVATE_LIBS_MANIFESTS := $(my_full_libs_manifest_files)
$(full_android_manifest): $(ANDROID_MANIFEST_MERGER_CLASSPATH)
-$(full_android_manifest): $(MANIFEST_FIXER)
$(full_android_manifest) : $(main_android_manifest) $(my_full_libs_manifest_files)
@echo "Merge android manifest files: $@ <-- $< $(PRIVATE_LIBS_MANIFESTS)"
@mkdir -p $(dir $@)
- $(MANIFEST_FIXER) $< $@.tmp --minSdkVersion $(PRIVATE_MIN_SDK_VERSION)
- $(hide) $(ANDROID_MANIFEST_MERGER) --main $@.tmp \
+ $(hide) $(ANDROID_MANIFEST_MERGER) --main $< \
--libs $(call normalize-path-list,$(PRIVATE_LIBS_MANIFESTS)) \
--out $@
- rm $@.tmp
-
-else
-$(full_android_manifest): $(MANIFEST_FIXER)
-$(full_android_manifest): $(main_android_manifest)
- @echo "Fix manifest: $@"
- $(MANIFEST_FIXER) $< $@ --minSdkVersion $(PRIVATE_MIN_SDK_VERSION)
endif
diff --git a/core/autogen_test_config.mk b/core/autogen_test_config.mk
index 20c582a..5feec2b 100644
--- a/core/autogen_test_config.mk
+++ b/core/autogen_test_config.mk
@@ -31,7 +31,7 @@
# Auto generating test config file for native test
$(autogen_test_config_file) : $(autogen_test_config_template)
@echo "Auto generating test config $(notdir $@)"
- $(hide) sed 's&{MODULE}&$(PRIVATE_MODULE)&g' $^ > $@
+ $(hide) sed 's&{MODULE}&$(PRIVATE_MODULE)&g' $< > $@
my_auto_generate_config := true
else
# Auto generating test config file for instrumentation test
diff --git a/core/definitions.mk b/core/definitions.mk
index 07576f9..9c7f8b6 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -3488,24 +3488,26 @@
###########################################################
## Verify module name meets character requirements:
## a-z A-Z 0-9
-## _.+-=,@~/
+## _.+-=,@~
##
-## This is equivalent to bazel's target name restrictions:
+## This is a subset of bazel's target name restrictions:
## https://docs.bazel.build/versions/master/build-ref.html#name
###########################################################
define verify-module-name
+$(if $(filter-out $(LOCAL_MODULE),$(subst /,,$(LOCAL_MODULE))), \
+ $(call pretty-warning,Module name contains a /$(comma) use LOCAL_MODULE_STEM and LOCAL_MODULE_RELATIVE_PATH instead)) \
$(if $(call _invalid-name-chars,$(LOCAL_MODULE)), \
$(call pretty-error,Invalid characters in module name: $(call _invalid-name-chars,$(LOCAL_MODULE))))
endef
define _invalid-name-chars
-$(subst /,,$(subst _,,$(subst .,,$(subst +,,$(subst -,,$(subst =,,$(subst $(comma),,$(subst @,,$(subst ~,,$(subst 0,,$(subst 1,,$(subst 2,,$(subst 3,,$(subst 4,,$(subst 5,,$(subst 6,,$(subst 7,,$(subst 8,,$(subst 9,,$(subst a,,$(subst b,,$(subst c,,$(subst d,,$(subst e,,$(subst f,,$(subst g,,$(subst h,,$(subst i,,$(subst j,,$(subst k,,$(subst l,,$(subst m,,$(subst n,,$(subst o,,$(subst p,,$(subst q,,$(subst r,,$(subst s,,$(subst t,,$(subst u,,$(subst v,,$(subst w,,$(subst x,,$(subst y,,$(subst z,,$(call to-lower,$(1)))))))))))))))))))))))))))))))))))))))))))))))
+$(subst _,,$(subst .,,$(subst +,,$(subst -,,$(subst =,,$(subst $(comma),,$(subst @,,$(subst ~,,$(subst 0,,$(subst 1,,$(subst 2,,$(subst 3,,$(subst 4,,$(subst 5,,$(subst 6,,$(subst 7,,$(subst 8,,$(subst 9,,$(subst a,,$(subst b,,$(subst c,,$(subst d,,$(subst e,,$(subst f,,$(subst g,,$(subst h,,$(subst i,,$(subst j,,$(subst k,,$(subst l,,$(subst m,,$(subst n,,$(subst o,,$(subst p,,$(subst q,,$(subst r,,$(subst s,,$(subst t,,$(subst u,,$(subst v,,$(subst w,,$(subst x,,$(subst y,,$(subst z,,$(call to-lower,$(1))))))))))))))))))))))))))))))))))))))))))))))
endef
.KATI_READONLY := verify-module-name _invalid-name-chars
###########################################################
## Verify module stem meets character requirements:
## a-z A-Z 0-9
-## _.+-=,@~/
+## _.+-=,@~
##
## This is a subset of bazel's target name restrictions:
## https://docs.bazel.build/versions/master/build-ref.html#name
@@ -3513,7 +3515,9 @@
## $(1): The module stem variable to check
###########################################################
define verify-module-stem
+$(if $(filter-out $($(1)),$(subst /,,$($(1)))), \
+ $(call pretty-warning,Module stem \($(1)\) contains a /$(comma) use LOCAL_MODULE_RELATIVE_PATH instead)) \
$(if $(call _invalid-name-chars,$($(1))), \
- $(call pretty-error,Invalid characters in module stem ($(1)): $(call _invalid-name-chars,$($(1)))))
+ $(call pretty-error,Invalid characters in module stem \($(1)\): $(call _invalid-name-chars,$($(1)))))
endef
.KATI_READONLY := verify-module-stem