From 3715001fe5493fc06d5f846c022f32d5cd86e99e Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Mon, 15 May 2017 13:32:43 -0700 Subject: [PATCH 1/4] Allow disabling of CleanSpec functionality This is only intended for testing purposes -- so that we can run build system tests and verify that kati only gets run once for each configuration. CleanSpecs necessarily write state that require us to re-run kati twice. Test: export NO_ANDROID_CLEANSPEC=true; rm -rf out; m -j; m -j Change-Id: I635a8d8b6754dff82fbc7f20c500d06d7cf6c4f2 --- core/cleanbuild.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk index fa89758a4..3a909337b 100644 --- a/core/cleanbuild.mk +++ b/core/cleanbuild.mk @@ -14,7 +14,7 @@ # # Don't bother with the cleanspecs if you are running mm/mmm -ifeq ($(ONE_SHOT_MAKEFILE)$(dont_bother),) +ifeq ($(ONE_SHOT_MAKEFILE)$(dont_bother)$(NO_ANDROID_CLEANSPEC),) INTERNAL_CLEAN_STEPS := @@ -142,7 +142,7 @@ rewrite_clean_steps_file := INTERNAL_CLEAN_STEPS := INTERNAL_CLEAN_BUILD_VERSION := -endif # if not ONE_SHOT_MAKEFILE dont_bother +endif # if not ONE_SHOT_MAKEFILE dont_bother NO_ANDROID_CLEANSPEC # Since products and build variants (unfortunately) share the same # PRODUCT_OUT staging directory, things can get out of sync if different From bd8ac3284d1b87805fc35c167e405c10652f66a3 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Fri, 12 May 2017 19:28:46 -0700 Subject: [PATCH 2/4] Move clean/clobber to soong_ui So that we don't have to load up all the makefile state just to remove the output directory. Starting from a completely empty out directory: kati: 16s soong_ui: 2.0s From a minimal out directory (m -j blueprint_tools): kati: 3.8s soong_ui: 0.4s Test: m -j clean Test: m -j clobber Change-Id: Iec1ce032c7cc7ed102430080e857fc421b66309c --- core/config.mk | 2 +- core/main.mk | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/core/config.mk b/core/config.mk index 583909d57..86915a6ba 100644 --- a/core/config.mk +++ b/core/config.mk @@ -847,7 +847,7 @@ endef # These goals don't need to collect and include Android.mks/CleanSpec.mks # in the source tree. -dont_bother_goals := clean clobber dataclean installclean \ +dont_bother_goals := dataclean installclean \ help out \ snod systemimage-nodeps \ stnod systemtarball-nodeps \ diff --git a/core/main.mk b/core/main.mk index 6089cec39..5bc8b3bb9 100644 --- a/core/main.mk +++ b/core/main.mk @@ -1270,14 +1270,6 @@ endif # samplecode in $(MAKECMDGOALS) .PHONY: findbugs findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET) -.PHONY: clean -clean: - @rm -rf $(OUT_DIR)/* - @echo "Entire build directory removed." - -.PHONY: clobber -clobber: clean - # The rules for dataclean and installclean are defined in cleanbuild.mk. #xxx scrape this from ALL_MODULE_NAME_TAGS From 3eb44160e0b90d974d1415829dae87726838e44e Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Fri, 12 May 2017 16:32:18 -0700 Subject: [PATCH 3/4] Move version checking to soong_ui This removes versions_checked.mk that caused kati to regenerate the ninja file 3 times for a clean out directory. Kati needs to regenerate every time that we write a file that we also read. soong_ui doesn't have this problem. Bug: 35970961 Test: m clean; m -j blueprint_tools; m -j blueprint_tools; m -j blueprint_tools Test: $OUT_DIR/versions_checked.mk no longer exists Change-Id: I14b67dc275ea3daa77a7315c2985dc73d77fd07c --- CleanSpec.mk | 3 ++ core/main.mk | 140 --------------------------------------------------- 2 files changed, 3 insertions(+), 140 deletions(-) diff --git a/CleanSpec.mk b/CleanSpec.mk index 88f917297..b955e2599 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -417,6 +417,9 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/vendor/lib*) # Soong module variant change, remove obsolete intermediates $(call add-clean-step, rm -rf $(OUT_DIR)/soong/.intermediates) +# Version checking moving to Soong +$(call add-clean-step, rm -rf $(OUT_DIR)/versions_checked.mk) + # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST # ************************************************ diff --git a/core/main.mk b/core/main.mk index 5bc8b3bb9..f22e63d11 100644 --- a/core/main.mk +++ b/core/main.mk @@ -88,146 +88,6 @@ include $(BUILD_SYSTEM)/cleanbuild.mk # Include the google-specific config -include vendor/google/build/config.mk -VERSION_CHECK_SEQUENCE_NUMBER := 6 -JAVA_NOT_REQUIRED_CHECKED := --include $(OUT_DIR)/versions_checked.mk -ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER)$(JAVA_NOT_REQUIRED),$(VERSIONS_CHECKED)$(JAVA_NOT_REQUIRED_CHECKED)) - -$(info Checking build tools versions...) - -# check for a case sensitive file system -ifneq (a,$(shell mkdir -p $(OUT_DIR) ; \ - echo a > $(OUT_DIR)/casecheck.txt; \ - echo B > $(OUT_DIR)/CaseCheck.txt; \ - cat $(OUT_DIR)/casecheck.txt)) -$(warning ************************************************************) -$(warning You are building on a case-insensitive filesystem.) -$(warning Please move your source tree to a case-sensitive filesystem.) -$(warning ************************************************************) -$(error Case-insensitive filesystems not supported) -endif - -# Make sure that there are no spaces in the absolute path; the -# build system can't deal with them. -ifneq ($(words $(shell pwd)),1) -$(warning ************************************************************) -$(warning You are building in a directory whose absolute path contains) -$(warning a space character:) -$(warning $(space)) -$(warning "$(shell pwd)") -$(warning $(space)) -$(warning Please move your source tree to a path that does not contain) -$(warning any spaces.) -$(warning ************************************************************) -$(error Directory names containing spaces not supported) -endif - -ifneq ($(JAVA_NOT_REQUIRED),true) -java_version_str := $(shell unset _JAVA_OPTIONS && java -version 2>&1) -javac_version_str := $(shell unset _JAVA_OPTIONS && javac -version 2>&1) - -# Check for the correct version of java, should be 1.8 by -# default and only 1.7 if LEGACY_USE_JAVA7 is set. -ifeq ($(LEGACY_USE_JAVA7),) # if LEGACY_USE_JAVA7 == '' -required_version := "1.8.x" -required_javac_version := "1.8" -java_version := $(shell echo '$(java_version_str)' | grep '[ "]1\.8[\. "$$]') -javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.8[\. "$$]') -else -required_version := "1.7.x" -required_javac_version := "1.7" -java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.7[\. "$$]') -javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.7[\. "$$]') -endif # if LEGACY_USE_JAVA7 == '' - -ifeq ($(strip $(java_version)),) -$(info ************************************************************) -$(info You are attempting to build with the incorrect version) -$(info of java.) -$(info $(space)) -$(info Your version is: $(java_version_str).) -$(info The required version is: $(required_version)) -$(info $(space)) -$(info Please follow the machine setup instructions at) -$(info $(space)$(space)$(space)$(space)https://source.android.com/source/initializing.html) -$(info ************************************************************) -$(error stop) -endif - -# Check for the current JDK. -# -# For Java 1.7/1.8, we require OpenJDK on linux and Oracle JDK on Mac OS. -requires_openjdk := false -ifeq ($(BUILD_OS),linux) -requires_openjdk := true -endif - - -# Check for the current jdk -ifeq ($(requires_openjdk), true) -# The user asked for openjdk, so check that the host -# java version is really openjdk and not some other JDK. -ifeq ($(shell echo '$(java_version_str)' | grep -i openjdk),) -$(info ************************************************************) -$(info You asked for an OpenJDK based build but your version is) -$(info $(java_version_str).) -$(info ************************************************************) -$(error stop) -endif # java version is not OpenJdk -else # if requires_openjdk -ifneq ($(shell echo '$(java_version_str)' | grep -i openjdk),) -$(info ************************************************************) -$(info You are attempting to build with an unsupported JDK.) -$(info $(space)) -$(info You use OpenJDK but only Sun/Oracle JDK is supported.) -$(info Please follow the machine setup instructions at) -$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html) -$(info ************************************************************) -$(error stop) -endif # java version is not Sun Oracle JDK -endif # if requires_openjdk - -KNOWN_INCOMPATIBLE_JAVAC_VERSIONS := google -incompat_javac := $(foreach v,$(KNOWN_INCOMPATIBLE_JAVAC_VERSIONS),$(findstring $(v),$(javac_version_str))) -ifneq ($(incompat_javac),) -javac_version := -endif - -# Check for the correct version of javac -ifeq ($(strip $(javac_version)),) -$(info ************************************************************) -$(info You are attempting to build with the incorrect version) -$(info of javac.) -$(info $(space)) -$(info Your version is: $(javac_version_str).) -ifneq ($(incompat_javac),) -$(info This '$(incompat_javac)' version is not supported for Android platform builds.) -$(info Use a publicly available JDK and make sure you have run envsetup.sh / lunch.) -else -$(info The required version is: $(required_javac_version)) -endif -$(info $(space)) -$(info Please follow the machine setup instructions at) -$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html) -$(info ************************************************************) -$(error stop) -endif - -endif # if JAVA_NOT_REQUIRED - -ifndef BUILD_EMULATOR - # Emulator binaries are now provided under prebuilts/android-emulator/ - BUILD_EMULATOR := false -endif - -$(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \ - > $(OUT_DIR)/versions_checked.mk) -$(shell echo 'BUILD_EMULATOR ?= $(BUILD_EMULATOR)' \ - >> $(OUT_DIR)/versions_checked.mk) -$(shell echo 'JAVA_NOT_REQUIRED_CHECKED := $(JAVA_NOT_REQUIRED)' \ - >> $(OUT_DIR)/versions_checked.mk) -endif - # These are the modifier targets that don't do anything themselves, but # change the behavior of the build. # (must be defined before including definitions.make) From 85e55ceff2108d3fc1c7aaa76faa25912ffd9c5e Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Fri, 12 May 2017 19:28:46 -0700 Subject: [PATCH 4/4] Move auto installclean to soong_ui This way kati doesn't need to keep state for which build got run last, and we have to run kati less often. This was forcing another kati run for an empty out directory, and a kati run (or two) every time you switched products that shared a device. Bug: 35970961 Test: m clean; m -j blueprint_tools; m -j blueprint_tools; m -j blueprint_tools Test: lunch aosp_arm-eng; m -j blueprint_tools; lunch full-eng; m -j blueprint_tools; Change-Id: I825a0868fb7059016a940c76244527432e3e7cff --- core/cleanbuild.mk | 54 ---------------------------------------------- 1 file changed, 54 deletions(-) diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk index 3a909337b..b7109f60b 100644 --- a/core/cleanbuild.mk +++ b/core/cleanbuild.mk @@ -144,52 +144,6 @@ INTERNAL_CLEAN_BUILD_VERSION := endif # if not ONE_SHOT_MAKEFILE dont_bother NO_ANDROID_CLEANSPEC -# Since products and build variants (unfortunately) share the same -# PRODUCT_OUT staging directory, things can get out of sync if different -# build configurations are built in the same tree. The following logic -# will notice when the configuration has changed and remove the files -# necessary to keep things consistent. - -previous_build_config_file := $(PRODUCT_OUT)/previous_build_config.mk -current_build_config_file := $(PRODUCT_OUT)/current_build_config.mk - -current_build_config := \ - $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) -force_installclean := false - -# Read the current state from the file, if present. -# Will set PREVIOUS_BUILD_CONFIG. -# -PREVIOUS_BUILD_CONFIG := --include $(previous_build_config_file) -PREVIOUS_BUILD_CONFIG := $(strip $(PREVIOUS_BUILD_CONFIG)) - -ifdef PREVIOUS_BUILD_CONFIG - ifneq ($(current_build_config),$(PREVIOUS_BUILD_CONFIG)) - $(info *** Build configuration changed: "$(PREVIOUS_BUILD_CONFIG)" -> "$(current_build_config)") - ifneq ($(DISABLE_AUTO_INSTALLCLEAN),true) - force_installclean := true - else - $(info DISABLE_AUTO_INSTALLCLEAN is set; skipping auto-clean. Your tree may be in an inconsistent state.) - endif - endif -endif # else, this is the first build, so no need to clean. - -# Write the new state to the file. -# -$(shell \ - mkdir -p $(dir $(current_build_config_file)) && \ - echo "PREVIOUS_BUILD_CONFIG := $(current_build_config)" > \ - $(current_build_config_file) \ - ) -$(shell cmp $(current_build_config_file) $(previous_build_config_file) > /dev/null 2>&1 || \ - mv -f $(current_build_config_file) $(previous_build_config_file)) - -PREVIOUS_BUILD_CONFIG := -previous_build_config_file := -current_build_config_file := -current_build_config := - # # installclean logic # @@ -272,14 +226,6 @@ installclean: dataclean $(hide) rm -rf $(FILES) @echo "Deleted images and staging directories." -ifeq ($(force_installclean),true) - $(info *** Forcing "make installclean"...) - $(info *** rm -rf $(dataclean_files) $(installclean_files)) - $(shell rm -rf $(dataclean_files) $(installclean_files)) - $(info *** Done with the cleaning, now starting the real build.) -endif -force_installclean := - ########################################################### .PHONY: clean-jack-files