1 # Copyright (C) 2015 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 # Check to see if we need to force proguard to re-run, typically after using tapas to 16 # switch to/from eng builds. This is determined by comparing the flag files used in the previous 17 # build. If the flag files have changed, proguard is rerun. 18 19 # If the LOCAL_MODULE being setup isn't a build target, then don't run ForceProguard. 20 ifneq (,$(findstring $(LOCAL_MODULE), $(TARGET_BUILD_APPS))) 21 22 PREVIOUS_FLAG_FILES_USED_DIR := $(call local-intermediates-dir,1) 23 24 # If the local intermediates dir doesn't exist, ForceProguard won't work. 25 ifneq ($(wildcard $(PREVIOUS_FLAG_FILES_USED_DIR)),) 26 PREVIOUS_FLAG_FILES_USED_FILE := $(PREVIOUS_FLAG_FILES_USED_DIR)/previous_proguard_flag_files 27 PREVIOUS_FLAG_FILES_USED := $(if $(wildcard $(PREVIOUS_FLAG_FILES_USED_FILE)), \ 28 $(shell cat $(PREVIOUS_FLAG_FILES_USED_FILE))) 29 30 ifneq ($(strip $(PREVIOUS_FLAG_FILES_USED)), $(strip $(LOCAL_PROGUARD_FLAG_FILES))) 31 $(info *** Flag files used for proguard have changed; forcing proguard to rerun.) 32 $(shell touch $(LOCAL_PATH)/proguard.flags) 33 $(shell echo $(LOCAL_PROGUARD_FLAG_FILES) > $(PREVIOUS_FLAG_FILES_USED_FILE)) 34 endif 35 36 endif 37 # End local intermediates directory existence check 38 39 endif 40 # End LOCAL_MODULE is a build target check 41