Merge "emulator: support system-as-root"
diff --git a/Changes.md b/Changes.md
new file mode 100644
index 0000000..53ff007
--- /dev/null
+++ b/Changes.md
@@ -0,0 +1,106 @@
+# Build System Changes for Android.mk Writers
+
+## Deprecating / obsoleting envsetup.sh variables in Makefiles
+
+It is not required to source envsetup.sh before running a build. Many scripts,
+including a majority of our automated build systems, do not do so. Make will
+transparently make every environment variable available as a make variable.
+This means that relying on environment variables only set up in envsetup.sh will
+produce different output for local users and scripted users.
+
+Many of these variables also include absolute path names, which we'd like to
+keep out of the generated files, so that you don't need to do a full rebuild if
+you move the source tree.
+
+To fix this, we're marking the variables that are set in envsetup.sh as
+deprecated in the makefiles. This will trigger a warning every time one is read
+(or written) inside Kati. Once all the warnings have been removed for a
+particular variable, we'll switch it to obsolete, and any references will become
+errors.
+
+### envsetup.sh variables with make equivalents
+
+| instead of | use |
+|--------------------------------------------------------------|----------------------|
+| OUT {#OUT} | OUT_DIR |
+| ANDROID_HOST_OUT {#ANDROID_HOST_OUT} | HOST_OUT |
+| ANDROID_PRODUCT_OUT {#ANDROID_PRODUCT_OUT} | PRODUCT_OUT |
+| ANDROID_HOST_OUT_TESTCASES {#ANDROID_HOST_OUT_TESTCASES} | HOST_OUT_TESTCASES |
+| ANDROID_TARGET_OUT_TESTCASES {#ANDROID_TARGET_OUT_TESTCASES} | TARGET_OUT_TESTCASES |
+
+All of the make variables may be relative paths from the current directory, or
+absolute paths if the output directory was specified as an absolute path. If you
+need an absolute variable, convert it to absolute during a rule, so that it's
+not expanded into the generated ninja file:
+
+``` make
+$(PRODUCT_OUT)/gen.img: my/src/path/gen.sh
+ export PRODUCT_OUT=$$(cd $(PRODUCT_OUT); pwd); cd my/src/path; ./gen.sh -o $${PRODUCT_OUT}/gen.img
+```
+
+### ANDROID_BUILD_TOP {#ANDROID_BUILD_TOP}
+
+In Android.mk files, you can always assume that the current directory is the
+root of the source tree, so this can just be replaced with '.' (which is what
+$TOP is hardcoded to), or removed entirely. If you need an absolute path, see
+the instructions above.
+
+### Stop using PATH directly {#PATH}
+
+This isn't only set by envsetup.sh, but it is modified by it. Due to that it's
+rather easy for this to change between different shells, and it's not ideal to
+reread the makefiles every time this changes.
+
+In most cases, you shouldn't need to touch PATH at all. When you need to have a
+rule reference a particular binary that's part of the source tree or outputs,
+it's preferrable to just use the path to the file itself (since you should
+already be adding that as a dependency).
+
+Depending on the rule, passing the file path itself may not be feasible due to
+layers of unchangable scripts/binaries. In that case, be sure to add the
+dependency, but modify the PATH within the rule itself:
+
+``` make
+$(TARGET): myscript my/path/binary
+ PATH=my/path:$$PATH myscript -o $@
+```
+
+### Stop using PYTHONPATH directly {#PYTHONPATH}
+
+Like PATH, this isn't only set by envsetup.sh, but it is modified by it. Due to
+that it's rather easy for this to change between different shells, and it's not
+ideal to reread the makefiles every time.
+
+The best solution here is to start switching to Soong's python building support,
+which packages the python interpreter, libraries, and script all into one file
+that no longer needs PYTHONPATH. See fontchain_lint for examples of this:
+
+* [external/fonttools/Lib/fontTools/Android.bp] for python_library_host
+* [frameworks/base/Android.bp] for python_binary_host
+* [frameworks/base/data/fonts/Android.mk] to execute the python binary
+
+If you still need to use PYTHONPATH, do so within the rule itself, just like
+path:
+
+``` make
+$(TARGET): myscript.py $(sort $(shell find my/python/lib -name '*.py'))
+ PYTHONPATH=my/python/lib:$$PYTHONPATH myscript.py -o $@
+```
+
+### Other envsetup.sh variables {#other_envsetup_variables}
+
+* ANDROID_TOOLCHAIN
+* ANDROID_TOOLCHAIN_2ND_ARCH
+* ANDROID_DEV_SCRIPTS
+* ANDROID_EMULATOR_PREBUILTS
+* ANDROID_PRE_BUILD_PATHS
+
+These are all exported from envsetup.sh, but don't have clear equivalents within
+the makefile system. If you need one of them, you'll have to set up your own
+version.
+
+
+[build/soong/Changes.md]: https://android.googlesource.com/platform/build/soong/+/master/Changes.md
+[external/fonttools/Lib/fontTools/Android.bp]: https://android.googlesource.com/platform/external/fonttools/+/master/Lib/fontTools/Android.bp
+[frameworks/base/Android.bp]: https://android.googlesource.com/platform/frameworks/base/+/master/Android.bp
+[frameworks/base/data/fonts/Android.mk]: https://android.googlesource.com/platform/frameworks/base/+/master/data/fonts/Android.mk
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..47809a9
--- /dev/null
+++ b/README.md
@@ -0,0 +1,23 @@
+# Android Make Build System
+
+This is the Makefile-based portion of the Android Build System.
+
+For documentation on how to run a build, see [Usage.txt](Usage.txt)
+
+For a list of behavioral changes useful for Android.mk writers see
+[Changes.md](Changes.md)
+
+For an outdated reference on Android.mk files, see
+[build-system.html](/core/build-system.html). Our Android.mk files look similar,
+but are entirely different from the Android.mk files used by the NDK build
+system. When searching for documentation elsewhere, ensure that it is for the
+platform build system -- most are not.
+
+This Makefile-based system is in the process of being replaced with [Soong], a
+new build system written in Go. During the transition, all of these makefiles
+are read by [Kati], and generate a ninja file instead of being executed
+directly. That's combined with a ninja file read by Soong so that the build
+graph of the two systems can be combined and run as one.
+
+[Kati]: https://github.com/google/kati
+[Soong]: https://android.googlesource.com/platform/build/soong/+/master
diff --git a/README.txt b/Usage.txt
similarity index 100%
rename from README.txt
rename to Usage.txt
diff --git a/core/Makefile b/core/Makefile
index 06fdf62..2e863a7 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -58,6 +58,19 @@
unique_product_copy_files_destinations :=
# -----------------------------------------------------------------
+# Returns the max allowed size for an image suitable for hash verification
+# (e.g., boot.img, recovery.img, etc).
+# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
+# $(1): partition size to flash the image
+define get-hash-image-max-size
+$(if $(1), \
+ $(if $(filter true,$(BOARD_AVB_ENABLE)), \
+ $(eval _hash_meta_size := 69632), \
+ $(eval _hash_meta_size := 0)) \
+ $(1)-$(_hash_meta_size))
+endef
+
+# -----------------------------------------------------------------
# Define rules to copy headers defined in copy_headers.mk
# If more than one makefile declared a header, print a warning,
# then copy the last one defined. This matches the previous make
@@ -686,7 +699,7 @@
$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
$(call pretty,"Target boot image: $@")
$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
- $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+ $(hide) $(call assert-max-image-size,$@,$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
$(hide) $(AVBTOOL) add_hash_footer \
--image $@ \
--partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
@@ -697,9 +710,9 @@
bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
@echo "make $@: ignoring dependencies"
$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
- $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+ $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
$(hide) $(AVBTOOL) add_hash_footer \
- --image $@ \
+ --image $(INSTALLED_BOOTIMAGE_TARGET) \
--partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
--partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
@@ -1288,15 +1301,15 @@
)
$(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
$(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1))
+ $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
+ $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))), \
+ $(hide) $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
$(if $(and $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),$(filter true,$(BOARD_AVB_ENABLE))), \
$(hide) $(AVBTOOL) add_hash_footer \
--image $(1) \
--partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
--partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS))
- $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
- $(hide) $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE)), \
- $(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)))
endef
ADBD := $(TARGET_OUT_EXECUTABLES)/adbd
diff --git a/core/apidiff.mk b/core/apidiff.mk
index 1a7467d..6fd94a2 100644
--- a/core/apidiff.mk
+++ b/core/apidiff.mk
@@ -57,8 +57,18 @@
LOCAL_JAVA_LIBRARIES := android_test_stubs_current $(LOCAL_JAVA_LIBRARIES)
$(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_test_stubs_current)
else
- LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES)
- $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION))
+ ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION)))
+ ifeq (,$(TARGET_BUILD_APPS))
+ LOCAL_JAVA_LIBRARIES := system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) $(LOCAL_JAVA_LIBRARIES)
+ $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)))
+ else
+ LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES)
+ $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION))
+ endif
+ else
+ LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES)
+ $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION))
+ endif
endif
else
LOCAL_JAVA_LIBRARIES := core-oj core-libart ext framework $(LOCAL_JAVA_LIBRARIES)
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 592650d..7ce3f0f 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -86,6 +86,7 @@
endif
include $(BUILD_SYSTEM)/local_vndk.mk
+include $(BUILD_SYSTEM)/local_vsdk.mk
my_module_tags := $(LOCAL_MODULE_TAGS)
ifeq ($(my_host_cross),true)
@@ -611,6 +612,7 @@
ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true
endif
ALL_MODULES.$(my_register_name).FOR_HOST_CROSS := $(my_host_cross)
+ALL_MODULES.$(my_register_name).COMPATIBILITY_SUITES := $(LOCAL_COMPATIBILITY_SUITE)
INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name)
@@ -666,7 +668,7 @@
ifdef j_or_n
-$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(my_checked_module)
+$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_hc_or_t) : $(my_checked_module)
ifneq (,$(filter $(my_module_tags),tests))
$(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(my_checked_module)
endif
diff --git a/core/binary.mk b/core/binary.mk
index e54edbe..bf2e93b 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -387,9 +387,9 @@
# clang is enabled by default for host builds
# enable it unless we've specifically disabled clang above
ifdef LOCAL_IS_HOST_MODULE
- ifeq ($($(my_prefix)OS),windows)
+ ifneq ($($(my_prefix)CLANG_SUPPORTED),true)
ifeq ($(my_clang),true)
- $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Clang is not yet supported for windows binaries)
+ $(call pretty-error,Clang is not yet supported for $($(my_prefix)OS) binaries)
endif
my_clang := false
else
@@ -806,7 +806,7 @@
ifneq (,$(LOCAL_SDK_VERSION))
# Set target-api for LOCAL_SDK_VERSIONs other than current.
ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
-renderscript_target_api := $(LOCAL_SDK_VERSION)
+renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
endif
endif # LOCAL_SDK_VERSION is set
endif # LOCAL_RENDERSCRIPT_TARGET_API is set
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index aa1f756..59297ea 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -231,10 +231,14 @@
LOCAL_SDK_VERSION:=
LOCAL_SHARED_ANDROID_LIBRARIES:=
LOCAL_SHARED_LIBRARIES:=
+LOCAL_SOONG_HEADER_JAR :=
+LOCAL_SOONG_DEX_JAR :=
+LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=
# '',true
LOCAL_SOURCE_FILES_ALL_GENERATED:=
LOCAL_SRC_FILES:=
LOCAL_SRC_FILES_EXCLUDE:=
+LOCAL_SRCJARS:=
LOCAL_STATIC_ANDROID_LIBRARIES:=
LOCAL_STATIC_JAVA_AAR_LIBRARIES:=
LOCAL_STATIC_JAVA_LIBRARIES:=
diff --git a/core/config.mk b/core/config.mk
index 7ff2922..2f022a5 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -59,7 +59,24 @@
.DELETE_ON_ERROR:
# Mark variables deprecated/obsolete
-$(KATI_deprecated_var PATH,Do not use PATH directly)
+CHANGES_URL := https://android.googlesource.com/platform/build/+/master/Changes.md
+$(KATI_deprecated_var PATH,Do not use PATH directly. See $(CHANGES_URL)#PATH)
+$(KATI_obsolete_var PYTHONPATH,Do not use PYTHONPATH directly. See $(CHANGES_URL)#PYTHONPATH)
+$(KATI_obsolete_var OUT,Use OUT_DIR instead. See $(CHANGES_URL)#OUT)
+$(KATI_obsolete_var ANDROID_HOST_OUT,Use HOST_OUT instead. See $(CHANGES_URL)#ANDROID_HOST_OUT)
+$(KATI_deprecated_var ANDROID_PRODUCT_OUT,Use PRODUCT_OUT instead. See $(CHANGES_URL)#ANDROID_PRODUCT_OUT)
+$(KATI_obsolete_var ANDROID_HOST_OUT_TESTCASES,Use HOST_OUT_TESTCASES instead. See $(CHANGES_URL)#ANDROID_HOST_OUT_TESTCASES)
+$(KATI_obsolete_var ANDROID_TARGET_OUT_TESTCASES,Use TARGET_OUT_TESTCASES instead. See $(CHANGES_URL)#ANDROID_TARGET_OUT_TESTCASES)
+$(KATI_deprecated_var ANDROID_BUILD_TOP,Use '.' instead. See $(CHANGES_URL)#ANDROID_BUILD_TOP)
+$(KATI_obsolete_var \
+ ANDROID_TOOLCHAIN \
+ ANDROID_TOOLCHAIN_2ND_ARCH \
+ ANDROID_DEV_SCRIPTS \
+ ANDROID_EMULATOR_PREBUILTS \
+ ANDROID_PRE_BUILD_PATHS \
+ ,See $(CHANGES_URL)#other_envsetup_variables)
+
+CHANGES_URL :=
# Used to force goals to build. Only use for conditionally defined goals.
.PHONY: FORCE
@@ -67,6 +84,9 @@
ORIGINAL_MAKECMDGOALS := $(MAKECMDGOALS)
+dist_goal := $(strip $(filter dist,$(MAKECMDGOALS)))
+MAKECMDGOALS := $(strip $(filter-out dist,$(MAKECMDGOALS)))
+
# Tell python not to spam the source tree with .pyc files. This
# only has an effect on python 2.6 and above.
export PYTHONDONTWRITEBYTECODE := 1
@@ -659,7 +679,6 @@
FINDBUGS_DIR := external/owasp/sanitizer/tools/findbugs/bin
FINDBUGS := $(FINDBUGS_DIR)/findbugs
-JACOCO_CLI_JAR := $(HOST_OUT_JAVA_LIBRARIES)/jacoco-cli$(COMMON_JAVA_PACKAGE_SUFFIX)
# Tool to merge AndroidManifest.xmls
ANDROID_MANIFEST_MERGER_CLASSPATH := \
@@ -878,6 +897,11 @@
$(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%, \
$(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android.jar)))
+TARGET_AVAILABLE_SDK_VERSIONS := $(addprefix system_,$(call numerically_sort,\
+ $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android_system.jar,%, \
+ $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android_system.jar)))) \
+ $(TARGET_AVAILABLE_SDK_VERSIONS)
+
# We don't have prebuilt test_current SDK yet.
TARGET_AVAILABLE_SDK_VERSIONS := test_current $(TARGET_AVAILABLE_SDK_VERSIONS)
diff --git a/core/definitions.mk b/core/definitions.mk
index 9491412..b850bb8 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -3395,3 +3395,22 @@
$(eval ALL_MODULES.$(enforce_rro_source_module).REQUIRED += $(enforce_rro_module)) \
)
endef
+
+###########################################################
+## Find system_$(VER) in LOCAL_SDK_VERSION
+##
+## $(1): LOCAL_SDK_VERSION
+###########################################################
+define has-system-sdk-version
+$(filter system_%,$(1))
+endef
+
+###########################################################
+## Get numerical version in LOCAL_SDK_VERSION
+##
+## $(1): LOCAL_SDK_VERSION
+###########################################################
+define get-numeric-sdk-version
+$(filter-out current,\
+ $(if $(call has-system-sdk-version,$(1)),$(patsubst system_%,%,$(1)),$(1)))
+endef
diff --git a/core/distdir.mk b/core/distdir.mk
index 89c5966..c074186 100644
--- a/core/distdir.mk
+++ b/core/distdir.mk
@@ -17,9 +17,6 @@
# When specifying "dist", the user has asked that we copy the important
# files from this build into DIST_DIR.
-dist_goal := $(strip $(filter dist,$(MAKECMDGOALS)))
-MAKECMDGOALS := $(strip $(filter-out dist,$(MAKECMDGOALS)))
-
ifdef dist_goal
# $(1): source file
diff --git a/core/dpi_specific_apk.mk b/core/dpi_specific_apk.mk
index ac5c4a9..e29cde7 100644
--- a/core/dpi_specific_apk.mk
+++ b/core/dpi_specific_apk.mk
@@ -19,7 +19,7 @@
$(built_dpi_apk): PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports)
$(built_dpi_apk): PRIVATE_RESOURCE_LIST := $(all_res_assets)
ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
-$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
+$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
else
$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
endif
diff --git a/core/droiddoc.mk b/core/droiddoc.mk
index 2bac984..c8d0dc8 100644
--- a/core/droiddoc.mk
+++ b/core/droiddoc.mk
@@ -72,8 +72,18 @@
LOCAL_JAVA_LIBRARIES := android_test_stubs_current $(LOCAL_JAVA_LIBRARIES)
$(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_test_stubs_current)
else
- LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES)
- $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION))
+ ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION)))
+ ifeq (,$(TARGET_BUILD_APPS))
+ LOCAL_JAVA_LIBRARIES := system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) $(LOCAL_JAVA_LIBRARIES)
+ $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)))
+ else
+ LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES)
+ $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION))
+ endif
+ else
+ LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES)
+ $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION))
+ endif
endif
else
LOCAL_JAVA_LIBRARIES := core-oj core-libart ext framework $(LOCAL_JAVA_LIBRARIES)
diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk
index a522f0b..1b3f967 100644
--- a/core/host_dalvik_java_library.mk
+++ b/core/host_dalvik_java_library.mk
@@ -186,8 +186,8 @@
endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
- my_default_app_target_sdk := $(LOCAL_SDK_VERSION)
- my_sdk_version := $(LOCAL_SDK_VERSION)
+ my_default_app_target_sdk := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
+ my_sdk_version := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
else
my_default_app_target_sdk := $(DEFAULT_APP_TARGET_SDK)
my_sdk_version := $(PLATFORM_SDK_VERSION)
diff --git a/core/jacoco.mk b/core/jacoco.mk
index 74d84f4..f51790d 100644
--- a/core/jacoco.mk
+++ b/core/jacoco.mk
@@ -21,7 +21,6 @@
# determine Jacoco include/exclude filters even when coverage is not enabled
# to get syntax checking on LOCAL_JACK_COVERAGE_(INCLUDE|EXCLUDE)_FILTER
-DEFAULT_JACOCO_EXCLUDE_FILTER := org/junit/*,org/jacoco/*,org/mockito/*
# copy filters from Jack but also skip some known java packages
my_include_filter := $(strip $(LOCAL_JACK_COVERAGE_INCLUDE_FILTER))
my_exclude_filter := $(strip $(DEFAULT_JACOCO_EXCLUDE_FILTER),$(LOCAL_JACK_COVERAGE_EXCLUDE_FILTER))
diff --git a/core/java.mk b/core/java.mk
index 45d5678..99dc9fc 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -135,7 +135,7 @@
ifneq (,$(LOCAL_SDK_VERSION))
# Set target-api for LOCAL_SDK_VERSIONs other than current.
ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
- renderscript_target_api := $(LOCAL_SDK_VERSION)
+ renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
endif
endif # LOCAL_SDK_VERSION is set
endif # LOCAL_RENDERSCRIPT_TARGET_API is set
@@ -820,8 +820,8 @@
endif # full_classes_jar is defined
ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
- my_default_app_target_sdk := $(LOCAL_SDK_VERSION)
- my_sdk_version := $(LOCAL_SDK_VERSION)
+ my_default_app_target_sdk := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
+ my_sdk_version := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
else
my_default_app_target_sdk := $(DEFAULT_APP_TARGET_SDK)
my_sdk_version := $(PLATFORM_SDK_VERSION)
diff --git a/core/java_common.mk b/core/java_common.mk
index 4dd0de6..a90c779 100644
--- a/core/java_common.mk
+++ b/core/java_common.mk
@@ -229,8 +229,16 @@
else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current)
full_java_bootclasspath_libs := $(call java-lib-header-files,android_test_stubs_current)
else
- full_java_bootclasspath_libs := $(call java-lib-header-files,sdk_v$(LOCAL_SDK_VERSION))
- endif # current, system_current, or test_current
+ ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION)))
+ ifeq (,$(TARGET_BUILD_APPS))
+ full_java_bootclasspath_libs := $(call java-lib-header-files,system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)))
+ else
+ full_java_bootclasspath_libs := $(call java-lib-header-files,sdk_v$(LOCAL_SDK_VERSION))
+ endif
+ else
+ full_java_bootclasspath_libs := $(call java-lib-header-files,sdk_v$(LOCAL_SDK_VERSION))
+ endif
+ endif # current, system_current, system_${VER} or test_current
endif # LOCAL_SDK_VERSION
ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
@@ -404,6 +412,10 @@
my_link_type := java:system
my_warn_types := java:platform
my_allowed_types := java:sdk java:system
+else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION)))
+my_link_type := java:system
+my_warn_types := java:platform
+my_allowed_types := java:sdk java:system
else ifneq ($(LOCAL_SDK_VERSION),)
my_link_type := java:sdk
my_warn_types := java:system java:platform
diff --git a/core/local_vsdk.mk b/core/local_vsdk.mk
new file mode 100644
index 0000000..f798d47
--- /dev/null
+++ b/core/local_vsdk.mk
@@ -0,0 +1,19 @@
+
+ifdef BOARD_VSDK_VERSION
+# Set LOCAL_SDK_VERSION to system_current, If LOCAL_SDK_VERSION is not defined and LOCAL_VENDOR_MODULE is true
+ _is_vendor_app :=
+ ifneq (,$(filter true,$(LOCAL_VENDOR_MODULE) $(LOCAL_ODM_MODULE) $(LOCAL_OEM_MODULE) $(LOCAL_PROPRIETARY_MODULE)))
+ _is_vendor_app := true
+ else
+ ifneq (,$(filter $(TARGET_OUT_VENDOR)%,$(LOCAL_MODULE_PATH) $(LOCAL_MODULE_PATH_32) $(LOCAL_MODULE_PATH_64)))
+ _is_vendor_app := true
+ endif
+ endif
+ ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
+ ifndef LOCAL_SDK_VERSION
+ ifeq ($(_is_vendor_app),true)
+ LOCAL_SDK_VERSION := system_current
+ endif
+ endif
+ endif
+endif
diff --git a/core/package_internal.mk b/core/package_internal.mk
index 6337131..282bcad 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -389,7 +389,7 @@
ifneq (,$(LOCAL_SDK_VERSION))
# Set target-api for LOCAL_SDK_VERSIONs other than current.
ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
-renderscript_target_api := $(LOCAL_SDK_VERSION)
+renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
endif
endif # LOCAL_SDK_VERSION is set
endif # LOCAL_RENDERSCRIPT_TARGET_API is set
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 6b7f150..2a9ad1f 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -540,6 +540,8 @@
ifeq ($(LOCAL_SDK_VERSION),system_current)
my_link_type := java:system
+else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION)))
+my_link_type := java:system
else ifneq ($(LOCAL_SDK_VERSION),)
my_link_type := java:sdk
else
diff --git a/core/product.mk b/core/product.mk
index c01a856..f15f6b3 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -102,6 +102,7 @@
PRODUCT_SDK_ADDON_COPY_MODULES \
PRODUCT_SDK_ADDON_DOC_MODULES \
PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP \
+ PRODUCT_SOONG_NAMESPACES \
PRODUCT_DEFAULT_WIFI_CHANNELS \
PRODUCT_DEFAULT_DEV_CERTIFICATE \
PRODUCT_RESTRICT_VENDOR_FILES \
diff --git a/core/product_config.mk b/core/product_config.mk
index 4e2d5ae..5b0e257 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -480,3 +480,7 @@
# Whether any paths should have CFI enabled for components
PRODUCT_CFI_INCLUDE_PATHS := \
$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CFI_INCLUDE_PATHS))
+
+# which Soong namespaces to export to Make
+PRODUCT_SOONG_NAMESPACES :=
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SOONG_NAMESPACES))
diff --git a/core/soong_app_prebuilt.mk b/core/soong_app_prebuilt.mk
new file mode 100644
index 0000000..ae0b982
--- /dev/null
+++ b/core/soong_app_prebuilt.mk
@@ -0,0 +1,68 @@
+# App prebuilt coming from Soong.
+# Extra inputs:
+# LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE
+
+ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
+ $(call pretty-error,soong_app_prebuilt.mk may only be used from Soong)
+endif
+
+LOCAL_MODULE_SUFFIX := .apk
+LOCAL_BUILT_MODULE_STEM := package.apk
+
+#######################################
+include $(BUILD_SYSTEM)/base_rules.mk
+#######################################
+
+ifdef LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR
+ $(eval $(call copy-one-file,$(LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR),\
+ $(intermediates.COMMON)/jacoco-report-classes.jar))
+endif
+
+$(eval $(call copy-one-file,$(LOCAL_PREBUILT_MODULE_FILE),$(LOCAL_BUILT_MODULE)))
+
+ifdef LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE
+resource_export_package := $(intermediates.COMMON)/package-export.apk
+resource_export_stamp := $(intermediates.COMMON)/src/R.stamp
+
+$(resource_export_package): PRIVATE_STAMP := $(resource_export_stamp)
+$(resource_export_package): .KATI_IMPLICIT_OUTPUTS := $(resource_export_stamp)
+$(resource_export_package): $(LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE)
+ @echo "Copy: $$@"
+ $(copy-file-to-target)
+ touch $(PRIVATE_STAMP)
+
+endif # LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE
+
+java-dex: $(LOCAL_SOONG_DEX_JAR)
+
+ifdef LOCAL_DEX_PREOPT
+# defines built_odex along with rule to install odex
+include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
+
+$(built_odex): $(LOCAL_SOONG_DEX_JAR)
+ $(call dexpreopt-one-file,$<,$@)
+endif
+
+ifndef LOCAL_IS_HOST_MODULE
+ifeq ($(LOCAL_SDK_VERSION),system_current)
+my_link_type := java:system
+my_warn_types := java:platform
+my_allowed_types := java:sdk java:system
+else ifneq ($(LOCAL_SDK_VERSION),)
+my_link_type := java:sdk
+my_warn_types := java:system java:platform
+my_allowed_types := java:sdk
+else
+my_link_type := java:platform
+my_warn_types :=
+my_allowed_types := java:sdk java:system java:platform
+endif
+
+my_link_deps :=
+my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
+my_common := COMMON
+include $(BUILD_SYSTEM)/link_type.mk
+endif # !LOCAL_IS_HOST_MODULE
+
+# Built in equivalent to include $(CLEAR_VARS)
+LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=
diff --git a/core/soong_config.mk b/core/soong_config.mk
index 5ebd123..32e9ae0 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -118,6 +118,11 @@
$(call add_json_bool, MinimizeJavaDebugInfo, $(filter true,$(PRODUCT_MINIMIZE_JAVA_DEBUG_INFO)))
$(call add_json_bool, UseGoma, $(filter-out false,$(USE_GOMA)))
+$(call add_json_bool, Arc, $(filter true,$(TARGET_ARC)))
+
+$(call add_json_str, DistDir, $(if $(dist_goal), $(DIST_DIR)))
+
+$(call add_json_list, NamespacesToExport, $(PRODUCT_SOONG_NAMESPACES))
_contents := $(subst $(comma)$(newline)__SV_END,$(newline)}$(newline),$(_contents)__SV_END)
diff --git a/core/soong_java_prebuilt.mk b/core/soong_java_prebuilt.mk
index 53ad50d..e7f5fa5 100644
--- a/core/soong_java_prebuilt.mk
+++ b/core/soong_java_prebuilt.mk
@@ -2,6 +2,7 @@
# Extra inputs:
# LOCAL_SOONG_HEADER_JAR
# LOCAL_SOONG_DEX_JAR
+# LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR
ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
$(call pretty-error,soong_java_prebuilt.mk may only be used from Soong)
@@ -15,16 +16,17 @@
#######################################
full_classes_jar := $(intermediates.COMMON)/classes.jar
+full_classes_pre_proguard_jar := $(intermediates.COMMON)/classes-pre-proguard.jar
full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar
common_javalib.jar := $(intermediates.COMMON)/javalib.jar
-LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(LOCAL_PREBUILT_MODULE_FILE)
+$(eval $(call copy-one-file,$(LOCAL_PREBUILT_MODULE_FILE),$(full_classes_jar)))
+$(eval $(call copy-one-file,$(LOCAL_PREBUILT_MODULE_FILE),$(full_classes_pre_proguard_jar)))
-#######################################
-include $(BUILD_SYSTEM)/jacoco.mk
-#######################################
-
-$(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(full_classes_jar)))
+ifdef LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR
+ $(eval $(call copy-one-file,$(LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR),\
+ $(intermediates.COMMON)/jacoco-report-classes.jar))
+endif
ifneq ($(TURBINE_DISABLED),false)
ifdef LOCAL_SOONG_HEADER_JAR
@@ -79,6 +81,10 @@
my_link_type := java:system
my_warn_types := java:platform
my_allowed_types := java:sdk java:system
+else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION)))
+my_link_type := java:system
+my_warn_types := java:platform
+my_allowed_types := java:sdk java:system
else ifneq ($(LOCAL_SDK_VERSION),)
my_link_type := java:sdk
my_warn_types := java:system java:platform
@@ -94,7 +100,3 @@
my_common := COMMON
include $(BUILD_SYSTEM)/link_type.mk
endif # !LOCAL_IS_HOST_MODULE
-
-# Built in equivalent to include $(CLEAR_VARS)
-LOCAL_SOONG_HEADER_JAR :=
-LOCAL_SOONG_DEX_JAR :=
diff --git a/core/static_java_library.mk b/core/static_java_library.mk
index dd54135..ae606dd 100644
--- a/core/static_java_library.mk
+++ b/core/static_java_library.mk
@@ -160,7 +160,7 @@
ifneq (,$(LOCAL_SDK_VERSION))
# Set target-api for LOCAL_SDK_VERSIONs other than current.
ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
-renderscript_target_api := $(LOCAL_SDK_VERSION)
+renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
endif
endif # LOCAL_SDK_VERSION is set
endif # LOCAL_RENDERSCRIPT_TARGET_API is set
diff --git a/core/tasks/module-info.mk b/core/tasks/module-info.mk
index e9b2ac7..f6d688c 100644
--- a/core/tasks/module-info.mk
+++ b/core/tasks/module-info.mk
@@ -11,6 +11,7 @@
'"path": [$(foreach w,$(sort $(ALL_MODULES.$(m).PATH)),"$(w)", )], ' \
'"tags": [$(foreach w,$(sort $(ALL_MODULES.$(m).TAGS)),"$(w)", )], ' \
'"installed": [$(foreach w,$(sort $(ALL_MODULES.$(m).INSTALLED)),"$(w)", )], ' \
+ '"compatibility_suites": [$(foreach w,$(sort $(ALL_MODULES.$(m).COMPATIBILITY_SUITES)),"$(w)", )], ' \
'},\n' \
) | sed -e 's/, *\]/]/g' -e 's/, *\}/ }/g' -e '$$s/,$$//' >> $@
$(hide) echo '}' >> $@
diff --git a/core/tasks/tools/compatibility.mk b/core/tasks/tools/compatibility.mk
index 0fc2045..41ee76f 100644
--- a/core/tasks/tools/compatibility.mk
+++ b/core/tasks/tools/compatibility.mk
@@ -21,6 +21,8 @@
# test_suite_readme: the path to a README file for this test suite
# test_suite_prebuilt_tools: the set of prebuilt tools to be included directly
# in the 'tools' subdirectory of the test suite.
+# test_suite_tools: the set of tools for this test suite
+#
# Output variables:
# compatibility_zip: the path to the output zip file.
@@ -38,6 +40,8 @@
$(HOST_OUT_EXECUTABLES)/$(test_suite_tradefed) \
$(test_suite_readme)
+test_tools += $(test_suite_tools)
+
compatibility_zip := $(out_dir).zip
$(compatibility_zip): PRIVATE_NAME := android-$(test_suite_name)
$(compatibility_zip): PRIVATE_OUT_DIR := $(out_dir)
@@ -59,3 +63,4 @@
test_suite_dynamic_config :=
test_suite_readme :=
test_suite_prebuilt_tools :=
+test_suite_tools :=
diff --git a/core/tasks/vndk.mk b/core/tasks/vndk.mk
index d824a41..a3ec16a 100644
--- a/core/tasks/vndk.mk
+++ b/core/tasks/vndk.mk
@@ -24,72 +24,135 @@
# Args:
# $(1): if not empty, evaluates for TARGET_2ND_ARCH
define clang-ubsan-vndk-core
- $(eval prefix := $(if $(1),2ND_,))
- $(addsuffix .vendor,$($(addprefix $(prefix),UBSAN_RUNTIME_LIBRARY)))
+$(strip \
+ $(eval prefix := $(if $(1),2ND_,)) \
+ $(addsuffix .vendor,$($(addprefix $(prefix),UBSAN_RUNTIME_LIBRARY))) \
+)
endef
+# Returns list of file paths of the intermediate objs
+#
# Args:
-# $(1): list of lib names without '.so' suffix (e.g., libX.vendor)
-# $(2): if not empty, evaluates for TARGET_2ND_ARCH
+# $(1): list of obj names (e.g., libfoo.vendor, ld.config.txt, ...)
+# $(2): target class (e.g., SHARED_LIBRARIES, STATIC_LIBRARIES, ETC)
+# $(3): if not empty, evaluates for TARGET_2ND_ARCH
define paths-of-intermediates
- $(strip \
- $(foreach lib,$(1), \
- $(call append-path,$(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),,,$(2)),$(lib).so)))
+$(strip \
+ $(foreach obj,$(1), \
+ $(eval file_name := $(if $(filter SHARED_LIBRARIES,$(2)),$(patsubst %.so,%,$(obj)).so,$(obj))) \
+ $(eval dir := $(call intermediates-dir-for,$(2),$(obj),,,$(3))) \
+ $(call append-path,$(dir),$(file_name)) \
+ ) \
+)
endef
-vndk_core_libs := $(addsuffix .vendor,$(filter-out libclang_rt.ubsan%,$(VNDK_CORE_LIBRARIES)))
-vndk_sp_libs := $(addsuffix .vendor,$(VNDK_SAMEPROCESS_LIBRARIES))
-vndk_snapshot_dependencies := \
- $(vndk_core_libs) \
- $(vndk_sp_libs)
-
# If in the future libclang_rt.ubsan* is removed from the VNDK-core list,
# need to update the related logic in this file.
ifeq (,$(filter libclang_rt.ubsan%,$(VNDK_CORE_LIBRARIES)))
- $(error libclang_rt.ubsan* is no longer a VNDK-core library.)
+ $(warning libclang_rt.ubsan* is no longer a VNDK-core library. Please update this file.)
+ vndk_core_libs := $(addsuffix .vendor,$(VNDK_CORE_LIBRARIES))
+else
+ vndk_core_libs := $(addsuffix .vendor,$(filter-out libclang_rt.ubsan%,$(VNDK_CORE_LIBRARIES)))
+
+ # for TARGET_ARCH
+ vndk_core_libs += $(call clang-ubsan-vndk-core)
+
+ # TODO(b/69834489): Package additional arch variants
+ # ifdef TARGET_2ND_ARCH
+ # vndk_core_libs += $(call clang-ubsan-vndk-core,true)
+ # endif
endif
-# for TARGET_ARCH
-clang_ubsan_vndk_core_$(TARGET_ARCH) := $(call clang-ubsan-vndk-core)
-vndk_snapshot_dependencies += \
- $(clang_ubsan_vndk_core_$(TARGET_ARCH))
+vndk_sp_libs := $(addsuffix .vendor,$(VNDK_SAMEPROCESS_LIBRARIES))
+vndk_private_libs := $(addsuffix .vendor,$(VNDK_PRIVATE_LIBRARIES))
-ifdef TARGET_2ND_ARCH
-clang_ubsan_vndk_core_$(TARGET_2ND_ARCH) := $(call clang-ubsan-vndk-core,true)
-vndk_snapshot_dependencies += \
- $(clang_ubsan_vndk_core_$(TARGET_2ND_ARCH))
-endif
+vndk_snapshot_libs := \
+ $(vndk_core_libs) \
+ $(vndk_sp_libs)
+vndk_prebuilt_txts := \
+ ld.config.txt \
+ vndksp.libraries.txt \
+ llndk.libraries.txt
+
+vndk_snapshot_top := $(call intermediates-dir-for,PACKAGING,vndk-snapshot)
+vndk_snapshot_out := $(vndk_snapshot_top)/vndk-snapshot
+vndk_snapshot_configs_out := $(vndk_snapshot_top)/configs
+
+#######################################
+# vndkcore.libraries.txt
+vndkcore.libraries.txt := $(vndk_snapshot_configs_out)/vndkcore.libraries.txt
+$(vndkcore.libraries.txt): $(vndk_core_libs)
+ @echo 'Generating: $@'
+ @rm -f $@
+ @mkdir -p $(dir $@)
+ $(hide) echo -n > $@
+ $(hide) $(foreach lib,$^,echo $(patsubst %.vendor,%,$(lib)).so >> $@;)
+
+
+#######################################
+# vndkprivate.libraries.txt
+vndkprivate.libraries.txt := $(vndk_snapshot_configs_out)/vndkprivate.libraries.txt
+$(vndkprivate.libraries.txt): $(vndk_private_libs)
+ @echo 'Generating: $@'
+ @rm -f $@
+ @mkdir -p $(dir $@)
+ $(hide) echo -n > $@
+ $(hide) $(foreach lib,$^,echo $(patsubst %.vendor,%,$(lib)).so >> $@;)
+
+
+vndk_snapshot_configs := \
+ $(vndkcore.libraries.txt) \
+ $(vndkprivate.libraries.txt)
+
+#######################################
+# vndk_snapshot_zip
+vndk_snapshot_arch := $(vndk_snapshot_out)/arch-$(TARGET_ARCH)-$(TARGET_ARCH_VARIANT)
vndk_snapshot_zip := $(PRODUCT_OUT)/android-vndk-$(TARGET_ARCH).zip
-vndk_snapshot_out := $(call intermediates-dir-for,PACKAGING,vndk-snapshot)
+
$(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_OUT := $(vndk_snapshot_out)
-$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT_$(TARGET_ARCH) := \
- $(vndk_snapshot_out)/arch-$(TARGET_ARCH)/shared/vndk-core
-$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES_$(TARGET_ARCH) := \
- $(call paths-of-intermediates,$(vndk_core_libs) $(clang_ubsan_vndk_core_$(TARGET_ARCH)))
-$(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT_$(TARGET_ARCH) := \
- $(vndk_snapshot_out)/arch-$(TARGET_ARCH)/shared/vndk-sp
-$(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES_$(TARGET_ARCH) := \
- $(call paths-of-intermediates,$(vndk_sp_libs))
+$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT := $(vndk_snapshot_arch)/shared/vndk-core
+$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES := \
+ $(call paths-of-intermediates,$(vndk_core_libs),SHARED_LIBRARIES)
-ifdef TARGET_2ND_ARCH
-$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT_$(TARGET_2ND_ARCH) := \
- $(vndk_snapshot_out)/arch-$(TARGET_2ND_ARCH)/shared/vndk-core
-$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES_$(TARGET_2ND_ARCH) := \
- $(call paths-of-intermediates,$(vndk_core_libs) $(clang_ubsan_vndk_core_$(TARGET_2ND_ARCH)),true)
-$(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT_$(TARGET_2ND_ARCH) := \
- $(vndk_snapshot_out)/arch-$(TARGET_2ND_ARCH)/shared/vndk-sp
-$(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES_$(TARGET_2ND_ARCH) := \
- $(call paths-of-intermediates,$(vndk_sp_libs),true)
-endif
+$(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT := $(vndk_snapshot_arch)/shared/vndk-sp
+$(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES := \
+ $(call paths-of-intermediates,$(vndk_sp_libs),SHARED_LIBRARIES)
+
+$(vndk_snapshot_zip): PRIVATE_CONFIGS_OUT := $(vndk_snapshot_arch)/configs
+$(vndk_snapshot_zip): PRIVATE_CONFIGS_INTERMEDIATES := \
+ $(call paths-of-intermediates,$(vndk_prebuilt_txts),ETC) \
+ $(vndk_snapshot_configs)
+
+# TODO(b/69834489): Package additional arch variants
+# ifdef TARGET_2ND_ARCH
+# vndk_snapshot_arch_2ND := $(vndk_snapshot_out)/arch-$(TARGET_2ND_ARCH)-$(TARGET_2ND_ARCH_VARIANT)
+# $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT_2ND := $(vndk_snapshot_arch_2ND)/shared/vndk-core
+# $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES_2ND := \
+# $(call paths-of-intermediates,$(vndk_core_libs),SHARED_LIBRARIES,true)
+# $(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT_2ND := $(vndk_snapshot_arch_2ND)/shared/vndk-sp
+# $(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES_2ND := \
+# $(call paths-of-intermediates,$(vndk_sp_libs),SHARED_LIBRARIES,true)
+# endif
# Args
# $(1): destination directory
-# $(2): list of libs to copy
+# $(2): list of files to copy
$(vndk_snapshot_zip): private-copy-vndk-intermediates = \
- @mkdir -p $(1); \
- $(foreach lib,$(2),cp -p $(lib) $(call append-path,$(1),$(subst .vendor,,$(notdir $(lib))));)
+ $(if $(2),$(strip \
+ @mkdir -p $(1); \
+ $(foreach file,$(2), \
+ if [ -e $(file) ]; then \
+ cp -p $(file) $(call append-path,$(1),$(subst .vendor,,$(notdir $(file)))); \
+ fi; \
+ ) \
+ ))
+
+vndk_snapshot_dependencies := \
+ $(vndk_snapshot_libs) \
+ $(vndk_prebuilt_txts) \
+ $(vndk_snapshot_configs)
$(vndk_snapshot_zip): $(vndk_snapshot_dependencies) $(SOONG_ZIP)
@echo 'Generating VNDK snapshot: $@'
@@ -97,16 +160,19 @@
@rm -rf $(PRIVATE_VNDK_SNAPSHOT_OUT)
@mkdir -p $(PRIVATE_VNDK_SNAPSHOT_OUT)
$(call private-copy-vndk-intermediates, \
- $(PRIVATE_VNDK_CORE_OUT_$(TARGET_ARCH)),$(PRIVATE_VNDK_CORE_INTERMEDIATES_$(TARGET_ARCH)))
+ $(PRIVATE_VNDK_CORE_OUT),$(PRIVATE_VNDK_CORE_INTERMEDIATES))
$(call private-copy-vndk-intermediates, \
- $(PRIVATE_VNDK_SP_OUT_$(TARGET_ARCH)),$(PRIVATE_VNDK_SP_INTERMEDIATES_$(TARGET_ARCH)))
-ifdef TARGET_2ND_ARCH
+ $(PRIVATE_VNDK_SP_OUT),$(PRIVATE_VNDK_SP_INTERMEDIATES))
$(call private-copy-vndk-intermediates, \
- $(PRIVATE_VNDK_CORE_OUT_$(TARGET_2ND_ARCH)),$(PRIVATE_VNDK_CORE_INTERMEDIATES_$(TARGET_2ND_ARCH)))
- $(call private-copy-vndk-intermediates, \
- $(PRIVATE_VNDK_SP_OUT_$(TARGET_2ND_ARCH)),$(PRIVATE_VNDK_SP_INTERMEDIATES_$(TARGET_2ND_ARCH)))
-endif
- $(hide) $(SOONG_ZIP) -o $@ -P vndk-snapshot -C $(PRIVATE_VNDK_SNAPSHOT_OUT) \
+ $(PRIVATE_CONFIGS_OUT),$(PRIVATE_CONFIGS_INTERMEDIATES))
+# TODO(b/69834489): Package additional arch variants
+# ifdef TARGET_2ND_ARCH
+# $(call private-copy-vndk-intermediates, \
+# $(PRIVATE_VNDK_CORE_OUT_2ND),$(PRIVATE_VNDK_CORE_INTERMEDIATES_2ND))
+# $(call private-copy-vndk-intermediates, \
+# $(PRIVATE_VNDK_SP_OUT_2ND),$(PRIVATE_VNDK_SP_INTERMEDIATES_2ND))
+# endif
+ $(hide) $(SOONG_ZIP) -o $@ -P android-vndk-snapshot -C $(PRIVATE_VNDK_SNAPSHOT_OUT) \
-D $(PRIVATE_VNDK_SNAPSHOT_OUT)
.PHONY: vndk
@@ -114,6 +180,24 @@
$(call dist-for-goals, vndk, $(vndk_snapshot_zip))
+# clear global vars
+clang-ubsan-vndk-core :=
+paths-of-intermediates :=
+vndk_core_libs :=
+vndk_sp_libs :=
+vndk_snapshot_libs :=
+vndk_prebuilt_txts :=
+vndk_snapshot_configs :=
+vndk_snapshot_top :=
+vndk_snapshot_out :=
+vndk_snapshot_configs_out :=
+vndk_snapshot_arch :=
+vndk_snapshot_dependencies :=
+# TODO(b/69834489): Package additional arch variants
+# ifdef TARGET_2ND_ARCH
+# vndk_snapshot_arch_2ND :=
+# endif
+
else # BOARD_VNDK_VERSION is NOT set to 'current'
.PHONY: vndk
diff --git a/help.sh b/help.sh
index c031dcc..3f39c77 100755
--- a/help.sh
+++ b/help.sh
@@ -15,7 +15,7 @@
m -j [<goals>] # Execute the configured build.
Usage of "m" imitates usage of the program "make".
-See '"${SCRIPT_DIR}"'/README.txt for more info about build usage and concepts.
+See '"${SCRIPT_DIR}"'/Usage.txt for more info about build usage and concepts.
Common goals are:
diff --git a/navbar.md b/navbar.md
new file mode 100644
index 0000000..e218a78
--- /dev/null
+++ b/navbar.md
@@ -0,0 +1,4 @@
+* [Home](/README.md)
+* [Usage](/Usage.txt)
+* [Changes](/Changes.md)
+* [Outdated Reference](/core/build-system.html)
diff --git a/target/board/generic/sepolicy/bootanim.te b/target/board/generic/sepolicy/bootanim.te
index 4be1c8a..b23e1ca 100644
--- a/target/board/generic/sepolicy/bootanim.te
+++ b/target/board/generic/sepolicy/bootanim.te
@@ -2,4 +2,8 @@
allow bootanim ashmem_device:chr_file execute;
#TODO: This can safely be ignored until b/62954877 is fixed
dontaudit bootanim system_data_file:dir read;
+
+allow bootanim vendor_file:file { execute getattr open read };
+allow bootanim graphics_device:chr_file { read ioctl open };
+
set_prop(bootanim, qemu_prop)
diff --git a/target/board/generic/sepolicy/file_contexts b/target/board/generic/sepolicy/file_contexts
index a9b1472..521c65e 100644
--- a/target/board/generic/sepolicy/file_contexts
+++ b/target/board/generic/sepolicy/file_contexts
@@ -22,6 +22,7 @@
/vendor/bin/hw/android\.hardware\.drm@1\.0-service\.widevine u:object_r:hal_drm_widevine_exec:s0
/vendor/lib(64)?/hw/gralloc\.ranchu\.so u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/hw/gralloc\.goldfish\.default\.so u:object_r:same_process_hal_file:s0
/vendor/lib(64)?/libEGL_emulation\.so u:object_r:same_process_hal_file:s0
/vendor/lib(64)?/libGLESv1_CM_emulation\.so u:object_r:same_process_hal_file:s0
/vendor/lib(64)?/libGLESv2_emulation\.so u:object_r:same_process_hal_file:s0
diff --git a/target/board/generic/sepolicy/hal_graphics_allocator_default.te b/target/board/generic/sepolicy/hal_graphics_allocator_default.te
new file mode 100644
index 0000000..0c8e27d
--- /dev/null
+++ b/target/board/generic/sepolicy/hal_graphics_allocator_default.te
@@ -0,0 +1,2 @@
+allow hal_graphics_allocator_default graphics_device:dir search;
+allow hal_graphics_allocator_default graphics_device:chr_file { ioctl open read write };
diff --git a/target/board/treble_common.mk b/target/board/treble_common.mk
index 1ba6726..0296d71 100644
--- a/target/board/treble_common.mk
+++ b/target/board/treble_common.mk
@@ -19,7 +19,6 @@
# VNDK
BOARD_VNDK_VERSION := current
-BOARD_VNDK_RUNTIME_DISABLE := true
# Properties
TARGET_SYSTEM_PROP := build/make/target/board/treble_system.prop
diff --git a/target/product/emulator.mk b/target/product/emulator.mk
index 13b8f28..856ba1a 100644
--- a/target/product/emulator.mk
+++ b/target/product/emulator.mk
@@ -26,6 +26,7 @@
PRODUCT_PACKAGES += \
egl.cfg \
gralloc.goldfish \
+ gralloc.goldfish.default \
gralloc.ranchu \
libGLESv1_CM_emulation \
lib_renderControl_enc \
@@ -35,6 +36,9 @@
libOpenglSystemCommon \
libGLESv2_emulation \
libGLESv1_enc \
+ libEGL_swiftshader \
+ libGLESv1_CM_swiftshader \
+ libGLESv2_swiftshader \
qemu-props \
camera.goldfish \
camera.goldfish.jpeg \
diff --git a/tools/libhost/Android.bp b/tools/libhost/Android.bp
index e5a5ecf..4c9100f 100644
--- a/tools/libhost/Android.bp
+++ b/tools/libhost/Android.bp
@@ -10,6 +10,7 @@
name: "libhost",
target: {
windows: {
+ cflags: ["-Wno-unused-parameter"],
enabled: true,
},
},
diff --git a/tools/libhost/CopyFile.c b/tools/libhost/CopyFile.c
index bd65f1e..f9bda86 100644
--- a/tools/libhost/CopyFile.c
+++ b/tools/libhost/CopyFile.c
@@ -352,7 +352,12 @@
* need to trash it so we can create one.
*/
#if defined(_WIN32)
-extern int copySymlink(const char* src, const char* dst, const struct stat* pSrcStat, unsigned int options) __attribute__((error("no symlinks on Windows")));
+extern int copySymlink(const char* src, const char* dst, const struct stat* pSrcStat, unsigned int options)
+#ifdef __clang__
+ __attribute__((unavailable("no symlinks on Windows")));
+#else
+ __attribute__((error("no symlinks on Windows")));
+#endif
#else
static int copySymlink(const char* src, const char* dst, const struct stat* pSrcStat, unsigned int options)
{
@@ -574,8 +579,10 @@
} else {
retVal = copyDirectory(src, dst, &srcStat, options);
}
+#if !defined(_WIN32)
} else if (S_ISLNK(srcStat.st_mode)) {
retVal = copySymlink(src, dst, &srcStat, options);
+#endif
} else if (S_ISREG(srcStat.st_mode)) {
retVal = copyRegular(src, dst, &srcStat, options);
} else {
diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py
index 1ef55ff..8f06b95 100644
--- a/tools/releasetools/blockimgdiff.py
+++ b/tools/releasetools/blockimgdiff.py
@@ -1178,9 +1178,22 @@
def FindTransfers(self):
"""Parse the file_map to generate all the transfers."""
- def AddSplitTransfers(tgt_name, src_name, tgt_ranges, src_ranges, style,
- by_id):
- """Add one or multiple Transfer()s by splitting large files."""
+ def AddSplitTransfersWithFixedSizeChunks(tgt_name, src_name, tgt_ranges,
+ src_ranges, style, by_id):
+ """Add one or multiple Transfer()s by splitting large files.
+
+ For BBOTA v3, we need to stash source blocks for resumable feature.
+ However, with the growth of file size and the shrink of the cache
+ partition source blocks are too large to be stashed. If a file occupies
+ too many blocks, we split it into smaller pieces by getting multiple
+ Transfer()s.
+
+ The downside is that after splitting, we may increase the package size
+ since the split pieces don't align well. According to our experiments,
+ 1/8 of the cache size as the per-piece limit appears to be optimal.
+ Compared to the fixed 1024-block limit, it reduces the overall package
+ size by 30% for volantis, and 20% for angler and bullhead."""
+
pieces = 0
while (tgt_ranges.size() > max_blocks_per_transfer and
src_ranges.size() > max_blocks_per_transfer):
@@ -1207,21 +1220,15 @@
self.tgt.RangeSha1(tgt_ranges), self.src.RangeSha1(src_ranges),
style, by_id)
- def FindZipsAndAddSplitTransfers(tgt_name, src_name, tgt_ranges,
- src_ranges, style, by_id):
- """Find all the zip archives and add split transfers for the other files.
+ def AddSplitTransfers(tgt_name, src_name, tgt_ranges, src_ranges, style,
+ by_id):
+ """Find all the zip files and split the others with a fixed chunk size.
- For BBOTA v3, we need to stash source blocks for resumable feature.
- However, with the growth of file size and the shrink of the cache
- partition source blocks are too large to be stashed. If a file occupies
- too many blocks, we split it into smaller pieces by getting multiple
- Transfer()s.
-
- The downside is that after splitting, we may increase the package size
- since the split pieces don't align well. According to our experiments,
- 1/8 of the cache size as the per-piece limit appears to be optimal.
- Compared to the fixed 1024-block limit, it reduces the overall package
- size by 30% for volantis, and 20% for angler and bullhead."""
+ This function will construct a list of zip archives, which will later be
+ split by imgdiff to reduce the final patch size. For the other files,
+ we will plainly split them based on a fixed chunk size with the potential
+ patch size penalty.
+ """
assert style == "diff"
@@ -1241,8 +1248,8 @@
large_apks.append((tgt_name, src_name, tgt_ranges, src_ranges))
return
- AddSplitTransfers(tgt_name, src_name, tgt_ranges, src_ranges,
- style, by_id)
+ AddSplitTransfersWithFixedSizeChunks(tgt_name, src_name, tgt_ranges,
+ src_ranges, style, by_id)
def AddTransfer(tgt_name, src_name, tgt_ranges, src_ranges, style, by_id,
split=False):
@@ -1292,7 +1299,7 @@
assert tgt_changed + tgt_skipped.size() == tgt_size
print('%10d %10d (%6.2f%%) %s' % (tgt_skipped.size(), tgt_size,
tgt_skipped.size() * 100.0 / tgt_size, tgt_name))
- FindZipsAndAddSplitTransfers(
+ AddSplitTransfers(
"%s-skipped" % (tgt_name,),
"%s-skipped" % (src_name,),
tgt_skipped, src_skipped, style, by_id)
@@ -1309,7 +1316,7 @@
return
# Add the transfer(s).
- FindZipsAndAddSplitTransfers(
+ AddSplitTransfers(
tgt_name, src_name, tgt_ranges, src_ranges, style, by_id)
def ParseAndValidateSplitInfo(patch_size, tgt_ranges, src_ranges,
@@ -1384,6 +1391,11 @@
be valid because the block ranges of src-X & tgt-X will always stay the
same afterwards; but there's a chance we don't use the patch if we
convert the "diff" command into "new" or "move" later.
+
+ The split will be attempted by calling imgdiff, which expects the input
+ files to be valid zip archives. If imgdiff fails for some reason (i.e.
+ holes in the APK file), we will fall back to split the failed APKs into
+ fixed size chunks.
"""
while True:
@@ -1412,8 +1424,9 @@
print("Failed to create patch between {} and {},"
" falling back to bsdiff".format(src_name, tgt_name))
with transfer_lock:
- AddSplitTransfers(tgt_name, src_name, tgt_ranges, src_ranges,
- "diff", self.transfers)
+ AddSplitTransfersWithFixedSizeChunks(tgt_name, src_name,
+ tgt_ranges, src_ranges,
+ "diff", self.transfers)
continue
with open(patch_info_file) as patch_info: