1d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#  Copyright (C) 2015 The Android Open Source Project
2d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#
3d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#  Licensed under the Apache License, Version 2.0 (the "License");
4d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#  you may not use this file except in compliance with the License.
5d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#  You may obtain a copy of the License at
6d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#
7d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#       http://www.apache.org/licenses/LICENSE-2.0
8d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#
9d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#  Unless required by applicable law or agreed to in writing, software
10d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#  distributed under the License is distributed on an "AS IS" BASIS,
11d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#  See the License for the specific language governing permissions and
13d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd#  limitations under the License.
14d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
15d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd# Check to see if we need to force proguard to re-run, typically after using tapas to
16d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd# switch to/from eng builds. This is determined by comparing the flag files used in the previous
17d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd# build. If the flag files have changed, proguard is rerun.
18d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
19d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd# If the LOCAL_MODULE being setup isn't a build target, then don't run ForceProguard.
20d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddifneq (,$(findstring $(LOCAL_MODULE), $(TARGET_BUILD_APPS)))
21d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
22d3b009ae55651f1e60950342468e3c37fdeb0796Mike DoddPREVIOUS_FLAG_FILES_USED_DIR := $(call local-intermediates-dir,1)
23d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
24d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd# If the local intermediates dir doesn't exist, ForceProguard won't work.
25d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddifneq ($(wildcard $(PREVIOUS_FLAG_FILES_USED_DIR)),)
26d3b009ae55651f1e60950342468e3c37fdeb0796Mike DoddPREVIOUS_FLAG_FILES_USED_FILE := $(PREVIOUS_FLAG_FILES_USED_DIR)/previous_proguard_flag_files
27d3b009ae55651f1e60950342468e3c37fdeb0796Mike DoddPREVIOUS_FLAG_FILES_USED := $(if $(wildcard $(PREVIOUS_FLAG_FILES_USED_FILE)), \
28d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                                $(shell cat $(PREVIOUS_FLAG_FILES_USED_FILE)))
29d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
30d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddifneq ($(strip $(PREVIOUS_FLAG_FILES_USED)), $(strip $(LOCAL_PROGUARD_FLAG_FILES)))
31d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd$(info *** Flag files used for proguard have changed; forcing proguard to rerun.)
32d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd$(shell touch $(LOCAL_PATH)/proguard.flags)
33d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd$(shell echo $(LOCAL_PROGUARD_FLAG_FILES) > $(PREVIOUS_FLAG_FILES_USED_FILE))
34d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddendif
35d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
36d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddendif
37d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd# End local intermediates directory existence check
38d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
39d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddendif
40d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd# End LOCAL_MODULE is a build target check
41