Merge "Handle zygote_32_64 in gsi_release.mk"
diff --git a/CleanSpec.mk b/CleanSpec.mk
index cbfca3e..426e25d 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -638,6 +638,14 @@
# Move odm build.prop to /odm/etc/.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/odm/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/odm/build.prop)
+
+# Move product and system_ext to root for emulators
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/generic*/*/product)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/generic*/*/system_ext)
+
+# link_type and jni_link_type files are no longer needed
+$(call add-clean-step, find $(OUT_DIR) -type f -name "*link_type" -print0 | xargs -0 rm -f)
+
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
diff --git a/Usage.txt b/Usage.txt
index 558329b..ea4788a 100644
--- a/Usage.txt
+++ b/Usage.txt
@@ -26,12 +26,6 @@
If no targets are specified, the build system will build the images
for the configured product and variant.
- An alternative to setting $TARGET_PRODUCT and $TARGET_BUILD_VARIANT,
- which you may see in build servers, is to execute:
-
- m PRODUCT-<product>-<variant>
-
-
A target may be a file path. For example, out/host/linux-x86/bin/adb .
Note that when giving a relative file path as a target, that path is
interpreted relative to the root of the source tree (rather than relative
diff --git a/core/Makefile b/core/Makefile
index e9cd51f..40c374f 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1172,7 +1172,8 @@
.PHONY: notice_files
# Create the rule to combine the files into text and html/xml forms
-# $(1) - xml_excluded_vendor_product|xml_vendor|xml_product|xml_odm|html
+# $(1) - xml_excluded_system_product_odm|xml_excluded_vendor_product_odm
+# xml_product|xml_odm|xml_system_ext|xml_system|html
# $(2) - Plain text output file
# $(3) - HTML/XML output file
# $(4) - File title
@@ -1197,12 +1198,13 @@
$(2) : $(3)
$(3) : $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
build/make/tools/generate-notice-files.py --text-output $(2) \
- $(if $(filter $(1),xml_excluded_extra_partitions),-e vendor -e product -e system_ext -e odm --xml-output, \
- $(if $(filter $(1),xml_vendor),-i vendor --xml-output, \
+ $(if $(filter $(1),xml_excluded_vendor_product_odm),-e vendor -e product -e system_ext -e odm --xml-output, \
+ $(if $(filter $(1),xml_excluded_system_product_odm),-e system -e product -e system_ext -e odm --xml-output, \
$(if $(filter $(1),xml_product),-i product --xml-output, \
$(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
- $(if $(filter $(1),xml_odm),-i odm --xml-output, \
- --html-output))))) $(3) \
+ $(if $(filter $(1),xml_system),-i system --xml-output, \
+ $(if $(filter $(1),xml_odm),-i odm --xml-output, \
+ --html-output)))))) $(3) \
-t $$(PRIVATE_MESSAGE) -s $$(PRIVATE_DIR)/src
notice_files: $(2) $(3)
endef
@@ -1268,26 +1270,40 @@
license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
# testcases are not relevant to the system image.
license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
+license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
-license_modules_agg := $(license_modules_vendor) \
+license_modules_agg := $(license_modules_system) \
+ $(license_modules_vendor) \
$(license_modules_product) \
$(license_modules_system_ext) \
$(license_modules_odm)
license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
-$(eval $(call combine-notice-files, xml_excluded_extra_partitions, \
+# If we are building in a configuration that includes a prebuilt vendor.img, we can't
+# update its notice file, so include those notices in the system partition instead
+ifdef BOARD_PREBUILT_VENDORIMAGE
+license_modules_system += $(license_modules_rest)
+system_xml_directories := xml_excluded_vendor_product_odm
+system_notice_file_message := "Notices for files contained in all filesystem images except vendor/system_ext/product/odm in this directory:"
+else
+license_modules_vendor += $(license_modules_rest)
+system_xml_directories := xml_system
+system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
+endif
+
+$(eval $(call combine-notice-files, $(system_xml_directories), \
$(target_notice_file_txt), \
$(target_notice_file_xml), \
- "Notices for files contained in the filesystem images in this directory:", \
+ $(system_notice_file_message), \
$(TARGET_OUT_NOTICE_FILES), \
- $(license_modules_rest)))
-$(eval $(call combine-notice-files, xml_vendor, \
+ $(license_modules_system)))
+$(eval $(call combine-notice-files, xml_excluded_system_product_odm, \
$(target_vendor_notice_file_txt), \
$(target_vendor_notice_file_xml), \
- "Notices for files contained in the vendor filesystem image in this directory:", \
+ "Notices for files contained in all filesystem images except system/system_ext/product/odm in this directory:", \
$(TARGET_OUT_NOTICE_FILES), \
$(license_modules_vendor)))
$(eval $(call combine-notice-files, xml_product, \
@@ -1330,19 +1346,14 @@
$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
$(copy-file-to-target)
-# if we've been run my mm, mmm, etc, don't reinstall this every time
-ifeq ($(ONE_SHOT_MAKEFILE),)
- ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
- ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
- ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
- ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
- ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
-endif
+ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
+ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
+ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
+ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
+ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
endif # PRODUCT_NOTICE_SPLIT
-ifeq ($(ONE_SHOT_MAKEFILE),)
- ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
-endif
+ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
$(eval $(call combine-notice-files, html, \
$(tools_notice_file_txt), \
@@ -4676,11 +4687,12 @@
$(if $(INTERNAL_SUPERIMAGE_MISC_INFO), zip -q -j -u $@ $(INTERNAL_SUPERIMAGE_MISC_INFO))
$(if $(INTERNAL_SUPERIMAGE_DIST_TARGET), zip -q -j -u $@ $(INTERNAL_SUPERIMAGE_DIST_TARGET))
else
-$(INTERNAL_UPDATE_PACKAGE_TARGET):
+$(INTERNAL_UPDATE_PACKAGE_TARGET): $(INSTALLED_MISC_INFO_TARGET)
@echo "Package: $@"
$(hide) $(ZIP2ZIP) -i $(BUILT_TARGET_FILES_PACKAGE) -o $@ \
IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
OTA/android-info.txt:android-info.txt "IMAGES/*.img:."
+ $(if $(INSTALLED_MISC_INFO_TARGET), zip -q -j -u $@ $(INSTALLED_MISC_INFO_TARGET))
endif # BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE
.PHONY: updatepackage
diff --git a/core/binary.mk b/core/binary.mk
index 531e4c3..874a4d3 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -1403,15 +1403,9 @@
# libraries have already been linked into the module at that point.
# We do, however, care about the NOTICE files for any static
# libraries that we use. (see notice_files.mk)
-#
-# Don't do this in mm, since many of the targets won't exist.
-ifeq ($(ONE_SHOT_MAKEFILE),)
installed_static_library_notice_file_targets := \
$(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-STATIC_LIBRARIES-$(lib))
-else
-installed_static_library_notice_file_targets :=
-endif
$(notice_target): | $(installed_static_library_notice_file_targets)
$(LOCAL_INSTALLED_MODULE): | $(notice_target)
@@ -1614,7 +1608,9 @@
ifeq ($(my_use_clang_lld),true)
my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LLDFLAGS)
include $(BUILD_SYSTEM)/pack_dyn_relocs_setup.mk
- ifeq ($(my_pack_module_relocations),false)
+ ifeq ($(my_pack_module_relocations),true)
+ my_target_global_ldflags += -Wl,--pack-dyn-relocs=android+relr -Wl,--use-android-relr-tags
+ else
my_target_global_ldflags += -Wl,--pack-dyn-relocs=none
endif
else
diff --git a/core/board_config.mk b/core/board_config.mk
index f7dc557..4045c71 100644
--- a/core/board_config.mk
+++ b/core/board_config.mk
@@ -193,20 +193,29 @@
# Note that this assumes that the 2ND_CPU_ABI for a 64 bit target
# is always 32 bits. If this isn't the case, these variables should
# be overriden in the board configuration.
+#
+# Similarly, TARGET_NATIVE_BRIDGE_2ND_ABI for a 64 bit target is always
+# 32 bits. Note that all CPU_ABIs are preferred over all NATIVE_BRIDGE_ABIs.
+_target_native_bridge_abi_list_32_bit :=
+_target_native_bridge_abi_list_64_bit :=
+
ifeq (,$(TARGET_CPU_ABI_LIST_64_BIT))
ifeq (true|true,$(TARGET_IS_64_BIT)|$(TARGET_SUPPORTS_64_BIT_APPS))
TARGET_CPU_ABI_LIST_64_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
+ _target_native_bridge_abi_list_64_bit := $(TARGET_NATIVE_BRIDGE_ABI)
endif
endif
ifeq (,$(TARGET_CPU_ABI_LIST_32_BIT))
ifneq (true,$(TARGET_IS_64_BIT))
TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
+ _target_native_bridge_abi_list_32_bit := $(TARGET_NATIVE_BRIDGE_ABI)
else
ifeq (true,$(TARGET_SUPPORTS_32_BIT_APPS))
# For a 64 bit target, assume that the 2ND_CPU_ABI
# is a 32 bit ABI.
TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_2ND_CPU_ABI) $(TARGET_2ND_CPU_ABI2)
+ _target_native_bridge_abi_list_32_bit := $(TARGET_NATIVE_BRIDGE_2ND_ABI)
endif
endif
endif
@@ -215,14 +224,21 @@
# of preference) that the target supports. If a TARGET_CPU_ABI_LIST
# is specified by the board configuration, we use that. If not, we
# build a list out of the TARGET_CPU_ABIs specified by the config.
+# Add NATIVE_BRIDGE_ABIs at the end to keep order of preference.
ifeq (,$(TARGET_CPU_ABI_LIST))
ifeq ($(TARGET_IS_64_BIT)|$(TARGET_PREFER_32_BIT_APPS),true|true)
- TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_32_BIT) $(TARGET_CPU_ABI_LIST_64_BIT)
+ TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_32_BIT) $(TARGET_CPU_ABI_LIST_64_BIT) \
+ $(_target_native_bridge_abi_list_32_bit) $(_target_native_bridge_abi_list_64_bit)
else
- TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_64_BIT) $(TARGET_CPU_ABI_LIST_32_BIT)
+ TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_64_BIT) $(TARGET_CPU_ABI_LIST_32_BIT) \
+ $(_target_native_bridge_abi_list_64_bit) $(_target_native_bridge_abi_list_32_bit)
endif
endif
+# Add NATIVE_BRIDGE_ABIs at the end of 32 and 64 bit CPU_ABIs to keep order of preference.
+TARGET_CPU_ABI_LIST_32_BIT += $(_target_native_bridge_abi_list_32_bit)
+TARGET_CPU_ABI_LIST_64_BIT += $(_target_native_bridge_abi_list_64_bit)
+
# Strip whitespace from the ABI list string.
TARGET_CPU_ABI_LIST := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST)))
TARGET_CPU_ABI_LIST_32_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_32_BIT)))
diff --git a/core/config.mk b/core/config.mk
index a6a76cb..ee87632 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -118,6 +118,7 @@
ARCH_X86_HAVE_SSE4_2 \
ARCH_X86_HAVE_SSSE3 \
)
+$(KATI_obsolete_var PRODUCT_IOT)
# Used to force goals to build. Only use for conditionally defined goals.
.PHONY: FORCE
@@ -137,6 +138,9 @@
.KATI_READONLY := TARGET_DEVICE_DIR
endif
+ONE_SHOT_MAKEFILE :=
+.KATI_READONLY := ONE_SHOT_MAKEFILE
+
# Set up efficient math functions which are used in make.
# Here since this file is included by envsetup as well as during build.
include $(BUILD_SYSTEM_COMMON)/math.mk
@@ -469,9 +473,6 @@
ifneq ($(filter true,$(SOONG_ALLOW_MISSING_DEPENDENCIES)),)
ALLOW_MISSING_DEPENDENCIES := true
endif
-ifneq ($(ONE_SHOT_MAKEFILE),)
-ALLOW_MISSING_DEPENDENCIES := true
-endif
.KATI_READONLY := ALLOW_MISSING_DEPENDENCIES
TARGET_BUILD_APPS_USE_PREBUILT_SDK :=
@@ -484,7 +485,6 @@
prebuilt_sdk_tools := prebuilts/sdk/tools
prebuilt_sdk_tools_bin := $(prebuilt_sdk_tools)/$(HOST_OS)/bin
-# Always use prebuilts for ckati and makeparallel
prebuilt_build_tools := prebuilts/build-tools
prebuilt_build_tools_wrappers := prebuilts/build-tools/common/bin
prebuilt_build_tools_jars := prebuilts/build-tools/common/framework
@@ -542,7 +542,6 @@
FILESLIST := $(SOONG_HOST_OUT_EXECUTABLES)/fileslist
FILESLIST_UTIL :=$= build/make/tools/fileslist_util.py
HOST_INIT_VERIFIER := $(HOST_OUT_EXECUTABLES)/host_init_verifier
-MAKEPARALLEL := $(prebuilt_build_tools_bin)/makeparallel
SOONG_JAVAC_WRAPPER := $(SOONG_HOST_OUT_EXECUTABLES)/soong_javac_wrapper
SOONG_ZIP := $(SOONG_HOST_OUT_EXECUTABLES)/soong_zip
MERGE_ZIPS := $(SOONG_HOST_OUT_EXECUTABLES)/merge_zips
@@ -605,7 +604,6 @@
JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
DATA_BINDING_COMPILER := $(HOST_OUT_JAVA_LIBRARIES)/databinding-compiler.jar
FAT16COPY := build/make/tools/fat16copy.py
-CHECK_LINK_TYPE := build/make/tools/check_link_type.py
CHECK_ELF_FILE := build/make/tools/check_elf_file.py
LPMAKE := $(HOST_OUT_EXECUTABLES)/lpmake$(HOST_EXECUTABLE_SUFFIX)
BUILD_IMAGE := $(HOST_OUT_EXECUTABLES)/build_image$(HOST_EXECUTABLE_SUFFIX)
diff --git a/core/definitions.mk b/core/definitions.mk
index e44f51d..16bec84 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2322,6 +2322,7 @@
PACKAGING=$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING ANDROID_LOG_TAGS="*:e" $(ART_VERIDEX_APPCOMPAT_SCRIPT) --dex-file=$@ --api-flags=$(INTERNAL_PLATFORM_HIDDENAPI_FLAGS) 2>&1 >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log
endef
appcompat-files = \
+ $(AAPT2) \
$(ART_VERIDEX_APPCOMPAT_SCRIPT) \
$(INTERNAL_PLATFORM_HIDDENAPI_FLAGS) \
$(HOST_OUT_EXECUTABLES)/veridex \
diff --git a/core/envsetup.mk b/core/envsetup.mk
index 05957cd..3e8fd3f 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -82,8 +82,6 @@
# ---------------------------------------------------------------
# The product defaults to generic on hardware
-# NOTE: This will be overridden in product_config.mk if make
-# was invoked with a PRODUCT-xxx-yyy goal.
ifeq ($(TARGET_PRODUCT),)
TARGET_PRODUCT := aosp_arm
endif
@@ -94,6 +92,13 @@
TARGET_BUILD_VARIANT := eng
endif
+TARGET_BUILD_APPS ?=
+
+.KATI_READONLY := \
+ TARGET_PRODUCT \
+ TARGET_BUILD_VARIANT \
+ TARGET_BUILD_APPS
+
# ---------------------------------------------------------------
# Set up configuration for host machine. We don't do cross-
# compiles except for arm/mips, so the HOST is whatever we are
diff --git a/core/java_common.mk b/core/java_common.mk
index ff2886e..cb88a9e 100644
--- a/core/java_common.mk
+++ b/core/java_common.mk
@@ -494,13 +494,9 @@
##########################################################
# Copy NOTICE files of transitive static dependencies
# Don't do this in mm, since many of the targets won't exist.
-ifeq ($(ONE_SHOT_MAKEFILE),)
installed_static_library_notice_file_targets := \
$(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-JAVA_LIBRARIES-$(lib))
-else
-installed_static_library_notice_file_targets :=
-endif
$(notice_target): | $(installed_static_library_notice_file_targets)
$(LOCAL_INSTALLED_MODULE): | $(notice_target)
diff --git a/core/main.mk b/core/main.mk
index b7b6cd0..9f4b86c 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -10,22 +10,11 @@
endif
ifndef KATI
-
-host_prebuilts := linux-x86
-ifeq ($(shell uname),Darwin)
-host_prebuilts := darwin-x86
+$(warning Calling make directly is no longer supported.)
+$(warning Either use 'envsetup.sh; m' or 'build/soong/soong_ui.bash --make-mode')
+$(error done)
endif
-.PHONY: run_soong_ui
-run_soong_ui:
- +@prebuilts/build-tools/$(host_prebuilts)/bin/makeparallel --ninja build/soong/soong_ui.bash --make-mode $(MAKECMDGOALS)
-
-.PHONY: $(MAKECMDGOALS)
-$(sort $(MAKECMDGOALS)) : run_soong_ui
- @#empty
-
-else # KATI
-
$(info [1/1] initializing build system ...)
# Absolute path of the present working direcotry.
@@ -102,6 +91,8 @@
-include test/sts/tools/sts-tradefed/build/config.mk
# CTS-Instant-specific config
-include test/suite_harness/tools/cts-instant-tradefed/build/config.mk
+# MTS-specific config.
+-include test/mts/tools/build/config.mk
# Clean rules
.PHONY: clean-dex-files
@@ -194,6 +185,8 @@
$(error stopping)
endif
+# These are the valid values of TARGET_BUILD_VARIANT.
+INTERNAL_VALID_VARIANTS := user userdebug eng
ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
$(info ***************************************************************)
$(info ***************************************************************)
@@ -438,43 +431,6 @@
subdir_makefiles_inc := .
FULL_BUILD :=
-ifneq ($(ONE_SHOT_MAKEFILE),)
-# We've probably been invoked by the "mm" shell function
-# with a subdirectory's makefile.
-include $(SOONG_ANDROID_MK) $(wildcard $(ONE_SHOT_MAKEFILE))
-# Change CUSTOM_MODULES to include only modules that were
-# defined by this makefile; this will install all of those
-# modules as a side-effect. Do this after including ONE_SHOT_MAKEFILE
-# so that the modules will be installed in the same place they
-# would have been with a normal make.
-CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))
-
-# A helper goal printing out install paths
-define register_module_install_path
-.PHONY: GET-MODULE-INSTALL-PATH-$(1)
-GET-MODULE-INSTALL-PATH-$(1):
- echo 'INSTALL-PATH: $(1) $(ALL_MODULES.$(1).INSTALLED)'
-endef
-
-SORTED_ALL_MODULES := $(sort $(ALL_MODULES))
-UNIQUE_ALL_MODULES :=
-$(foreach m,$(SORTED_ALL_MODULES),\
- $(if $(call streq,$(m),$(lastword $(UNIQUE_ALL_MODULES))),,\
- $(eval UNIQUE_ALL_MODULES += $(m))))
-SORTED_ALL_MODULES :=
-
-$(foreach mod,$(UNIQUE_ALL_MODULES),$(if $(ALL_MODULES.$(mod).INSTALLED),\
- $(eval $(call register_module_install_path,$(mod)))\
- $(foreach path,$(ALL_MODULES.$(mod).PATH),\
- $(eval my_path_prefix := GET-INSTALL-PATH-IN)\
- $(foreach component,$(subst /,$(space),$(path)),\
- $(eval my_path_prefix := $$(my_path_prefix)-$$(component))\
- $(eval .PHONY: $$(my_path_prefix))\
- $(eval $$(my_path_prefix): GET-MODULE-INSTALL-PATH-$(mod))))))
-UNIQUE_ALL_MODULES :=
-
-else # ONE_SHOT_MAKEFILE
-
ifneq ($(dont_bother),true)
FULL_BUILD := true
#
@@ -496,8 +452,6 @@
endif # dont_bother
-endif # ONE_SHOT_MAKEFILE
-
ifndef subdir_makefiles_total
subdir_makefiles_total := $(words init post finish)
endif
@@ -723,7 +677,7 @@
$(eval req_files := )\
$(foreach req_mod,$(req_mods), \
$(eval req_file := $(filter $(TARGET_OUT_ROOT)/%, $(call module-installed-files,$(req_mod)))) \
- $(if $(strip $(req_file))$(ONE_SHOT_MAKEFILE),\
+ $(if $(strip $(req_file)),\
,\
$(error $(m).LOCAL_TARGET_REQUIRED_MODULES : illegal value $(req_mod) : not a device module. If you want to specify host modules to be required to be installed along with your host module, add those module names to LOCAL_REQUIRED_MODULES instead)\
)\
@@ -749,7 +703,7 @@
$(eval req_files := )\
$(foreach req_mod,$(req_mods), \
$(eval req_file := $(filter $(HOST_OUT)/%, $(call module-installed-files,$(req_mod)))) \
- $(if $(strip $(req_file))$(ONE_SHOT_MAKEFILE),\
+ $(if $(strip $(req_file)),\
,\
$(error $(m).LOCAL_HOST_REQUIRED_MODULES : illegal value $(req_mod) : not a host module. If you want to specify target modules to be required to be installed along with your target module, add those module names to LOCAL_REQUIRED_MODULES instead)\
)\
@@ -1018,45 +972,6 @@
$(error exiting from previous errors)
endif
-# The intermediate filename for link type rules
-#
-# APPS are special -- they have up to three different rules:
-# 1. The COMMON rule for Java libraries
-# 2. The jni_link_type rule for embedded native code
-# 3. The 2ND_jni_link_type for the second architecture native code
-define link-type-file
-$(eval _ltf_aux_variant:=$(link-type-aux-variant))\
-$(if $(_ltf_aux_variant),$(call aux-variant-load-env,$(_ltf_aux_variant)))\
-$(call intermediates-dir-for,$(link-type-class),$(link-type-name),$(filter AUX HOST HOST_CROSS,$(link-type-prefix)),$(link-type-common),$(link-type-2ndarchprefix),$(filter HOST_CROSS,$(link-type-prefix)))/$(if $(filter APPS,$(link-type-class)),$(if $(link-type-common),,$(link-type-2ndarchprefix)jni_))link_type\
-$(if $(_ltf_aux_variant),$(call aux-variant-load-env,none))\
-$(eval _ltf_aux_variant:=)
-endef
-
-# Write out the file-based link_type rules for the ALLOW_MISSING_DEPENDENCIES
-# case. We always need to write the file for mm to work, but only need to
-# check it if we weren't able to check it when reading the Android.mk files.
-define link-type-file-rule
-my_link_type_deps := $(foreach l,$($(1).DEPS),$(call link-type-file,$(l)))
-my_link_type_file := $(call link-type-file,$(1))
-$($(1).BUILT): | $$(my_link_type_file)
-$$(my_link_type_file): PRIVATE_DEPS := $$(my_link_type_deps)
-ifeq ($($(1).MISSING),true)
-$$(my_link_type_file): $(CHECK_LINK_TYPE)
-endif
-$$(my_link_type_file): $$(my_link_type_deps)
- @echo Check module type: $$@
- $$(hide) mkdir -p $$(dir $$@) && rm -f $$@
-ifeq ($($(1).MISSING),true)
- $$(hide) $(CHECK_LINK_TYPE) --makefile $($(1).MAKEFILE) --module $(link-type-name) \
- --type "$($(1).TYPE)" $(addprefix --allowed ,$($(1).ALLOWED)) \
- $(addprefix --warn ,$($(1).WARN)) $$(PRIVATE_DEPS)
-endif
- $$(hide) echo "$($(1).TYPE)" >$$@
-endef
-
-$(foreach lt,$(ALL_LINK_TYPES),\
- $(eval $(call link-type-file-rule,$(lt))))
-
# -------------------------------------------------------------------
# Figure out our module sets.
#
@@ -1893,5 +1808,3 @@
$(call dist-write-file,$(KATI_PACKAGE_MK_DIR)/dist.mk)
$(info [$(call inc_and_print,subdir_makefiles_inc)/$(subdir_makefiles_total)] writing build rules ...)
-
-endif # KATI
diff --git a/core/ninja_config.mk b/core/ninja_config.mk
index 85a7568..b1f4b03 100644
--- a/core/ninja_config.mk
+++ b/core/ninja_config.mk
@@ -7,7 +7,7 @@
KATI_OUTPUT_PATTERNS := $(OUT_DIR)/build%.ninja $(OUT_DIR)/ninja%.sh
# Modifier goals we don't need to pass to Ninja.
-NINJA_EXCLUDE_GOALS := all PRODUCT-%
+NINJA_EXCLUDE_GOALS := all
# A list of goals which affect parsing of makefiles and we need to pass to Kati.
PARSE_TIME_MAKE_GOALS := \
@@ -55,7 +55,7 @@
include $(wildcard vendor/*/build/ninja_config.mk)
# Any Android goals that need to be built.
-ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(CKATI) $(MAKEPARALLEL),\
+ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS),\
$(sort $(ORIGINAL_MAKECMDGOALS) $(MAKECMDGOALS)))
# Goals we need to pass to Ninja.
NINJA_GOALS := $(filter-out $(NINJA_EXCLUDE_GOALS), $(ANDROID_GOALS))
diff --git a/core/pack_dyn_relocs_setup.mk b/core/pack_dyn_relocs_setup.mk
index c5564b1..f86e11e 100644
--- a/core/pack_dyn_relocs_setup.mk
+++ b/core/pack_dyn_relocs_setup.mk
@@ -32,3 +32,12 @@
# Do not pack relocations on host modules
my_pack_module_relocations := false
endif
+
+# Lld relocation packing cannot be enabled for binaries before Android Pie.
+ifneq ($(LOCAL_SDK_VERSION),)
+ ifneq ($(LOCAL_SDK_VERSION),current)
+ ifeq ($(call math_lt,$(LOCAL_SDK_VERSION),28),true)
+ my_pack_module_relocations := false
+ endif
+ endif
+endif
diff --git a/core/product.mk b/core/product.mk
index 1afd26b..c54583d 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -280,9 +280,6 @@
# Make this art variable visible to soong_config.mk.
_product_single_value_vars += PRODUCT_ART_USE_READ_BARRIER
-# Whether the product is an Android Things variant.
-_product_single_value_vars += PRODUCT_IOT
-
# Add reserved headroom to a system image.
_product_single_value_vars += PRODUCT_SYSTEM_HEADROOM
diff --git a/core/product_config.mk b/core/product_config.mk
index 21d6a16..1293c94 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -78,78 +78,18 @@
endef
# ---------------------------------------------------------------
-
-# These are the valid values of TARGET_BUILD_VARIANT. Also, if anything else is passed
-# as the variant in the PRODUCT-$TARGET_BUILD_PRODUCT-$TARGET_BUILD_VARIANT form,
-# it will be treated as a goal, and the eng variant will be used.
-INTERNAL_VALID_VARIANTS := user userdebug eng
-
-# ---------------------------------------------------------------
-# Provide "PRODUCT-<prodname>-<goal>" targets, which lets you build
-# a particular configuration without needing to set up the environment.
-#
+# Check for obsolete PRODUCT- and APP- goals
ifeq ($(CALLED_FROM_SETUP),true)
product_goals := $(strip $(filter PRODUCT-%,$(MAKECMDGOALS)))
ifdef product_goals
- # Scrape the product and build names out of the goal,
- # which should be of the form PRODUCT-<productname>-<buildname>.
- #
- ifneq ($(words $(product_goals)),1)
- $(error Only one PRODUCT-* goal may be specified; saw "$(product_goals)")
- endif
- goal_name := $(product_goals)
- product_goals := $(patsubst PRODUCT-%,%,$(product_goals))
- product_goals := $(subst -, ,$(product_goals))
- ifneq ($(words $(product_goals)),2)
- $(error Bad PRODUCT-* goal "$(goal_name)")
- endif
-
- # The product they want
- TARGET_PRODUCT := $(word 1,$(product_goals))
-
- # The variant they want
- TARGET_BUILD_VARIANT := $(word 2,$(product_goals))
-
- ifeq ($(TARGET_BUILD_VARIANT),tests)
- $(error "tests" has been deprecated as a build variant. Use it as a build goal instead.)
- endif
-
- # The build server wants to do make PRODUCT-dream-sdk
- # which really means TARGET_PRODUCT=dream make sdk.
- ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
- override MAKECMDGOALS := $(MAKECMDGOALS) $(TARGET_BUILD_VARIANT)
- TARGET_BUILD_VARIANT := userdebug
- default_goal_substitution :=
- else
- default_goal_substitution := droid
- endif
-
- # Replace the PRODUCT-* goal with the build goal that it refers to.
- # Note that this will ensure that it appears in the same relative
- # position, in case it matters.
- override MAKECMDGOALS := $(patsubst $(goal_name),$(default_goal_substitution),$(MAKECMDGOALS))
+ $(error The PRODUCT-* goal is no longer supported. Use `TARGET_PRODUCT=<product> m droid` instead)
endif
-endif # CALLED_FROM_SETUP
-# else: Use the value set in the environment or buildspec.mk.
-
-# ---------------------------------------------------------------
-# Provide "APP-<appname>" targets, which lets you build
-# an unbundled app.
-#
-ifeq ($(CALLED_FROM_SETUP),true)
unbundled_goals := $(strip $(filter APP-%,$(MAKECMDGOALS)))
ifdef unbundled_goals
$(error The APP-* goal is no longer supported. Use `TARGET_BUILD_APPS="<app>" m droid` instead)
endif # unbundled_goals
endif
-# Now that we've parsed APP-* and PRODUCT-*, mark these as readonly
-TARGET_BUILD_APPS ?=
-.KATI_READONLY := \
- TARGET_PRODUCT \
- TARGET_BUILD_VARIANT \
- TARGET_BUILD_APPS
-
# Default to building dalvikvm on hosts that support it...
ifeq ($(HOST_OS),linux)
# ... or if the if the option is already set
diff --git a/core/soong_config.mk b/core/soong_config.mk
index 3e60a83..6737472 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -136,8 +136,6 @@
$(call add_json_bool, VndkUseCoreVariant, $(TARGET_VNDK_USE_CORE_VARIANT))
-$(call add_json_bool, Product_is_iot, $(filter true,$(PRODUCT_IOT)))
-
$(call add_json_bool, Treble_linker_namespaces, $(filter true,$(PRODUCT_TREBLE_LINKER_NAMESPACES)))
$(call add_json_bool, Enforce_vintf_manifest, $(filter true,$(PRODUCT_ENFORCE_VINTF_MANIFEST)))
diff --git a/core/tasks/module-info.mk b/core/tasks/module-info.mk
index eb31380..f6cec15 100644
--- a/core/tasks/module-info.mk
+++ b/core/tasks/module-info.mk
@@ -24,10 +24,6 @@
$(hide) echo '}' >> $@
-# If ONE_SHOT_MAKEFILE is set, our view of the world is smaller, so don't
-# rewrite the file in that came.
-ifndef ONE_SHOT_MAKEFILE
droidcore: $(MODULE_INFO_JSON)
-endif
$(call dist-for-goals, general-tests, $(MODULE_INFO_JSON))
diff --git a/core/tasks/mts.mk b/core/tasks/mts.mk
new file mode 100644
index 0000000..56b2390
--- /dev/null
+++ b/core/tasks/mts.mk
@@ -0,0 +1,23 @@
+# Copyright (C) 2019 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+test_suite_name := mts
+test_suite_tradefed := mts-tradefed
+test_suite_readme := test/mts/README.md
+
+include $(BUILD_SYSTEM)/tasks/tools/compatibility.mk
+
+.PHONY: mts
+mts: $(compatibility_zip)
+$(call dist-for-goals, mts, $(compatibility_zip))
diff --git a/core/tasks/sdk-addon.mk b/core/tasks/sdk-addon.mk
index 62d9aa6..7f777a5 100644
--- a/core/tasks/sdk-addon.mk
+++ b/core/tasks/sdk-addon.mk
@@ -14,8 +14,6 @@
.PHONY: sdk_addon
-ifndef ONE_SHOT_MAKEFILE
-
# If they didn't define PRODUCT_SDK_ADDON_NAME, then we won't define
# any of these rules.
addon_name := $(PRODUCT_SDK_ADDON_NAME)
@@ -150,5 +148,3 @@
$(error Trying to build sdk_addon, but product '$(INTERNAL_PRODUCT)' does not define one)
endif
endif # addon_name
-
-endif # !ONE_SHOT_MAKEFILE
diff --git a/target/board/BoardConfigEmuCommon.mk b/target/board/BoardConfigEmuCommon.mk
index ac21918..76cb470 100644
--- a/target/board/BoardConfigEmuCommon.mk
+++ b/target/board/BoardConfigEmuCommon.mk
@@ -37,7 +37,9 @@
BOARD_SUPER_PARTITION_GROUPS := emulator_dynamic_partitions
BOARD_EMULATOR_DYNAMIC_PARTITIONS_PARTITION_LIST := \
system \
- vendor
+ vendor \
+ product \
+ system_ext
# 3G
BOARD_EMULATOR_DYNAMIC_PARTITIONS_SIZE := 3221225472
@@ -55,6 +57,11 @@
BOARD_VENDORIMAGE_PARTITION_SIZE := 146800640
endif
+TARGET_COPY_OUT_PRODUCT := product
+BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE := ext4
+TARGET_COPY_OUT_SYSTEM_EXT := system_ext
+BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE := ext4
+
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_FLASH_BLOCK_SIZE := 512
DEVICE_MATRIX_FILE := device/generic/goldfish/compatibility_matrix.xml
diff --git a/tools/check_builds.sh b/tools/check_builds.sh
deleted file mode 100644
index 7e4ea7c..0000000
--- a/tools/check_builds.sh
+++ /dev/null
@@ -1,92 +0,0 @@
-# Copyright (C) 2009 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the 'License');
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an 'AS IS' BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#
-# Usage:
-#
-# Source this file into your environment. Then:
-#
-# $ golden_builds sdk-sdk generic-eng generic-userdebug dream-eng
-#
-# will build a set of combos. This might take a while. Then you can
-# go make changes, and run:
-#
-# $ check_builds sdk-sdk generic-eng generic-userdebug dream-eng
-#
-# Go get dinner, and when you get back, there will be a file
-# test-builds/sizes.html that has a pretty chart of which files are
-# in which tree, and how big they are. In that chart, cells for files
-# that are missing are red, and rows where the file sizes are not all
-# the same will be blue.
-#
-
-TEST_BUILD_DIR=test-builds
-
-function do_builds
-{
- PREFIX=$1
- shift
- while [ -n "$1" ]
- do
- rm -rf $TEST_BUILD_DIR/$PREFIX-$1
- make PRODUCT-$(echo $1 | sed "s/-.*//" )-installclean
- make -j16 PRODUCT-$1 dist DIST_DIR=$TEST_BUILD_DIR/$PREFIX-$1
- if [ $? -ne 0 ] ; then
- echo FAILED
- return
- fi
- shift
- done
-}
-
-function golden_builds
-{
- rm -rf $TEST_BUILD_DIR/golden-* $TEST_BUILD_DIR/dist-*
- do_builds golden "$@"
-}
-
-function compare_builds
-{
- local inputs=
- while [ -n "$1" ]
- do
- inputs="$inputs $TEST_BUILD_DIR/golden-$1/installed-files.txt"
- inputs="$inputs $TEST_BUILD_DIR/dist-$1/installed-files.txt"
- shift
- done
- build/make/tools/compare_fileslist.py $inputs > $TEST_BUILD_DIR/sizes.html
-}
-
-function check_builds
-{
- rm -rf $TEST_BUILD_DIR/dist-*
- do_builds dist "$@"
- compare_builds "$@"
-}
-
-function diff_builds
-{
- local inputs=
- while [ -n "$1" ]
- do
- diff $TEST_BUILD_DIR/golden-$1/installed-files.txt $TEST_BUILD_DIR/dist-$1/installed-files.txt &> /dev/null
- if [ $? != 0 ]; then
- echo =========== $1 ===========
- diff $TEST_BUILD_DIR/golden-$1/installed-files.txt $TEST_BUILD_DIR/dist-$1/installed-files.txt
- fi
- shift
- done
- build/make/tools/compare_fileslist.py $inputs > $TEST_BUILD_DIR/sizes.html
-}
-
diff --git a/tools/check_link_type.py b/tools/check_link_type.py
deleted file mode 100755
index 40754ad..0000000
--- a/tools/check_link_type.py
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Utility to verify modules link against acceptable module types"""
-
-from __future__ import print_function
-import argparse
-import os
-import sys
-
-WARNING_MSG = ('\033[1m%(makefile)s: \033[35mwarning:\033[0m\033[1m '
- '%(module)s (%(type)s) should not link to %(dep_name)s (%(dep_type)s)'
- '\033[0m')
-ERROR_MSG = ('\033[1m%(makefile)s: \033[31merror:\033[0m\033[1m '
- '%(module)s (%(type)s) should not link to %(dep_name)s (%(dep_type)s)'
- '\033[0m')
-
-def parse_args():
- """Parse commandline arguments."""
- parser = argparse.ArgumentParser(description='Check link types')
- parser.add_argument('--makefile', help='Makefile defining module')
- parser.add_argument('--module', help='The module being checked')
- parser.add_argument('--type', help='The link type of module')
- parser.add_argument('--allowed', help='Allow deps to use these types',
- action='append', default=[], metavar='TYPE')
- parser.add_argument('--warn', help='Warn if deps use these types',
- action='append', default=[], metavar='TYPE')
- parser.add_argument('deps', help='The dependencies to check',
- metavar='DEP', nargs='*')
- return parser.parse_args()
-
-def print_msg(msg, args, dep_name, dep_type):
- """Print a warning or error message"""
- print(msg % {
- "makefile": args.makefile,
- "module": args.module,
- "type": args.type,
- "dep_name": dep_name,
- "dep_type": dep_type}, file=sys.stderr)
-
-def main():
- """Program entry point."""
- args = parse_args()
-
- failed = False
- for dep in args.deps:
- dep_name = os.path.basename(os.path.dirname(dep))
- if dep_name.endswith('_intermediates'):
- dep_name = dep_name[:len(dep_name)-len('_intermediates')]
-
- with open(dep, 'r') as dep_file:
- dep_types = dep_file.read().strip().split(' ')
-
- for dep_type in dep_types:
- if dep_type in args.allowed:
- continue
- if dep_type in args.warn:
- print_msg(WARNING_MSG, args, dep_name, dep_type)
- else:
- print_msg(ERROR_MSG, args, dep_name, dep_type)
- failed = True
-
- if failed:
- sys.exit(1)
-
-if __name__ == '__main__':
- main()
diff --git a/tools/generate-self-extracting-archive.py b/tools/generate-self-extracting-archive.py
new file mode 100755
index 0000000..f0b7568
--- /dev/null
+++ b/tools/generate-self-extracting-archive.py
@@ -0,0 +1,165 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2019 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Generates a self extracting archive with a license click through.
+
+Usage:
+ generate-self-extracting-archive.py $OUTPUT_FILE $INPUT_ARCHIVE $COMMENT $LICENSE_FILE
+
+ The comment will be included at the beginning of the output archive file.
+
+Output:
+ The output of the script is a single executable file that when run will
+ display the provided license and if the user accepts extract the wrapped
+ archive.
+
+ The layout of the output file is roughly:
+ * Executable shell script that extracts the archive
+ * Actual archive contents
+ * Zip file containing the license
+"""
+
+import tempfile
+import sys
+import os
+import zipfile
+
+_HEADER_TEMPLATE = """#!/bin/sh
+#
+{comment_line}
+#
+# Usage is subject to the enclosed license agreement
+
+echo
+echo The license for this software will now be displayed.
+echo You must agree to this license before using this software.
+echo
+echo -n Press Enter to view the license
+read dummy
+echo
+more << EndOfLicense
+{license}
+EndOfLicense
+
+if test $? != 0
+then
+ echo "ERROR: Couldn't display license file" 1>&2
+ exit 1
+fi
+echo
+echo -n 'Type "I ACCEPT" if you agree to the terms of the license: '
+read typed
+if test "$typed" != "I ACCEPT"
+then
+ echo
+ echo "You didn't accept the license. Extraction aborted."
+ exit 2
+fi
+echo
+{extract_command}
+if test $? != 0
+then
+ echo
+ echo "ERROR: Couldn't extract files." 1>&2
+ exit 3
+else
+ echo
+ echo "Files extracted successfully."
+fi
+exit 0
+"""
+
+_PIPE_CHUNK_SIZE = 1048576
+def _pipe_bytes(src, dst):
+ while True:
+ b = src.read(_PIPE_CHUNK_SIZE)
+ if not b:
+ break
+ dst.write(b)
+
+_MAX_OFFSET_WIDTH = 8
+def _generate_extract_command(start, end, extract_name):
+ """Generate the extract command.
+
+ The length of this string must be constant no matter what the start and end
+ offsets are so that its length can be computed before the actual command is
+ generated.
+
+ Args:
+ start: offset in bytes of the start of the wrapped file
+ end: offset in bytes of the end of the wrapped file
+ extract_name: of the file to create when extracted
+
+ """
+ # start gets an extra character for the '+'
+ # for tail +1 is the start of the file, not +0
+ start_str = ('+%d' % (start + 1)).rjust(_MAX_OFFSET_WIDTH + 1)
+ if len(start_str) != _MAX_OFFSET_WIDTH + 1:
+ raise Exception('Start offset too large (%d)' % start)
+
+ end_str = ('%d' % end).rjust(_MAX_OFFSET_WIDTH)
+ if len(end_str) != _MAX_OFFSET_WIDTH:
+ raise Exception('End offset too large (%d)' % end)
+
+ return "tail -c %s $0 | head -c %s > %s\n" % (start_str, end_str, extract_name)
+
+
+def main(argv):
+ output_filename = argv[1]
+ input_archive_filename = argv[2]
+ comment = argv[3]
+ license_filename = argv[4]
+
+ input_archive_size = os.stat(input_archive_filename).st_size
+
+ with open(license_filename, 'r') as license_file:
+ license = license_file.read()
+
+ comment_line = '# %s\n' % comment
+ extract_name = os.path.basename(input_archive_filename)
+
+ # Compute the size of the header before writing the file out. This is required
+ # so that the extract command, which uses the contents offset, can be created
+ # and included inside the header.
+ header_for_size = _HEADER_TEMPLATE.format(
+ comment_line=comment_line,
+ license=license,
+ extract_command=_generate_extract_command(0, 0, extract_name),
+ )
+ header_size = len(header_for_size.encode('utf-8'))
+
+ # write the final output
+ with open(output_filename, 'wb') as output:
+ output.write(_HEADER_TEMPLATE.format(
+ comment_line=comment_line,
+ license=license,
+ extract_command=_generate_extract_command(header_size, input_archive_size, extract_name),
+ ).encode('utf-8'))
+
+ with open(input_archive_filename, 'rb') as input_file:
+ _pipe_bytes(input_file, output)
+
+ with tempfile.TemporaryFile() as trailing_zip:
+ with zipfile.ZipFile(trailing_zip, 'w') as myzip:
+ myzip.writestr('license.txt', license, compress_type=zipfile.ZIP_STORED)
+
+ # append the trailing zip to the end of the file
+ trailing_zip.seek(0)
+ _pipe_bytes(trailing_zip, output)
+
+if __name__ == "__main__":
+ main(sys.argv)
diff --git a/tools/makeparallel/.gitignore b/tools/makeparallel/.gitignore
deleted file mode 100644
index a7d6181..0000000
--- a/tools/makeparallel/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-makeparallel
-*.o
-*.d
-test.out
diff --git a/tools/makeparallel/Android.bp b/tools/makeparallel/Android.bp
deleted file mode 100644
index 898db68..0000000
--- a/tools/makeparallel/Android.bp
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2016 Google Inc. All rights reserved
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-cc_binary_host {
- name: "makeparallel",
- srcs: [
- "makeparallel.cpp",
- ],
- cflags: ["-Wall", "-Werror"],
-}
diff --git a/tools/makeparallel/Makefile b/tools/makeparallel/Makefile
deleted file mode 100644
index 82a4abf..0000000
--- a/tools/makeparallel/Makefile
+++ /dev/null
@@ -1,93 +0,0 @@
-# Copyright 2015 Google Inc. All rights reserved
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Find source file location from path to this Makefile
-MAKEPARALLEL_SRC_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
-ifndef MAKEPARALLEL_SRC_PATH
- MAKEPARALLEL_SRC_PATH := .
-endif
-
-# Set defaults if they weren't set by the including Makefile
-MAKEPARALLEL_CXX ?= $(CXX)
-MAKEPARALLEL_LD ?= $(CXX)
-MAKEPARALLEL_INTERMEDIATES_PATH ?= .
-MAKEPARALLEL_BIN_PATH ?= .
-
-MAKEPARALLEL_CXX_SRCS := \
- makeparallel.cpp
-
-MAKEPARALLEL_CXXFLAGS := -Wall -Werror -MMD -MP
-
-MAKEPARALLEL_CXX_SRCS := $(addprefix $(MAKEPARALLEL_SRC_PATH)/,\
- $(MAKEPARALLEL_CXX_SRCS))
-
-MAKEPARALLEL_CXX_OBJS := $(patsubst $(MAKEPARALLEL_SRC_PATH)/%.cpp,$(MAKEPARALLEL_INTERMEDIATES_PATH)/%.o,$(MAKEPARALLEL_CXX_SRCS))
-
-MAKEPARALLEL := $(MAKEPARALLEL_BIN_PATH)/makeparallel
-
-ifeq ($(shell uname),Linux)
-MAKEPARALLEL_LIBS := -lrt -lpthread
-endif
-
-# Rule to build makeparallel into MAKEPARALLEL_BIN_PATH
-$(MAKEPARALLEL): $(MAKEPARALLEL_CXX_OBJS)
- @mkdir -p $(dir $@)
- $(MAKEPARALLEL_LD) -std=c++11 $(MAKEPARALLEL_CXXFLAGS) -o $@ $^ $(MAKEPARALLEL_LIBS)
-
-# Rule to build source files into object files in MAKEPARALLEL_INTERMEDIATES_PATH
-$(MAKEPARALLEL_CXX_OBJS): $(MAKEPARALLEL_INTERMEDIATES_PATH)/%.o: $(MAKEPARALLEL_SRC_PATH)/%.cpp
- @mkdir -p $(dir $@)
- $(MAKEPARALLEL_CXX) -c -std=c++11 $(MAKEPARALLEL_CXXFLAGS) -o $@ $<
-
-makeparallel_clean:
- rm -rf $(MAKEPARALLEL)
- rm -rf $(MAKEPARALLEL_INTERMEDIATES_PATH)/*.o
- rm -rf $(MAKEPARALLEL_INTERMEDIATES_PATH)/*.d
-
-.PHONY: makeparallel_clean
-
--include $(MAKEPARALLEL_INTERMEDIATES_PATH)/*.d
-
-.PHONY: makeparallel_test
-MAKEPARALLEL_TEST := MAKEFLAGS= MAKELEVEL= MAKEPARALLEL=$(MAKEPARALLEL) $(MAKE) -f Makefile.test test
-MAKEPARALLEL_NINJA_TEST := MAKEFLAGS= MAKELEVEL= MAKEPARALLEL="$(MAKEPARALLEL) --ninja" $(MAKE) -f Makefile.test test
-makeparallel_test: $(MAKEPARALLEL)
- @EXPECTED="-j1234" $(MAKEPARALLEL_TEST) -j1234
- @EXPECTED="-j123" $(MAKEPARALLEL_TEST) -j123
- @EXPECTED="" $(MAKEPARALLEL_TEST) -j1
- @EXPECTED="-j$$(($$(nproc) + 2))" $(MAKEPARALLEL_TEST) -j
- @EXPECTED="" $(MAKEPARALLEL_TEST)
-
- @EXPECTED="-j1234" $(MAKEPARALLEL_NINJA_TEST) -j1234
- @EXPECTED="-j123" $(MAKEPARALLEL_NINJA_TEST) -j123
- @EXPECTED="-j1" $(MAKEPARALLEL_NINJA_TEST) -j1
- @EXPECTED="-j1" $(MAKEPARALLEL_NINJA_TEST)
- @EXPECTED="" $(MAKEPARALLEL_NINJA_TEST) -j
- @EXPECTED="" $(MAKEPARALLEL_NINJA_TEST) -j -l
-
- @EXPECTED="-j1234" $(MAKEPARALLEL_TEST) --no-print-directory -j1234
- @EXPECTED="-j1234" $(MAKEPARALLEL_TEST) --no-print-directory -k -j1234
- @EXPECTED="-j1234" $(MAKEPARALLEL_TEST) -k -j1234
- @EXPECTED="-j1234" $(MAKEPARALLEL_TEST) -j1234 -k
- @EXPECTED="-j1234" $(MAKEPARALLEL_TEST) -kt -j1234
-
- @EXPECTED="-j1234" $(MAKEPARALLEL_NINJA_TEST) --no-print-directory -j1234
- @EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) --no-print-directory -k -j1234
- @EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) -k -j1234
- @EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) -j1234 -k
- @EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) -kt -j1234
-
- @EXPECTED="" $(MAKEPARALLEL_TEST) A=-j1234
-
- @EXPECTED="-j1234 args" ARGS="args" $(MAKEPARALLEL_TEST) -j1234
diff --git a/tools/makeparallel/Makefile.test b/tools/makeparallel/Makefile.test
deleted file mode 100644
index cf53684..0000000
--- a/tools/makeparallel/Makefile.test
+++ /dev/null
@@ -1,12 +0,0 @@
-MAKEPARALLEL ?= ./makeparallel
-
-.PHONY: test
-test:
- @+echo MAKEFLAGS=$${MAKEFLAGS}; \
- result=$$($(MAKEPARALLEL) echo $(ARGS)); \
- echo result: $${result}; \
- if [ "$${result}" = "$(EXPECTED)" ]; then \
- echo SUCCESS && echo; \
- else \
- echo FAILED expected $(EXPECTED) && false; \
- fi
diff --git a/tools/makeparallel/README.md b/tools/makeparallel/README.md
deleted file mode 100644
index 2e5fbf9..0000000
--- a/tools/makeparallel/README.md
+++ /dev/null
@@ -1,54 +0,0 @@
-<!---
-Copyright (C) 2015 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-
-makeparallel
-============
-makeparallel communicates with the [GNU make jobserver](http://make.mad-scientist.net/papers/jobserver-implementation/)
-in order claim all available jobs, and then passes the number of jobs
-claimed to a subprocess with `-j<jobs>`.
-
-The number of available jobs is determined by reading tokens from the jobserver
-until a read would block. If the makeparallel rule is the only one running the
-number of jobs will be the total size of the jobserver pool, i.e. the value
-passed to make with `-j`. Any jobs running in parallel with with the
-makeparellel rule will reduce the measured value, and thus reduce the
-parallelism available to the subprocess.
-
-To run a multi-thread or multi-process binary inside GNU make using
-makeparallel, add
-```Makefile
- +makeparallel subprocess arguments
-```
-to a rule. For example, to wrap ninja in make, use something like:
-```Makefile
- +makeparallel ninja -f build.ninja
-```
-
-To determine the size of the jobserver pool, add
-```Makefile
- +makeparallel echo > make.jobs
-```
-to a rule that is guarantee to run alone (i.e. all other rules are either
-dependencies of the makeparallel rule, or the depend on the makeparallel
-rule. The output file will contain the `-j<num>` flag passed to the parent
-make process, or `-j1` if no flag was found. Since GNU make will run
-makeparallel during the execution phase, after all variables have been
-set and evaluated, it is not possible to get the output of makeparallel
-into a make variable. Instead, use a shell substitution to read the output
-file directly in a recipe. For example:
-```Makefile
- echo Make was started with $$(cat make.jobs)
-```
diff --git a/tools/makeparallel/makeparallel.cpp b/tools/makeparallel/makeparallel.cpp
deleted file mode 100644
index 66babdf..0000000
--- a/tools/makeparallel/makeparallel.cpp
+++ /dev/null
@@ -1,421 +0,0 @@
-// Copyright (C) 2015 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// makeparallel communicates with the GNU make jobserver
-// (http://make.mad-scientist.net/papers/jobserver-implementation/)
-// in order claim all available jobs, and then passes the number of jobs
-// claimed to a subprocess with -j<jobs>.
-
-#include <errno.h>
-#include <fcntl.h>
-#include <getopt.h>
-#include <poll.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/resource.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include <string>
-#include <vector>
-
-#ifdef __linux__
-#include <error.h>
-#endif
-
-#ifdef __APPLE__
-#include <err.h>
-#define error(code, eval, fmt, ...) errc(eval, code, fmt, ##__VA_ARGS__)
-// Darwin does not interrupt syscalls by default.
-#define TEMP_FAILURE_RETRY(exp) (exp)
-#endif
-
-// Throw an error if fd is not valid.
-static void CheckFd(int fd) {
- int ret = fcntl(fd, F_GETFD);
- if (ret < 0) {
- if (errno == EBADF) {
- error(errno, 0, "no jobserver pipe, prefix recipe command with '+'");
- } else {
- error(errno, errno, "fnctl failed");
- }
- }
-}
-
-// Extract flags from MAKEFLAGS that need to be propagated to subproccess
-static std::vector<std::string> ReadMakeflags() {
- std::vector<std::string> args;
-
- const char* makeflags_env = getenv("MAKEFLAGS");
- if (makeflags_env == nullptr) {
- return args;
- }
-
- // The MAKEFLAGS format is pretty useless. The first argument might be empty
- // (starts with a leading space), or it might be a set of one-character flags
- // merged together with no leading space, or it might be a variable
- // definition.
-
- std::string makeflags = makeflags_env;
-
- // Split makeflags into individual args on spaces. Multiple spaces are
- // elided, but an initial space will result in a blank arg.
- size_t base = 0;
- size_t found;
- do {
- found = makeflags.find_first_of(" ", base);
- args.push_back(makeflags.substr(base, found - base));
- base = found + 1;
- } while (found != makeflags.npos);
-
- // Drop the first argument if it is empty
- while (args.size() > 0 && args[0].size() == 0) {
- args.erase(args.begin());
- }
-
- // Prepend a - to the first argument if it does not have one and is not a
- // variable definition
- if (args.size() > 0 && args[0][0] != '-') {
- if (args[0].find('=') == makeflags.npos) {
- args[0] = '-' + args[0];
- }
- }
-
- return args;
-}
-
-static bool ParseMakeflags(std::vector<std::string>& args,
- int* in_fd, int* out_fd, bool* parallel, bool* keep_going) {
-
- std::vector<char*> getopt_argv;
- // getopt starts reading at argv[1]
- getopt_argv.reserve(args.size() + 1);
- getopt_argv.push_back(strdup(""));
- for (std::string& v : args) {
- getopt_argv.push_back(strdup(v.c_str()));
- }
-
- opterr = 0;
- optind = 1;
- while (1) {
- const static option longopts[] = {
- {"jobserver-fds", required_argument, 0, 0},
- {0, 0, 0, 0},
- };
- int longopt_index = 0;
-
- int c = getopt_long(getopt_argv.size(), getopt_argv.data(), "kj",
- longopts, &longopt_index);
-
- if (c == -1) {
- break;
- }
-
- switch (c) {
- case 0:
- switch (longopt_index) {
- case 0:
- {
- // jobserver-fds
- if (sscanf(optarg, "%d,%d", in_fd, out_fd) != 2) {
- error(EXIT_FAILURE, 0, "incorrect format for --jobserver-fds: %s", optarg);
- }
- // TODO: propagate in_fd, out_fd
- break;
- }
- default:
- abort();
- }
- break;
- case 'j':
- *parallel = true;
- break;
- case 'k':
- *keep_going = true;
- break;
- case '?':
- // ignore unknown arguments
- break;
- default:
- abort();
- }
- }
-
- for (char *v : getopt_argv) {
- free(v);
- }
-
- return true;
-}
-
-// Read a single byte from fd, with timeout in milliseconds. Returns true if
-// a byte was read, false on timeout. Throws away the read value.
-// Non-reentrant, uses timer and signal handler global state, plus static
-// variable to communicate with signal handler.
-//
-// Uses a SIGALRM timer to fire a signal after timeout_ms that will interrupt
-// the read syscall if it hasn't yet completed. If the timer fires before the
-// read the read could block forever, so read from a dup'd fd and close it from
-// the signal handler, which will cause the read to return EBADF if it occurs
-// after the signal.
-// The dup/read/close combo is very similar to the system described to avoid
-// a deadlock between SIGCHLD and read at
-// http://make.mad-scientist.net/papers/jobserver-implementation/
-static bool ReadByteTimeout(int fd, int timeout_ms) {
- // global variable to communicate with the signal handler
- static int dup_fd = -1;
-
- // dup the fd so the signal handler can close it without losing the real one
- dup_fd = dup(fd);
- if (dup_fd < 0) {
- error(errno, errno, "dup failed");
- }
-
- // set up a signal handler that closes dup_fd on SIGALRM
- struct sigaction action = {};
- action.sa_flags = SA_SIGINFO,
- action.sa_sigaction = [](int, siginfo_t*, void*) {
- close(dup_fd);
- };
- struct sigaction oldaction = {};
- int ret = sigaction(SIGALRM, &action, &oldaction);
- if (ret < 0) {
- error(errno, errno, "sigaction failed");
- }
-
- // queue a SIGALRM after timeout_ms
- const struct itimerval timeout = {{}, {0, timeout_ms * 1000}};
- ret = setitimer(ITIMER_REAL, &timeout, NULL);
- if (ret < 0) {
- error(errno, errno, "setitimer failed");
- }
-
- // start the blocking read
- char buf;
- int read_ret = read(dup_fd, &buf, 1);
- int read_errno = errno;
-
- // cancel the alarm in case it hasn't fired yet
- const struct itimerval cancel = {};
- ret = setitimer(ITIMER_REAL, &cancel, NULL);
- if (ret < 0) {
- error(errno, errno, "reset setitimer failed");
- }
-
- // remove the signal handler
- ret = sigaction(SIGALRM, &oldaction, NULL);
- if (ret < 0) {
- error(errno, errno, "reset sigaction failed");
- }
-
- // clean up the dup'd fd in case the signal never fired
- close(dup_fd);
- dup_fd = -1;
-
- if (read_ret == 0) {
- error(EXIT_FAILURE, 0, "EOF on jobserver pipe");
- } else if (read_ret > 0) {
- return true;
- } else if (read_errno == EINTR || read_errno == EBADF) {
- return false;
- } else {
- error(read_errno, read_errno, "read failed");
- }
- abort();
-}
-
-// Measure the size of the jobserver pool by reading from in_fd until it blocks
-static int GetJobserverTokens(int in_fd) {
- int tokens = 0;
- pollfd pollfds[] = {{in_fd, POLLIN, 0}};
- int ret;
- while ((ret = TEMP_FAILURE_RETRY(poll(pollfds, 1, 0))) != 0) {
- if (ret < 0) {
- error(errno, errno, "poll failed");
- } else if (pollfds[0].revents != POLLIN) {
- error(EXIT_FAILURE, 0, "unexpected event %d\n", pollfds[0].revents);
- }
-
- // There is probably a job token in the jobserver pipe. There is a chance
- // another process reads it first, which would cause a blocking read to
- // block forever (or until another process put a token back in the pipe).
- // The file descriptor can't be set to O_NONBLOCK as that would affect
- // all users of the pipe, including the parent make process.
- // ReadByteTimeout emulates a non-blocking read on a !O_NONBLOCK socket
- // using a SIGALRM that fires after a short timeout.
- bool got_token = ReadByteTimeout(in_fd, 10);
- if (!got_token) {
- // No more tokens
- break;
- } else {
- tokens++;
- }
- }
-
- // This process implicitly gets a token, so pool size is measured size + 1
- return tokens;
-}
-
-// Return tokens to the jobserver pool.
-static void PutJobserverTokens(int out_fd, int tokens) {
- // Return all the tokens to the pipe
- char buf = '+';
- for (int i = 0; i < tokens; i++) {
- int ret = TEMP_FAILURE_RETRY(write(out_fd, &buf, 1));
- if (ret < 0) {
- error(errno, errno, "write failed");
- } else if (ret == 0) {
- error(EXIT_FAILURE, 0, "EOF on jobserver pipe");
- }
- }
-}
-
-int main(int argc, char* argv[]) {
- int in_fd = -1;
- int out_fd = -1;
- bool parallel = false;
- bool keep_going = false;
- bool ninja = false;
- int tokens = 0;
-
- if (argc > 1 && strcmp(argv[1], "--ninja") == 0) {
- ninja = true;
- argv++;
- argc--;
- }
-
- if (argc < 2) {
- error(EXIT_FAILURE, 0, "expected command to run");
- }
-
- const char* path = argv[1];
- std::vector<char*> args({argv[1]});
-
- std::vector<std::string> makeflags = ReadMakeflags();
- if (ParseMakeflags(makeflags, &in_fd, &out_fd, ¶llel, &keep_going)) {
- if (in_fd >= 0 && out_fd >= 0) {
- CheckFd(in_fd);
- CheckFd(out_fd);
- fcntl(in_fd, F_SETFD, FD_CLOEXEC);
- fcntl(out_fd, F_SETFD, FD_CLOEXEC);
- tokens = GetJobserverTokens(in_fd);
- }
- }
-
- std::string jarg;
- if (parallel) {
- if (tokens == 0) {
- if (ninja) {
- // ninja is parallel by default
- jarg = "";
- } else {
- // make -j with no argument, guess a reasonable parallelism like ninja does
- jarg = "-j" + std::to_string(sysconf(_SC_NPROCESSORS_ONLN) + 2);
- }
- } else {
- jarg = "-j" + std::to_string(tokens + 1);
- }
- }
-
-
- if (ninja) {
- if (!parallel) {
- // ninja is parallel by default, pass -j1 to disable parallelism if make wasn't parallel
- args.push_back(strdup("-j1"));
- } else {
- if (jarg != "") {
- args.push_back(strdup(jarg.c_str()));
- }
- }
- if (keep_going) {
- args.push_back(strdup("-k0"));
- }
- } else {
- if (jarg != "") {
- args.push_back(strdup(jarg.c_str()));
- }
- }
-
- args.insert(args.end(), &argv[2], &argv[argc]);
-
- args.push_back(nullptr);
-
- static pid_t pid;
-
- // Set up signal handlers to forward SIGTERM to child.
- // Assume that all other signals are sent to the entire process group,
- // and that we'll wait for our child to exit instead of handling them.
- struct sigaction action = {};
- action.sa_flags = SA_RESTART;
- action.sa_handler = [](int signal) {
- if (signal == SIGTERM && pid > 0) {
- kill(pid, signal);
- }
- };
-
- int ret = 0;
- if (!ret) ret = sigaction(SIGHUP, &action, NULL);
- if (!ret) ret = sigaction(SIGINT, &action, NULL);
- if (!ret) ret = sigaction(SIGQUIT, &action, NULL);
- if (!ret) ret = sigaction(SIGTERM, &action, NULL);
- if (!ret) ret = sigaction(SIGALRM, &action, NULL);
- if (ret < 0) {
- error(errno, errno, "sigaction failed");
- }
-
- pid = fork();
- if (pid < 0) {
- error(errno, errno, "fork failed");
- } else if (pid == 0) {
- // child
- unsetenv("MAKEFLAGS");
- unsetenv("MAKELEVEL");
-
- // make 3.81 sets the stack ulimit to unlimited, which may cause problems
- // for child processes
- struct rlimit rlim{};
- if (getrlimit(RLIMIT_STACK, &rlim) == 0 && rlim.rlim_cur == RLIM_INFINITY) {
- rlim.rlim_cur = 8*1024*1024;
- setrlimit(RLIMIT_STACK, &rlim);
- }
-
- int ret = execvp(path, args.data());
- if (ret < 0) {
- error(errno, errno, "exec %s failed", path);
- }
- abort();
- }
-
- // parent
-
- siginfo_t status = {};
- int exit_status = 0;
- ret = waitid(P_PID, pid, &status, WEXITED);
- if (ret < 0) {
- error(errno, errno, "waitpid failed");
- } else if (status.si_code == CLD_EXITED) {
- exit_status = status.si_status;
- } else {
- exit_status = -(status.si_status);
- }
-
- if (tokens > 0) {
- PutJobserverTokens(out_fd, tokens);
- }
- exit(exit_status);
-}
diff --git a/tools/releasetools/test_utils.py b/tools/releasetools/test_utils.py
index 1e919f7..2445671 100755
--- a/tools/releasetools/test_utils.py
+++ b/tools/releasetools/test_utils.py
@@ -32,9 +32,12 @@
logging.basicConfig(stream=sys.stdout)
# Use ANDROID_BUILD_TOP as an indicator to tell if the needed tools (e.g.
-# avbtool, mke2fs) are available while running the tests. Not having the var or
-# having empty string means we can't run the tests that require external tools.
-EXTERNAL_TOOLS_UNAVAILABLE = not os.environ.get("ANDROID_BUILD_TOP")
+# avbtool, mke2fs) are available while running the tests, unless
+# FORCE_RUN_RELEASETOOLS is set to '1'. Not having the required vars means we
+# can't run the tests that require external tools.
+EXTERNAL_TOOLS_UNAVAILABLE = (
+ not os.environ.get('ANDROID_BUILD_TOP') and
+ os.environ.get('FORCE_RUN_RELEASETOOLS') != '1')
def SkipIfExternalToolsUnavailable():