From 1425e2d8c08663987f2d1004c55e6060d1ce6dfe Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 22 Jul 2014 15:42:11 -0700 Subject: [PATCH] Support LOCAL_PACKAGE_SPLITS. Support LOCAL_PACKAGE_SPLITS, which accepts a list of resource lables and generates multiple apks. The build system sets up rules to sign and zipalign the split apks. Bug: 16319961 Change-Id: I344b3d1c7eb158c6d0df879093d666a89870aadd --- core/.dex_preopt_odex_install.mk.swp | Bin 0 -> 16384 bytes core/base_rules.mk | 1 - core/clear_vars.mk | 1 + core/definitions.mk | 12 +++++++++++ core/package_internal.mk | 30 +++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 core/.dex_preopt_odex_install.mk.swp diff --git a/core/.dex_preopt_odex_install.mk.swp b/core/.dex_preopt_odex_install.mk.swp new file mode 100644 index 0000000000000000000000000000000000000000..3b978463428fc3d367b62edf95e4cd2f781fdc7b GIT binary patch literal 16384 zcmeHNTZklA89rI#WsSQDD(iy*&rZ*>Q)^F8rd7g@#@(9f-fYkIOgDX*tQah+yH0nP z+uhZvs_sccP|zsZ2l2%O3>pvx4M+&V_~x5RkPs0B^-14?H-r%M$;)@nsY_RNP0vg= zfnBVIkDlo|^`CRT^WUpl5A2n8=!3aW5`69>Wa+QJtgqj-apHxGgzW3X?$jK1`K3jl z-dHy=&c*QDz@6mUmOaXKEvwsS_E9qYQu3w}KR_v`;3-%H2@ zxBw`?A5RnV0`N^>3VZ=L2mI|6ABiG8{kFY zJHRu*1>g*DAMm61LpHDt6o4(@Q$Pl|2YB-&An12%!Xfmh#4 z$hUz4kO$5J|9uZ3zXHAiG=Ti6C{O4}01^5bZ3D^MsfhNeGfeCPx z|Ba@}(?AvY2=F>M)s%(w4**;)cAHArOK{kD``jk zZ4=kDhDvl{QJGOOVAvVA92ZNk*1+EucHC?z=d$M(5ggffC_cYi5Qn4fsWra#E2ZmL zEJ<3bPk!v^#mOAy?2}{$+gAu18fGVPVt zaXDtkU>$nMFcNB2jGyC~hTKYE78zQB5zvlhQ@6+HI!;};+dYz@nd5$N&lQN#>9#)6 zY2R$wx;@R(eMZGQO_Z-wOw_X6UN95Ii%>KV@M*Ku?C=|U`h-zy$a2K&u*c|%Z`X3! z+E!Vu*OlzHx~FR8(q>Jqm5OzF9yG&e)@?Vz;1}DWG~lR}yjAn{4lBu{g~zCDEU!dI zC?xv7Jm{A02%iLVlsYo+-Ey4UISrY+F?#m$CZFJfTHY&N)An{aqe>Pe8k0fJu{>JA zYs<1+`bFKAh9rrWW8%yHICtI4E1qjk@Bm7JjfJ}s_Mt$X)X@k=D-<(O9su_ zfrc|`vr%7fGlRCK;OGcz%Lz9VVOy$DY?UHh-g(L;eIK;fd(n|Ir$NcIfn|*Qj2w7H z+6F>~%WT1dz7p@|V zmd#zyYp9#Z#w4ZQt#pn6c^rHT9UYN7(29_Euq=`Utm=_c<0{VpWJ>msYmXTsihtGf zY}}tByQx;|lnqAiRKy&AOq_o@9%A930@H*=Fp8_uf7lHeM zf1!5&8Sn#O1biO&DDXV$_pbt%flmX!MeY6?a0z%5HT%zarowkCQRyay4@7I`+Yqu*fE86zi!#dw!R@+#^Ay5D0%I<>~In;~5q z@WG$)JS`Xc*(GRJx$NgyxrAwRUe)aPVyGw!qQ`) z41KUct&YDVFa z7p40^pUU!mfGpD-ArTEGovDR*Vb7y*xKodMnp|h{f?n!821p)fdjSV!?jSv!;i&cY z!97R+2$L(?JEk9b$Tk)FYpYD0H5)!CML? zvC%PQ=Yt|m`$PJH3r=M|xRIcS4dSdwKzK>uHIfc{o&&26%KM`~(8L3%%I9CsfG)08?uZ^#A|> literal 0 HcmV?d00001 diff --git a/core/base_rules.mk b/core/base_rules.mk index f40eae797d..7663ee2a7b 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -176,7 +176,6 @@ else built_module_path := $(intermediates) endif LOCAL_BUILT_MODULE := $(built_module_path)/$(my_built_module_stem) -built_module_path := ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) # Apk and its attachments reside in its own subdir. diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 4fd2888234..f23c4a65e9 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -23,6 +23,7 @@ LOCAL_PACKAGE_NAME:= LOCAL_OVERRIDES_PACKAGES:= LOCAL_EXPORT_PACKAGE_RESOURCES:= LOCAL_MANIFEST_PACKAGE_NAME:= +LOCAL_PACKAGE_SPLITS:= LOCAL_REQUIRED_MODULES:= LOCAL_ACP_UNAVAILABLE:= LOCAL_MODULE_TAGS:= diff --git a/core/definitions.mk b/core/definitions.mk index 66565919d0..e433b697c9 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1805,6 +1805,18 @@ $(hide) $(ZIPALIGN) -f 4 $@.unaligned $@.aligned $(hide) mv $@.aligned $@ endef +# Build a split APK +# The splti APKs are already built in the same command building the base APK. +# We only need to do zipalign and signing etc. +# This macro must be called with $(eval). +# $(1): the path to the built split APK. +# $(2): the path to the base APK. +define build-split-apk +$(1) : $(2) + $$(sign-package) + $$(align-package) +endef + define install-dex-debug $(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.dex" ]; then \ mkdir -p $(TOP)/dalvik/DEBUG-FILES; \ diff --git a/core/package_internal.mk b/core/package_internal.mk index c76792d2aa..a5b1142002 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -68,6 +68,10 @@ ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),) LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z endif +ifdef LOCAL_PACKAGE_SPLITS +LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS)) +endif + ifeq (,$(LOCAL_ASSET_DIR)) LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets endif @@ -403,6 +407,32 @@ $(built_odex) : $(built_dex) $(hide) rm $@.input endif +############################### +## APK splits +ifdef LOCAL_PACKAGE_SPLITS +built_apk_splits := $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/package_$(s).apk) +installed_apk_splits := $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk) + +$(built_apk_splits): PRIVATE_PRIVATE_KEY := $(private_key) +$(built_apk_splits): PRIVATE_CERTIFICATE := $(certificate) +# The splits should have been built in the same command building the base apk. +# This rule just establishes the dependency and make sure the splits are up to date. +$(foreach s,$(built_apk_splits),\ + $(eval $(call build-split-apk,$(s),$(LOCAL_BUILT_MODULE)))) + +# Rules to install the splits +$(foreach s,$(LOCAL_PACKAGE_SPLITS),\ + $(eval $(call copy-one-file,$(built_module_path)/package_$(s).apk,$(my_module_path)/$(LOCAL_MODULE)_$(s).apk))) + +# Register the additional built and installed files. +ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits) +ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \ + $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/package_$(s).apk:$(my_module_path)/$(LOCAL_MODULE)_$(s).apk) + +# Make sure to install the splits when you run "make ". +$(my_register_name): $(installed_apk_splits) +endif # LOCAL_PACKAGE_SPLITS + # Save information about this package PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources)