Add a coverage suffix to avoid Ninja file regeneration.

This CL uses the environment variable, EMMA_INSTRUMENT to determine whether or not coverage is enabled. If coverage is enabled, it adds a bunch of suffixes to the files generated in out/soong/ folders.

This change reduces the build time by avoiding ninja regeneration when users simply switches from atest to atest --experimental-coverage, or vice versa, and no Android.bp changes are made.

Bug: 331444846
Test: Locally run m libc, and then EMMA_INSTRUMENT m libc twice, no ninja regenerations required. Compared the hash of out/target/product/vsoc_x86_64/ between the before-change repo and after-change repo. Only diff is the after-change directory contains an extra file `out/target/product/vsoc_x86_64/.installable_files` while the original directory has only `out/target/product/vsoc_x86_64/.installable_files.previous`, both files have the same hash.
Change-Id: I91eb1134ac552f47a40f3d5ddaab630d146b0773
This commit is contained in:
Qing Shen
2024-08-14 01:21:56 +00:00
parent 0a7e037a9a
commit 2c7fb2df08
5 changed files with 20 additions and 11 deletions

View File

@@ -340,7 +340,7 @@ LOCAL_BUILT_MODULE := $(intermediates)/$(my_built_module_stem)
ifneq (,$(LOCAL_SOONG_INSTALLED_MODULE))
ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
$(call pretty-error, LOCAL_SOONG_INSTALLED_MODULE can only be used from $(SOONG_ANDROID_MK))
$(call pretty-error, LOCAL_MODULE_MAKEFILE can only be used from $(SOONG_ANDROID_MK))
endif
# Use the install path requested by Soong.
LOCAL_INSTALLED_MODULE := $(LOCAL_SOONG_INSTALLED_MODULE)

View File

@@ -1252,8 +1252,15 @@ include $(BUILD_SYSTEM)/sysprop_config.mk
# consistency with those defined in BoardConfig.mk files.
include $(BUILD_SYSTEM)/android_soong_config_vars.mk
SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.$(TARGET_PRODUCT).variables
SOONG_EXTRA_VARIABLES := $(SOONG_OUT_DIR)/soong.$(TARGET_PRODUCT).extra.variables
# EMMA_INSTRUMENT is set to true when coverage is enabled. Creates a suffix to
# differeciate the coverage version of ninja files. This will save 5 minutes of
# build time used to regenerate ninja.
ifeq (true,$(EMMA_INSTRUMENT))
COVERAGE_SUFFIX := .coverage
endif
SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.$(TARGET_PRODUCT)$(COVERAGE_SUFFIX).variables
SOONG_EXTRA_VARIABLES := $(SOONG_OUT_DIR)/soong.$(TARGET_PRODUCT)$(COVERAGE_SUFFIX).extra.variables
ifeq ($(CALLED_FROM_SETUP),true)
include $(BUILD_SYSTEM)/ninja_config.mk

View File

@@ -1,4 +1,4 @@
DEX_PREOPT_CONFIG := $(SOONG_OUT_DIR)/dexpreopt.config
DEX_PREOPT_CONFIG := $(SOONG_OUT_DIR)/dexpreopt${COVERAGE_SUFFIX}.config
ENABLE_PREOPT := true
ENABLE_PREOPT_BOOT_IMAGES := true

View File

@@ -31,8 +31,7 @@ endif
.KATI_READONLY := $(foreach n,$(SOONG_CONFIG_NAMESPACES),SOONG_CONFIG_$(n))
.KATI_READONLY := $(foreach n,$(SOONG_CONFIG_NAMESPACES),$(foreach k,$(SOONG_CONFIG_$(n)),SOONG_CONFIG_$(n)_$(k)))
include $(SOONG_MAKEVARS_MK)
include $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT)$(COVERAGE_SUFFIX).mk
YACC :=$= $(BISON) -d
include $(BUILD_SYSTEM)/clang/config.mk
@@ -276,12 +275,15 @@ FULL_BUILD := true
# Include all of the makefiles in the system
#
subdir_makefiles := $(SOONG_OUT_DIR)/installs-$(TARGET_PRODUCT).mk $(SOONG_ANDROID_MK)
subdir_makefiles := $(SOONG_OUT_DIR)/installs-$(TARGET_PRODUCT)$(COVERAGE_SUFFIX).mk $(SOONG_ANDROID_MK)
# Android.mk files are only used on Linux builds, Mac only supports Android.bp
ifeq ($(HOST_OS),linux)
subdir_makefiles += $(file <$(OUT_DIR)/.module_paths/Android.mk.list)
endif
subdir_makefiles += $(SOONG_OUT_DIR)/late-$(TARGET_PRODUCT).mk
subdir_makefiles += $(SOONG_OUT_DIR)/late-$(TARGET_PRODUCT)$(COVERAGE_SUFFIX).mk
subdir_makefiles_total := $(words int $(subdir_makefiles) post finish)
.KATI_READONLY := subdir_makefiles_total

View File

@@ -1,5 +1,5 @@
SOONG_MAKEVARS_MK := $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT).mk
SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android-$(TARGET_PRODUCT).mk
SOONG_MAKEVARS_MK := $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT)$(COVERAGE_SUFFIX).mk
SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android-$(TARGET_PRODUCT)$(COVERAGE_SUFFIX).mk
include $(BUILD_SYSTEM)/art_config.mk
include $(BUILD_SYSTEM)/dex_preopt_config.mk
@@ -26,7 +26,7 @@ ifeq ($(WRITE_SOONG_VARIABLES),true)
$(shell mkdir -p $(dir $(SOONG_VARIABLES)))
$(call json_start)
$(call add_json_str, Make_suffix, -$(TARGET_PRODUCT))
$(call add_json_str, Make_suffix, -$(TARGET_PRODUCT)$(COVERAGE_SUFFIX))
$(call add_json_str, BuildId, $(BUILD_ID))
$(call add_json_str, BuildFingerprintFile, build_fingerprint.txt)