Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b42ae80 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Allow forcing AAPT2 on"

parents 4537ebb7 2029903b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ my_full_libs_manifest_files += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)
  $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/AndroidManifest.xml)

# With aapt2, we'll link in the built resource from the AAR.
ifndef LOCAL_USE_AAPT2
ifneq ($(LOCAL_USE_AAPT2),true)
LOCAL_RESOURCE_DIR += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\
  $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/res)
endif  # LOCAL_USE_AAPT2
+11 −0
Original line number Diff line number Diff line
@@ -2147,6 +2147,17 @@ $(SOONG_ZIP) -o $(PRIVATE_SRCJAR) -C $(PRIVATE_JAVA_GEN_DIR) -D $(PRIVATE_JAVA_G
$(EXTRACT_JAR_PACKAGES) -i $(PRIVATE_SRCJAR) -o $(PRIVATE_AAPT_EXTRA_PACKAGES) --prefix '--extra-packages '
endef

define _create-default-manifest-file
$(1):
	rm -f $1
	echo '<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="missing.manifest"></manifest>' > $1
endef

define create-default-manifest-file
  $(eval $(call _create-default-manifest-file,$(1)))
endef


###########################################################
xlint_unchecked := -Xlint:unchecked

core/force_aapt2.mk

0 → 100644
+63 −0
Original line number Diff line number Diff line
#
# Copyright (C) 2018 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Including this makefile will force AAPT2 on if FORCE_AAPT2==true,
# rewriting some properties to convert standard AAPT usage to AAPT2.

ifeq ($(FORCE_AAPT2),true)
  ifneq ($(LOCAL_USE_AAPT2),true)
    # Force AAPT2 on
    LOCAL_USE_AAPT2 := true
    # Move LOCAL_STATIC_JAVA_AAR_LIBRARIES to LOCAL_STATIC_ANDROID_LIBRARIES
    LOCAL_STATIC_ANDROID_LIBRARIES := $(strip $(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES))
    LOCAL_STATIC_JAVA_AAR_LIBRARIES :=
    # Filter out support library resources
    LOCAL_RESOURCE_DIR := $(filter-out \
      prebuilts/sdk/current/% \
      frameworks/support/%,\
        $(LOCAL_RESOURCE_DIR))
    # Filter out unnecessary aapt flags
    LOCAL_AAPT_FLAGS := $(subst --extra-packages=,--extra-packages$(space), \
      $(filter-out \
        --extra-packages=android.support.% \
        --extra-packages=androidx.% \
        --auto-add-overlay,\
          $(subst --extra-packages$(space),--extra-packages=,$(LOCAL_AAPT_FLAGS))))

    # AAPT2 is pickier about missing resources.  Support library may have references to resources
    # added in current, so always treat LOCAL_SDK_VERSION as LOCAL_SDK_RES_VERSION := current.
    ifdef LOCAL_SDK_VERSION
      LOCAL_SDK_RES_VERSION := current
    endif

    ifeq (,$(strip $(LOCAL_MANIFEST_FILE)$(LOCAL_FULL_MANIFEST_FILE)))
      ifeq (,$(wildcard $(LOCAL_PATH)/AndroidManifest.xml))
        # work around missing manifests by creating a default one
        $(call pretty-warning, Missing manifest file)
        LOCAL_FULL_MANIFEST_FILE := $(call local-intermediates-dir,COMMON)/DefaultManifest.xml
        $(call create-default-manifest-file,$(LOCAL_FULL_MANIFEST_FILE))
      endif
    endif
  endif
endif

ifneq ($(LOCAL_USE_AAPT2),true)
  ifneq ($(LOCAL_USE_AAPT2),false)
    ifneq ($(LOCAL_USE_AAPT2),)
      $(call pretty-error,Invalid value for LOCAL_USE_AAPT2: "$(LOCAL_USE_AAPT2)")
    endif
  endif
endif
+1 −1
Original line number Diff line number Diff line
@@ -444,7 +444,7 @@ ifneq ($(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS)),)
common_proguard_flags += -dontshrink # don't shrink tests by default
endif # test package
ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
  ifdef LOCAL_USE_AAPT2
  ifeq ($(LOCAL_USE_AAPT2),true)
    common_proguard_flag_files += $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES),\
        $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/export_proguard_flags)
  endif
+1 −1
Original line number Diff line number Diff line
@@ -477,7 +477,7 @@ endif
ifdef LOCAL_AAPT2_ONLY
my_link_type += aapt2_only
endif
ifdef LOCAL_USE_AAPT2
ifeq ($(LOCAL_USE_AAPT2),true)
my_allowed_types += aapt2_only
endif

Loading