Merge changes from topics "soong-aar", "soong-bundle"

* changes:
  Store AAR path from Soong for dist
  Create bundle modules suitable for bundletool
  Dist bundle modules from Soong
This commit is contained in:
Colin Cross
2018-10-31 22:12:43 +00:00
committed by Gerrit Code Review
5 changed files with 67 additions and 0 deletions

View File

@@ -254,6 +254,8 @@ LOCAL_SDK_RES_VERSION:=
LOCAL_SDK_VERSION:=
LOCAL_SHARED_ANDROID_LIBRARIES:=
LOCAL_SHARED_LIBRARIES:=
LOCAL_SOONG_AAR :=
LOCAL_SOONG_BUNDLE :=
LOCAL_SOONG_CLASSES_JAR :=
LOCAL_SOONG_DEX_JAR :=
LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=

View File

@@ -1303,6 +1303,12 @@ ifneq ($(TARGET_BUILD_APPS),)
# Dist the installed files if they exist.
apps_only_installed_files := $(foreach m,$(unbundled_build_modules),$(ALL_MODULES.$(m).INSTALLED))
$(call dist-for-goals,apps_only, $(apps_only_installed_files))
# Dist the bundle files if they exist.
apps_only_bundle_files := $(foreach m,$(unbundled_build_modules),\
$(if $(ALL_MODULES.$(m).BUNDLE),$(ALL_MODULES.$(m).BUNDLE):$(m)-base.zip))
$(call dist-for-goals,apps_only, $(apps_only_bundle_files))
# For uninstallable modules such as static Java library, we have to dist the built file,
# as <module_name>.<suffix>
apps_only_dist_built_files := $(foreach m,$(unbundled_build_modules),$(if $(ALL_MODULES.$(m).INSTALLED),,\

View File

@@ -194,6 +194,11 @@ all_resources := $(strip $(my_res_resources) $(my_overlay_resources))
my_res_package := $(intermediates)/package-res.apk
LOCAL_INTERMEDIATE_TARGETS += $(my_res_package)
ifeq ($(LOCAL_USE_AAPT2),true)
my_bundle_module := $(intermediates)/base.zip
LOCAL_INTERMEDIATE_TARGETS += $(my_bundle_module)
endif
# Always run aapt2, because we need to at least compile the AndroidManifest.xml.
need_compile_res := true
@@ -674,6 +679,52 @@ ifdef LOCAL_COMPRESSED_MODULE
$(compress-package)
endif # LOCAL_COMPRESSED_MODULE
ifeq ($(LOCAL_USE_AAPT2),true)
my_package_res_pb := $(intermediates)/package-res.pb.apk
$(my_package_res_pb): $(my_res_package) $(AAPT2)
$(AAPT2) convert --output-format proto $< -o $@
$(my_bundle_module): $(my_package_res_pb)
$(my_bundle_module): PRIVATE_RES_PACKAGE := $(my_package_res_pb)
$(my_bundle_module): $(jni_shared_libraries)
$(my_bundle_module): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis)
$(my_bundle_module): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis)
ifneq ($(full_classes_jar),)
$(my_bundle_module): PRIVATE_DEX_FILE := $(built_dex)
# Use the jarjar processed archive as the initial package file.
$(my_bundle_module): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
$(my_bundle_module): $(built_dex)
else
$(my_bundle_module): PRIVATE_DEX_FILE :=
$(my_bundle_module): PRIVATE_SOURCE_ARCHIVE :=
endif # full_classes_jar
$(my_bundle_module): $(MERGE_ZIPS) $(SOONG_ZIP) $(ZIP2ZIP)
@echo "target Bundle: $(PRIVATE_MODULE) ($@)"
rm -rf $@.parts
mkdir -p $@.parts
$(ZIP2ZIP) -i $(PRIVATE_RES_PACKAGE) -o $@.parts/apk.zip AndroidManifest.xml:manifest/AndroidManifest.xml resources.pb "res/**/*" "assets/**/*"
ifneq ($(jni_shared_libraries),)
$(call create-jni-shared-libs-package,$@.parts/jni.zip)
endif
ifeq ($(full_classes_jar),)
# We don't build jar, need to add the Java resources here.
$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call create-java-resources-jar,$@.parts/res.zip))
else # full_classes_jar
$(call create-dex-jar,$@.parts/dex.zip,$(PRIVATE_DEX_FILE))
$(ZIP2ZIP) -i $@.parts/dex.zip -o $@.parts/dex.zip.tmp "classes*.dex:dex/"
mv -f $@.parts/dex.zip.tmp $@.parts/dex.zip
$(call extract-resources-jar,$@.parts/res.zip,$(PRIVATE_SOURCE_ARCHIVE))
endif # full_classes_jar
$(ZIP2ZIP) -i $@.parts/res.zip -o $@.parts/res.zip.tmp "**/*:root/"
mv -f $@.parts/res.zip.tmp $@.parts/res.zip
$(MERGE_ZIPS) $@ $@.parts/*.zip
rm -rf $@.parts
ALL_MODULES.$(LOCAL_MODULE).BUNDLE := $(my_bundle_module)
endif
###############################
## Build dpi-specific apks, if it's apps_only build.
ifdef TARGET_BUILD_APPS

View File

@@ -102,6 +102,10 @@ endif
PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
ifdef LOCAL_SOONG_BUNDLE
ALL_MODULES.$(LOCAL_MODULE).BUNDLE := $(LOCAL_SOONG_BUNDLE)
endif
ifndef LOCAL_IS_HOST_MODULE
ifeq ($(LOCAL_SDK_VERSION),system_current)
my_link_type := java:system

View File

@@ -128,6 +128,10 @@ else # LOCAL_SOONG_DEX_JAR
$(eval $(call copy-one-file,$(full_classes_jar),$(LOCAL_BUILT_MODULE)))
endif # LOCAL_SOONG_DEX_JAR
ifdef LOCAL_SOONG_AAR
ALL_MODULES.$(LOCAL_MODULE).AAR := $(LOCAL_SOONG_AAR)
endif
javac-check : $(full_classes_jar)
javac-check-$(LOCAL_MODULE) : $(full_classes_jar)
.PHONY: javac-check-$(LOCAL_MODULE)