The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | # Copyright (C) 2007 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
| 15 | |
Dan Willemsen | 514d499 | 2017-07-24 22:27:17 -0700 | [diff] [blame] | 16 | # Absolute path of the present working direcotry. |
| 17 | # This overrides the shell variable $PWD, which does not necessarily points to |
| 18 | # the top of the source tree, for example when "make -C" is used in m/mm/mmm. |
| 19 | PWD := $(shell pwd) |
| 20 | |
| 21 | TOP := . |
| 22 | TOPDIR := |
| 23 | |
Colin Cross | 6cdc5d2 | 2017-10-20 11:37:33 -0700 | [diff] [blame] | 24 | BUILD_SYSTEM := $(TOPDIR)build/make/core |
Dan Willemsen | 514d499 | 2017-07-24 22:27:17 -0700 | [diff] [blame] | 25 | |
| 26 | # Set up various standard variables based on configuration |
| 27 | # and host information. |
| 28 | include $(BUILD_SYSTEM)/config.mk |
| 29 | |
| 30 | include $(SOONG_MAKEVARS_MK) |
| 31 | |
| 32 | include $(BUILD_SYSTEM)/clang/config.mk |
| 33 | |
| 34 | # CTS-specific config. |
| 35 | -include cts/build/config.mk |
| 36 | # VTS-specific config. |
| 37 | -include test/vts/tools/vts-tradefed/build/config.mk |
| 38 | # device-tests-specific-config. |
| 39 | -include tools/tradefederation/build/suites/device-tests/config.mk |
| 40 | # general-tests-specific-config. |
| 41 | -include tools/tradefederation/build/suites/general-tests/config.mk |
Ying Wang | 50e52fa | 2013-02-22 18:15:29 -0800 | [diff] [blame] | 42 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 43 | INTERNAL_CLEAN_STEPS := |
| 44 | |
| 45 | # Builds up a list of clean steps. Creates a unique |
Ying Wang | fa9ae7b | 2010-03-03 10:45:14 -0800 | [diff] [blame] | 46 | # id for each step by taking makefile path, INTERNAL_CLEAN_BUILD_VERSION |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 47 | # and appending an increasing number of '@' characters. |
| 48 | # |
| 49 | # $(1): shell command to run |
Ying Wang | fa9ae7b | 2010-03-03 10:45:14 -0800 | [diff] [blame] | 50 | # $(2): indicate to not use makefile path as part of step id if not empty. |
Colin Cross | 6cdc5d2 | 2017-10-20 11:37:33 -0700 | [diff] [blame] | 51 | # $(2) should only be used in build/make/core/cleanspec.mk: just for compatibility. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 52 | define _add-clean-step |
| 53 | $(if $(strip $(INTERNAL_CLEAN_BUILD_VERSION)),, \ |
| 54 | $(error INTERNAL_CLEAN_BUILD_VERSION not set)) |
Ying Wang | fa9ae7b | 2010-03-03 10:45:14 -0800 | [diff] [blame] | 55 | $(eval _acs_makefile_prefix := $(lastword $(MAKEFILE_LIST))) |
| 56 | $(eval _acs_makefile_prefix := $(subst /,_,$(_acs_makefile_prefix))) |
| 57 | $(eval _acs_makefile_prefix := $(subst .,-,$(_acs_makefile_prefix))) |
| 58 | $(eval _acs_makefile_prefix := $(_acs_makefile_prefix)_acs) |
| 59 | $(if $($(_acs_makefile_prefix)),,\ |
| 60 | $(eval $(_acs_makefile_prefix) := $(INTERNAL_CLEAN_BUILD_VERSION))) |
| 61 | $(eval $(_acs_makefile_prefix) := $($(_acs_makefile_prefix))@) |
| 62 | $(if $(strip $(2)),$(eval _acs_id := $($(_acs_makefile_prefix))),\ |
| 63 | $(eval _acs_id := $(_acs_makefile_prefix)$($(_acs_makefile_prefix)))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 64 | $(eval INTERNAL_CLEAN_STEPS += $(_acs_id)) |
| 65 | $(eval INTERNAL_CLEAN_STEP.$(_acs_id) := $(1)) |
| 66 | $(eval _acs_id :=) |
Ying Wang | fa9ae7b | 2010-03-03 10:45:14 -0800 | [diff] [blame] | 67 | $(eval _acs_makefile_prefix :=) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 68 | endef |
| 69 | define add-clean-step |
Colin Cross | 6cdc5d2 | 2017-10-20 11:37:33 -0700 | [diff] [blame] | 70 | $(eval # for build/make/core/cleanspec.mk, dont use makefile path as part of step id) \ |
Ying Wang | fa9ae7b | 2010-03-03 10:45:14 -0800 | [diff] [blame] | 71 | $(if $(filter %/cleanspec.mk,$(lastword $(MAKEFILE_LIST))),\ |
| 72 | $(eval $(call _add-clean-step,$(1),true)),\ |
| 73 | $(eval $(call _add-clean-step,$(1)))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 74 | endef |
| 75 | |
| 76 | # Defines INTERNAL_CLEAN_BUILD_VERSION and the individual clean steps. |
| 77 | # cleanspec.mk is outside of the core directory so that more people |
| 78 | # can have permission to touch it. |
Ying Wang | fa9ae7b | 2010-03-03 10:45:14 -0800 | [diff] [blame] | 79 | include $(BUILD_SYSTEM)/cleanspec.mk |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 80 | INTERNAL_CLEAN_BUILD_VERSION := $(strip $(INTERNAL_CLEAN_BUILD_VERSION)) |
Ying Wang | eadaa95 | 2015-08-04 12:11:54 -0700 | [diff] [blame] | 81 | INTERNAL_CLEAN_STEPS := $(strip $(INTERNAL_CLEAN_STEPS)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 82 | |
| 83 | # If the clean_steps.mk file is missing (usually after a clean build) |
| 84 | # then we won't do anything. |
Dan Willemsen | e6f7560 | 2017-07-24 21:16:38 -0700 | [diff] [blame] | 85 | CURRENT_CLEAN_BUILD_VERSION := MISSING |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 86 | CURRENT_CLEAN_STEPS := $(INTERNAL_CLEAN_STEPS) |
| 87 | |
| 88 | # Read the current state from the file, if present. |
| 89 | # Will set CURRENT_CLEAN_BUILD_VERSION and CURRENT_CLEAN_STEPS. |
| 90 | # |
| 91 | clean_steps_file := $(PRODUCT_OUT)/clean_steps.mk |
| 92 | -include $(clean_steps_file) |
| 93 | |
Dan Willemsen | e6f7560 | 2017-07-24 21:16:38 -0700 | [diff] [blame] | 94 | ifeq ($(CURRENT_CLEAN_BUILD_VERSION),MISSING) |
| 95 | # Do nothing |
| 96 | else ifneq ($(CURRENT_CLEAN_BUILD_VERSION),$(INTERNAL_CLEAN_BUILD_VERSION)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 97 | # The major clean version is out-of-date. Do a full clean, and |
| 98 | # don't even bother with the clean steps. |
| 99 | $(info *** A clean build is required because of a recent change.) |
| 100 | $(shell rm -rf $(OUT_DIR)) |
| 101 | $(info *** Done with the cleaning, now starting the real build.) |
| 102 | else |
| 103 | # The major clean version is correct. Find the list of clean steps |
| 104 | # that we need to execute to get up-to-date. |
| 105 | steps := \ |
| 106 | $(filter-out $(CURRENT_CLEAN_STEPS),$(INTERNAL_CLEAN_STEPS)) |
| 107 | $(foreach step,$(steps), \ |
| 108 | $(info Clean step: $(INTERNAL_CLEAN_STEP.$(step))) \ |
| 109 | $(shell $(INTERNAL_CLEAN_STEP.$(step))) \ |
| 110 | ) |
Ying Wang | f6268b8 | 2014-06-18 12:07:48 -0700 | [diff] [blame] | 111 | |
| 112 | # Rewrite the clean step for the second arch. |
| 113 | ifdef TARGET_2ND_ARCH |
| 114 | # $(1): the clean step cmd |
| 115 | # $(2): the prefix to search for |
| 116 | # $(3): the prefix to replace with |
| 117 | define -cs-rewrite-cleanstep |
| 118 | $(if $(filter $(2)/%,$(1)),\ |
| 119 | $(eval _crs_new_cmd := $(patsubst $(2)/%,$(3)/%,$(1)))\ |
| 120 | $(info Clean step: $(_crs_new_cmd))\ |
| 121 | $(shell $(_crs_new_cmd))) |
| 122 | endef |
| 123 | $(foreach step,$(steps), \ |
| 124 | $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_INTERMEDIATES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES))\ |
| 125 | $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_SHARED_LIBRARIES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES))\ |
| 126 | $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_VENDOR_SHARED_LIBRARIES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES))\ |
| 127 | $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES),$(TARGET_OUT_INTERMEDIATES))\ |
| 128 | $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES),$(TARGET_OUT_SHARED_LIBRARIES))\ |
| 129 | $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES),$(TARGET_OUT_VENDOR_SHARED_LIBRARIES))\ |
| 130 | ) |
| 131 | endif |
| 132 | _crs_new_cmd := |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 133 | steps := |
| 134 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 135 | |
| 136 | # Write the new state to the file. |
Ying Wang | 50e52fa | 2013-02-22 18:15:29 -0800 | [diff] [blame] | 137 | # |
Shinichiro Hamaji | 14da142 | 2015-07-21 07:28:39 +0900 | [diff] [blame] | 138 | ifneq ($(CURRENT_CLEAN_BUILD_VERSION)-$(CURRENT_CLEAN_STEPS),$(INTERNAL_CLEAN_BUILD_VERSION)-$(INTERNAL_CLEAN_STEPS)) |
Dan Willemsen | e6f7560 | 2017-07-24 21:16:38 -0700 | [diff] [blame] | 139 | $(shell mkdir -p $(dir $(clean_steps_file))) |
| 140 | $(file >$(clean_steps_file).tmp,CURRENT_CLEAN_BUILD_VERSION := $(INTERNAL_CLEAN_BUILD_VERSION)$(newline)CURRENT_CLEAN_STEPS := $(INTERNAL_CLEAN_STEPS)$(newline)) |
| 141 | $(shell if ! cmp -s $(clean_steps_file).tmp $(clean_steps_file); then \ |
| 142 | mv $(clean_steps_file).tmp $(clean_steps_file); \ |
| 143 | else \ |
| 144 | rm $(clean_steps_file).tmp; \ |
| 145 | fi) |
Shinichiro Hamaji | 14da142 | 2015-07-21 07:28:39 +0900 | [diff] [blame] | 146 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 147 | |
Shinichiro Hamaji | 14da142 | 2015-07-21 07:28:39 +0900 | [diff] [blame] | 148 | CURRENT_CLEAN_BUILD_VERSION := |
| 149 | CURRENT_CLEAN_STEPS := |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 150 | clean_steps_file := |
| 151 | INTERNAL_CLEAN_STEPS := |
| 152 | INTERNAL_CLEAN_BUILD_VERSION := |