blob: 5f3182afa9d5f08f31e6858f8a15c6b5efd90f53 [file] [log] [blame]
Colin Cross20299032018-05-09 13:29:51 -07001#
2# Copyright (C) 2018 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
Colin Crosse6210f62019-02-25 22:21:24 -080017# Including this makefile will force AAPT2 on,
Colin Cross20299032018-05-09 13:29:51 -070018# rewriting some properties to convert standard AAPT usage to AAPT2.
19
Colin Crosse6210f62019-02-25 22:21:24 -080020ifeq ($(LOCAL_USE_AAPT2),false)
21 $(call pretty-error, LOCAL_USE_AAPT2 := false is no longer supported)
Colin Cross20299032018-05-09 13:29:51 -070022endif
23
Colin Crosse6210f62019-02-25 22:21:24 -080024# Filter out support library resources
25LOCAL_RESOURCE_DIR := $(filter-out \
26 prebuilts/sdk/current/% \
27 frameworks/support/%,\
28 $(LOCAL_RESOURCE_DIR))
29# Filter out unnecessary aapt flags
30ifneq (,$(filter --extra-packages,$(LOCAL_AAPT_FLAGS)))
31 LOCAL_AAPT_FLAGS := $(subst --extra-packages=,--extra-packages$(space), \
32 $(filter-out \
33 --extra-packages=android.support.% \
34 --extra-packages=androidx.%, \
35 $(subst --extra-packages$(space),--extra-packages=,$(LOCAL_AAPT_FLAGS))))
36 ifeq (,$(filter --extra-packages,$(LOCAL_AAPT_FLAGS)))
37 LOCAL_AAPT_FLAGS := $(filter-out --auto-add-overlay,$(LOCAL_AAPT_FLAGS))
Colin Cross20299032018-05-09 13:29:51 -070038 endif
Colin Crosse6210f62019-02-25 22:21:24 -080039endif
40
41# AAPT2 is pickier about missing resources. Support library may have references to resources
Colin Cross85f2b4a2019-04-18 10:20:49 -070042# added in current, so always treat LOCAL_SDK_VERSION := <number> as LOCAL_SDK_RES_VERSION := current.
43ifneq (,$(filter-out current system_current test_current core_current,$(LOCAL_SDK_VERSION)))
Colin Crosse6210f62019-02-25 22:21:24 -080044 LOCAL_SDK_RES_VERSION := current
45endif
46