Bug 1195388 - Part 1: Make ANDROID_APK_{NAME,PACKAGE} moz.build variables. r=gps

This paves the way for defining additional Android packages in
moz.build, which is a step toward moving the special
mobile/android/base/Makefile.in aapt invocations into the generic
java-build.mk framework.

The new variables are both passthru variables for now: in the future,
we'll roll them into some aggregate Android APK definition.

It's worth noting that references to the variables in Makefile.in
files are only defined after including rules.mk (and thereby
backend.mk).  This only required a few changes in the tree but it
confused me for some time.
This commit is contained in:
Nick Alexander 2015-08-19 12:34:58 -07:00
parent bed1164175
commit 8f3534dd41
20 changed files with 58 additions and 30 deletions

View File

@ -5,8 +5,6 @@
mobile-tests := mobile/android/tests/browser/robocop
TESTPATH := $(topsrcdir)/$(mobile-tests)
ANDROID_APK_NAME := robocop-debug
ANDROID_EXTRA_JARS += \
$(srcdir)/robotium-solo-4.3.1.jar \
$(NULL)

View File

@ -8,6 +8,8 @@ DEFINES['ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME']
base = '/mobile/android/tests/browser/robocop/'
ANDROID_APK_NAME = 'robocop-debug'
ANDROID_APK_PACKAGE = 'org.mozilla.roboexample.test'
ANDROID_ASSETS_DIRS += [base + 'assets']
TEST_HARNESS_FILES.testing.mochitest += [

View File

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_APK_NAME := sutAgentAndroid
include $(topsrcdir)/config/config.mk
JAVAFILES = \
AlertLooperThread.java \
@ -25,6 +25,4 @@ ANDROID_EXTRA_JARS = \
$(srcdir)/network-libs/jmdns.jar \
$(NULL)
include $(topsrcdir)/config/rules.mk
tools:: $(ANDROID_APK_NAME).apk

View File

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_APK_NAME := FenCP
include $(topsrcdir)/config/config.mk
JAVAFILES = \
DirCursor.java \
@ -11,6 +11,4 @@ JAVAFILES = \
FileCursor.java \
$(NULL)
include $(topsrcdir)/config/rules.mk
tools:: $(ANDROID_APK_NAME).apk

View File

@ -3,3 +3,6 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_APK_NAME = 'FenCP'
ANDROID_APK_PACKAGE = 'org.mozilla.fencp'

View File

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_APK_NAME := FfxCP
include $(topsrcdir)/config/config.mk
JAVAFILES = \
DirCursor.java \
@ -11,6 +11,4 @@ JAVAFILES = \
FileCursor.java \
$(NULL)
include $(topsrcdir)/config/rules.mk
tools:: $(ANDROID_APK_NAME).apk

View File

@ -3,3 +3,6 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_APK_NAME = 'FfxCP'
ANDROID_APK_PACKAGE = 'org.mozilla.ffxcp'

View File

@ -3,3 +3,6 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_APK_NAME = 'sutAgentAndroid'
ANDROID_APK_PACKAGE = 'com.mozilla.SUTAgentAndroid'

View File

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_APK_NAME := Watcher
include $(topsrcdir)/config/config.mk
JAVAFILES = \
IWatcherService.java \
@ -12,6 +12,4 @@ JAVAFILES = \
WatcherService.java \
$(NULL)
include $(topsrcdir)/config/rules.mk
tools:: $(ANDROID_APK_NAME).apk

View File

@ -3,3 +3,6 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_APK_NAME = 'Watcher'
ANDROID_APK_PACKAGE = 'com.mozilla.watcher'

View File

@ -16,15 +16,19 @@ endif #} JAVAFILES
ifdef ANDROID_APK_NAME #{
$(if $(ANDROID_APK_PACKAGE),,$(error Missing ANDROID_APK_PACKAGE with ANDROID_APK_NAME))
android_res_dirs := $(or $(ANDROID_RES_DIRS),$(srcdir)/res)
_ANDROID_RES_FLAG := $(addprefix -S ,$(android_res_dirs))
_ANDROID_ASSETS_FLAG := $(if $(ANDROID_ASSETS_DIRS),$(addprefix -A ,$(ANDROID_ASSETS_DIRS)))
android_manifest := $(or $(ANDROID_MANIFEST_FILE),AndroidManifest.xml)
GENERATED_DIRS += classes
GENERATED_DIRS += classes generated
generated_r_java := generated/$(subst .,/,$(ANDROID_APK_PACKAGE))/R.java
classes.dex: $(call mkdir_deps,classes)
classes.dex: R.java
classes.dex: $(generated_r_java)
classes.dex: $(ANDROID_APK_NAME).ap_
classes.dex: $(ANDROID_EXTRA_JARS)
classes.dex: $(JAVAFILES)
@ -38,17 +42,22 @@ classes.dex: $(JAVAFILES)
# all causes Make to treat the target differently, in a way that
# defeats our dependencies.
R.java: .aapt.deps ;
$(generated_r_java): .aapt.deps ;
$(ANDROID_APK_NAME).ap_: .aapt.deps ;
# This uses the fact that Android resource directories list all
# resource files one subdirectory below the parent resource directory.
android_res_files := $(wildcard $(addsuffix /*,$(wildcard $(addsuffix /*,$(android_res_dirs)))))
# aapt flag -m: 'make package directories under location specified by -J'.
.aapt.deps: $(android_manifest) $(android_res_files) $(wildcard $(ANDROID_ASSETS_DIRS))
@$(TOUCH) $@
$(AAPT) package -f -M $< -I $(ANDROID_SDK)/android.jar $(_ANDROID_RES_FLAG) $(_ANDROID_ASSETS_FLAG) \
-J ${@D} \
--custom-package $(ANDROID_APK_PACKAGE) \
--non-constant-id \
--auto-add-overlay \
-m \
-J ${@D}/generated \
-F $(ANDROID_APK_NAME).ap_
$(ANDROID_APK_NAME)-unsigned-unaligned.apk: $(ANDROID_APK_NAME).ap_ classes.dex
@ -60,10 +69,10 @@ $(ANDROID_APK_NAME)-unaligned.apk: $(ANDROID_APK_NAME)-unsigned-unaligned.apk
$(DEBUG_JARSIGNER) $@
$(ANDROID_APK_NAME).apk: $(ANDROID_APK_NAME)-unaligned.apk
$(ZIPALIGN) -f -v 4 $< $@
$(ZIPALIGN) -f 4 $< $@
GARBAGE += \
R.java \
$(generated_r_java) \
classes.dex \
$(ANDROID_APK_NAME).ap_ \
$(ANDROID_APK_NAME)-unsigned-unaligned.apk \

View File

@ -2,8 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_APK_NAME := background-junit3-debug
ANDROID_EXTRA_JARS := \
background-junit3.jar \
$(NULL)
@ -30,6 +28,6 @@ JAVA_BOOTCLASSPATH := $(ANDROID_SDK)/android.jar:$(subst $(NULL) ,:,$(wildcard $
# content changes.
classes.dex: $(wildcard $(JARS_DIR)/*.jar)
tools:: $(ANDROID_APK_NAME).apk
include $(topsrcdir)/config/rules.mk
tools:: $(ANDROID_APK_NAME).apk

View File

@ -6,6 +6,9 @@
DEFINES['ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME']
ANDROID_APK_NAME = 'background-junit3-debug'
ANDROID_APK_PACKAGE = 'org.mozilla.gecko.background.tests'
include('background_junit3_sources.mozbuild')
jar = add_java_jar('background-junit3')

View File

@ -2,8 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_APK_NAME := browser-junit3-debug
ANDROID_EXTRA_JARS += \
browser-junit3.jar \
$(NULL)

View File

@ -6,6 +6,9 @@
DEFINES['ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME']
ANDROID_APK_NAME = 'browser-junit3-debug'
ANDROID_APK_PACKAGE = 'org.mozilla.gecko.browser.tests'
jar = add_java_jar('browser-junit3')
jar.sources += [
'src/org/mozilla/tests/browser/junit3/harness/BrowserInstrumentationTestRunner.java',

View File

@ -2,8 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_APK_NAME := javaaddons-test
PP_TARGETS += manifest
manifest := $(srcdir)/AndroidManifest.xml.in
manifest_TARGET := export
@ -11,6 +9,6 @@ ANDROID_MANIFEST_FILE := $(CURDIR)/AndroidManifest.xml
ANDROID_EXTRA_JARS := javaaddons-test.jar
tools libs:: $(ANDROID_APK_NAME).apk
include $(topsrcdir)/config/rules.mk
tools libs:: $(ANDROID_APK_NAME).apk

View File

@ -4,6 +4,9 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_APK_NAME = 'javaaddons-test'
ANDROID_APK_PACKAGE = 'org.mozilla.javaaddons.test'
jar = add_java_jar('javaaddons-test')
jar.extra_jars += [
TOPOBJDIR + '/mobile/android/javaaddons/javaaddons-1.0.jar',

View File

@ -72,6 +72,8 @@ from ..util import (
from ..makeutil import Makefile
MOZBUILD_VARIABLES = [
b'ANDROID_APK_NAME',
b'ANDROID_APK_PACKAGE',
b'ANDROID_ASSETS_DIRS',
b'ANDROID_GENERATED_RESFILES',
b'ANDROID_RES_DIRS',

View File

@ -691,6 +691,14 @@ VARIABLES = {
file.
""", 'export'),
'ANDROID_APK_NAME': (unicode, unicode,
"""The name of an Android APK file to generate.
""", 'export'),
'ANDROID_APK_PACKAGE': (unicode, unicode,
"""The name of the Android package to generate R.java for, like org.mozilla.gecko.
""", 'export'),
'ANDROID_RES_DIRS': (ContextDerivedTypedListWithItems(Path, List), list,
"""Android resource directories.

View File

@ -556,6 +556,8 @@ class TreeMetadataEmitter(LoggingMixin):
# desired abstraction of the build definition away from makefiles.
passthru = VariablePassthru(context)
varlist = [
'ANDROID_APK_NAME',
'ANDROID_APK_PACKAGE',
'ANDROID_GENERATED_RESFILES',
'DISABLE_STL_WRAPPING',
'EXTRA_COMPONENTS',