Bug 919563 - Standardize APK generation. r=glandium

This only handles the simple cases: no mobile/android/base (yet).
This commit is contained in:
Nick Alexander 2013-10-01 12:43:30 -07:00
parent 7e380ef159
commit d7d5b7e7df
11 changed files with 130 additions and 304 deletions

View File

@ -8,17 +8,17 @@ dir-tests := $(DEPTH)/$(mobile-tests)
ANDROID_APK_NAME := robocop-debug
ROBOTIUM_PATH = $(srcdir)/robotium-solo-4.2.jar
JAVAFILES = \
R.java \
ANDROID_EXTRA_JARS += \
$(srcdir)/robotium-solo-4.2.jar \
$(NULL)
ANDROID_RESFILES = \
res/values/strings.xml \
$(NULL)
_JAVA_HARNESS = \
ANDROID_ASSETS_DIR := $(TESTPATH)/assets
_JAVA_HARNESS := \
Actions.java \
Assert.java \
Driver.java \
@ -51,7 +51,6 @@ PP_TARGETS += manifest
manifest := $(srcdir)/AndroidManifest.xml.in
manifest_TARGET := AndroidManifest.xml
# Install robocop configs and helper
INSTALL_TARGETS += robocop
robocop_TARGET := libs
@ -75,50 +74,25 @@ MOCHITEST_ROBOCOP_FILES := \
GARBAGE += \
AndroidManifest.xml \
$(java-tests-dep) \
$(_JAVA_HARNESS) \
classes.dex \
$(ANDROID_APK_NAME).ap_ \
$(ANDROID_APK_NAME)-unsigned-unaligned.apk \
$(ANDROID_APK_NAME)-unaligned.apk \
$(ANDROID_APK_NAME).apk \
$(java-harness-dep) \
$(robocop-deps) \
$(NULL)
JAVAFILES += \
$(robocop-deps) \
$(java-harness-dep) \
$(java-tests-dep) \
$(NULL)
DEFINES += \
-DANDROID_PACKAGE_NAME=$(ANDROID_PACKAGE_NAME) \
$(NULL)
JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar:$(ROBOTIUM_PATH)
include $(topsrcdir)/config/rules.mk
# Override rules.mk java flags with the android specific ones
include $(topsrcdir)/config/android-common.mk
GENERATED_DIRS_tools = classes $(dir-tests)
tools:: $(ANDROID_APK_NAME).apk
classes.dex: $(ANDROID_APK_NAME).ap_
classes.dex: $(robocop-deps)
classes.dex: $(java-harness-dep)
classes.dex: $(java-tests-dep)
$(JAVAC) $(JAVAC_FLAGS) -d classes $(JAVAFILES) $(_JAVA_HARNESS) $(java-tests-dep)
$(DX) --dex --output=$@ classes $(ROBOTIUM_PATH) $(ANDROID_COMPT_LIB)
$(ANDROID_APK_NAME).ap_: AndroidManifest.xml $(TESTPATH)/assets/*
$(AAPT) package -f -M $< -I $(ANDROID_SDK)/android.jar -I . -S res -A $(TESTPATH)/assets -F $@ -J ./
$(ANDROID_APK_NAME)-unsigned-unaligned.apk: $(ANDROID_APK_NAME).ap_ classes.dex
cp $< $@
$(ZIP) -0 $@ classes.dex
$(ANDROID_APK_NAME)-unaligned.apk: $(ANDROID_APK_NAME)-unsigned-unaligned.apk
cp $< $@
$(DEBUG_JARSIGNER) $@
$(ANDROID_APK_NAME).apk: $(ANDROID_APK_NAME)-unaligned.apk
$(ZIPALIGN) -f -v 4 $< $@
GENERATED_DIRS += $(dir-tests)
# PP_java-tests not fully usable here
# Intermediate step toward a library rule.

View File

@ -18,7 +18,6 @@ JAVAFILES = \
RunDataThread.java \
SUTAgentAndroid.java \
WifiConfiguration.java \
R.java \
$(NULL)
ANDROID_RESFILES = \
@ -31,42 +30,11 @@ ANDROID_RESFILES = \
res/values/strings.xml \
$(NULL)
GARBAGE += \
AndroidManifest.xml \
classes.dex \
$(ANDROID_APK_NAME).ap_ \
$(ANDROID_APK_NAME)-unsigned-unaligned.apk \
$(ANDROID_APK_NAME)-unaligned.apk \
$(ANDROID_APK_NAME).apk \
ANDROID_EXTRA_JARS = \
$(srcdir)/network-libs/commons-net-2.0.jar \
$(srcdir)/network-libs/jmdns.jar \
$(NULL)
GARBAGE_DIRS += network-libs
EXTRA_JARS = $(srcdir)/network-libs/commons-net-2.0.jar:$(srcdir)/network-libs/jmdns.jar
JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar:$(EXTRA_JARS)
include $(topsrcdir)/config/rules.mk
# include Android specific java flags - using these instead of what's in rules.mk
include $(topsrcdir)/config/android-common.mk
tools:: $(ANDROID_APK_NAME).apk
classes.dex: $(JAVAFILES)
$(JAVAC) $(JAVAC_FLAGS) -d classes $(addprefix $(srcdir)/,$(JAVAFILES))
$(DX) --dex --output=$@ classes $(subst :, ,$(EXTRA_JARS))
$(ANDROID_APK_NAME).ap_: AndroidManifest.xml
$(AAPT) package -f -M $< -I $(ANDROID_SDK)/android.jar -S res -F $@
$(ANDROID_APK_NAME)-unsigned-unaligned.apk: $(ANDROID_APK_NAME).ap_ classes.dex
cp $< $@
$(ZIP) -0 $@ classes.dex
$(ANDROID_APK_NAME)-unaligned.apk: $(ANDROID_APK_NAME)-unsigned-unaligned.apk
cp $< $@
$(DEBUG_JARSIGNER) $@
$(ANDROID_APK_NAME).apk: $(ANDROID_APK_NAME)-unaligned.apk
$(ZIPALIGN) -f -v 4 $< $@

View File

@ -1,37 +0,0 @@
/* 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/. */
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.mozilla.SUTAgentAndroid;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ateamlogo=0x7f020000;
public static final int ic_stat_first=0x7f020001;
public static final int ic_stat_neterror=0x7f020002;
public static final int ic_stat_second=0x7f020003;
public static final int ic_stat_warning=0x7f020004;
public static final int icon=0x7f020005;
}
public static final class id {
public static final int Button01=0x7f050001;
public static final int Textview01=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int foreground_service_started=0x7f040002;
public static final int hello=0x7f040000;
}
}

View File

@ -9,7 +9,6 @@ JAVAFILES = \
FenCP.java \
FenCPFP.java \
FileCursor.java \
R.java \
$(NULL)
ANDROID_RESFILES = \
@ -20,40 +19,6 @@ ANDROID_RESFILES = \
res/values/strings.xml \
$(NULL)
GARBAGE += \
AndroidManifest.xml \
classes.dex \
$(ANDROID_APK_NAME).ap_ \
$(ANDROID_APK_NAME)-unsigned-unaligned.apk \
$(ANDROID_APK_NAME)-unaligned.apk \
$(ANDROID_APK_NAME).apk \
$(NULL)
GARBAGE_DIRS += network-libs
JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar
include $(topsrcdir)/config/rules.mk
# include Android specific java flags - using these instead of what's in rules.mk
include $(topsrcdir)/config/android-common.mk
tools:: $(ANDROID_APK_NAME).apk
classes.dex: $(JAVAFILES)
$(JAVAC) $(JAVAC_FLAGS) -d classes $(addprefix $(srcdir)/,$(JAVAFILES))
$(DX) --dex --output=$@ classes
$(ANDROID_APK_NAME).ap_: AndroidManifest.xml
$(AAPT) package -f -M $< -I $(ANDROID_SDK)/android.jar -S res -F $@
$(ANDROID_APK_NAME)-unsigned-unaligned.apk: $(ANDROID_APK_NAME).ap_ classes.dex
cp $< $@
$(ZIP) -0 $@ classes.dex
$(ANDROID_APK_NAME)-unaligned.apk: $(ANDROID_APK_NAME)-unsigned-unaligned.apk
cp $< $@
$(DEBUG_JARSIGNER) $@
$(ANDROID_APK_NAME).apk: $(ANDROID_APK_NAME)-unaligned.apk
$(ZIPALIGN) -f -v 4 $< $@

View File

@ -1,27 +0,0 @@
/* 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/. */
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package org.mozilla.fencp;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}

View File

@ -9,7 +9,6 @@ JAVAFILES = \
ffxcp.java \
FfxCPFP.java \
FileCursor.java \
R.java \
$(NULL)
ANDROID_RESFILES = \
@ -20,40 +19,6 @@ ANDROID_RESFILES = \
res/values/strings.xml \
$(NULL)
GARBAGE += \
AndroidManifest.xml \
classes.dex \
$(ANDROID_APK_NAME).ap_ \
$(ANDROID_APK_NAME)-unsigned-unaligned.apk \
$(ANDROID_APK_NAME)-unaligned.apk \
$(ANDROID_APK_NAME).apk \
$(NULL)
GARBAGE_DIRS += network-libs
JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar
include $(topsrcdir)/config/rules.mk
# include Android specific java flags - using these instead of what's in rules.mk
include $(topsrcdir)/config/android-common.mk
tools:: $(ANDROID_APK_NAME).apk
classes.dex: $(JAVAFILES)
$(JAVAC) $(JAVAC_FLAGS) -d classes $(addprefix $(srcdir)/,$(JAVAFILES))
$(DX) --dex --output=$@ classes
$(ANDROID_APK_NAME).ap_: AndroidManifest.xml
$(AAPT) package -f -M $< -I $(ANDROID_SDK)/android.jar -S res -F $@
$(ANDROID_APK_NAME)-unsigned-unaligned.apk: $(ANDROID_APK_NAME).ap_ classes.dex
cp $< $@
$(ZIP) -0 $@ classes.dex
$(ANDROID_APK_NAME)-unaligned.apk: $(ANDROID_APK_NAME)-unsigned-unaligned.apk
cp $< $@
$(DEBUG_JARSIGNER) $@
$(ANDROID_APK_NAME).apk: $(ANDROID_APK_NAME)-unaligned.apk
$(ZIPALIGN) -f -v 4 $< $@

View File

@ -1,27 +0,0 @@
/* 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/. */
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package org.mozilla.ffxcp;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}

View File

@ -7,7 +7,6 @@ ANDROID_APK_NAME := Watcher
JAVAFILES = \
IWatcherService.java \
RedirOutputThread.java \
R.java \
WatcherMain.java \
WatcherReceiver.java \
WatcherService.java \
@ -24,41 +23,6 @@ ANDROID_RESFILES = \
res/values/strings.xml \
$(NULL)
GARBAGE += \
AndroidManifest.xml \
classes.dex \
$(ANDROID_APK_NAME).ap_ \
$(ANDROID_APK_NAME)-unsigned-unaligned.apk \
$(ANDROID_APK_NAME)-unaligned.apk \
$(ANDROID_APK_NAME).apk \
$(NULL)
GARBAGE_DIRS += res classes network-libs
JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar
include $(topsrcdir)/config/rules.mk
# include Android specific java flags - using these instead of what's in rules.mk
include $(topsrcdir)/config/android-common.mk
tools:: $(ANDROID_APK_NAME).apk
classes.dex: $(JAVAFILES)
$(NSINSTALL) -D classes
$(JAVAC) $(JAVAC_FLAGS) -d classes $(addprefix $(srcdir)/,$(JAVAFILES))
$(DX) --dex --output=$@ classes
$(ANDROID_APK_NAME).ap_: AndroidManifest.xml
$(AAPT) package -f -M $< -I $(ANDROID_SDK)/android.jar -S res -F $@
$(ANDROID_APK_NAME)-unsigned-unaligned.apk: $(ANDROID_APK_NAME).ap_ classes.dex
cp $< $@
$(ZIP) -0 $@ classes.dex
$(ANDROID_APK_NAME)-unaligned.apk: $(ANDROID_APK_NAME)-unsigned-unaligned.apk
cp $< $@
$(DEBUG_JARSIGNER) $@
$(ANDROID_APK_NAME).apk: $(ANDROID_APK_NAME)-unaligned.apk
$(ZIPALIGN) -f -v 4 $< $@

View File

@ -1,29 +0,0 @@
/* 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/. */
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.mozilla.watcher;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ateamlogo=0x7f020000;
public static final int icon=0x7f020001;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int foreground_service_started=0x7f040002;
public static final int hello=0x7f040000;
}
}

View File

@ -25,7 +25,7 @@ res-dep-preqs := \
$(res-dep): $(res-dep-preqs)
$(call copy_dir,$(srcdir)/res,$(CURDIR)/res)
@$(TOUCH) $@
endif #}
endif #} ANDROID_RESFILES
ifdef JAVAFILES #{
@ -33,7 +33,62 @@ GENERATED_DIRS += classes
export:: classes
classes: $(call mkdir_deps,classes)
endif #}
endif #} JAVAFILES
ifdef ANDROID_APK_NAME #{
_ANDROID_RES_FLAG := -S $(or $(ANDROID_RES_DIR),res)
_ANDROID_ASSETS_FLAG := $(addprefix -A ,$(ANDROID_ASSETS_DIR))
GENERATED_DIRS += classes
classes.dex: $(call mkdir_deps,classes)
classes.dex: R.java
classes.dex: $(ANDROID_APK_NAME).ap_
classes.dex: $(JAVAFILES)
$(JAVAC) $(JAVAC_FLAGS) -d classes $(filter %.java,$^)
$(DX) --dex --output=$@ classes $(ANDROID_EXTRA_JARS)
# R.java and $(ANDROID_APK_NAME).ap_ are both produced by aapt. To
# save an aapt invocation, we produce them both at the same time.
R.java: .aapt.deps
$(ANDROID_APK_NAME).ap_: .aapt.deps
.aapt.deps: AndroidManifest.xml $(wildcard $(ANDROID_RES_DIR)) $(wildcard $(ANDROID_ASSETS_DIR))
$(AAPT) package -f -M $< -I $(ANDROID_SDK)/android.jar $(_ANDROID_RES_FLAG) $(_ANDROID_ASSETS_FLAG) \
-J ${@D} \
-F $(ANDROID_APK_NAME).ap_
@$(TOUCH) $@
$(ANDROID_APK_NAME)-unsigned-unaligned.apk: $(ANDROID_APK_NAME).ap_ classes.dex
cp $< $@
$(ZIP) -0 $@ classes.dex
$(ANDROID_APK_NAME)-unaligned.apk: $(ANDROID_APK_NAME)-unsigned-unaligned.apk
cp $< $@
$(DEBUG_JARSIGNER) $@
$(ANDROID_APK_NAME).apk: $(ANDROID_APK_NAME)-unaligned.apk
$(ZIPALIGN) -f -v 4 $< $@
GARBAGE += \
R.java \
classes.dex \
$(ANDROID_APK_NAME).ap_ \
$(ANDROID_APK_NAME)-unsigned-unaligned.apk \
$(ANDROID_APK_NAME)-unaligned.apk \
$(ANDROID_APK_NAME).apk \
$(NULL)
JAVA_CLASSPATH := $(ANDROID_SDK)/android.jar
ifdef ANDROID_EXTRA_JARS #{
JAVA_CLASSPATH := $(JAVA_CLASSPATH):$(subst $(NULL) ,:,$(strip $(ANDROID_EXTRA_JARS)))
endif #} ANDROID_EXTRA_JARS
# Include Android specific java flags, instead of what's in rules.mk.
include $(topsrcdir)/config/android-common.mk
endif #} ANDROID_APK_NAME
INCLUDED_JAVA_BUILD_MK := 1

View File

@ -25,7 +25,7 @@ res-dep-preqs := \
$(res-dep): $(res-dep-preqs)
$(call copy_dir,$(srcdir)/res,$(CURDIR)/res)
@$(TOUCH) $@
endif #}
endif #} ANDROID_RESFILES
ifdef JAVAFILES #{
@ -33,7 +33,62 @@ GENERATED_DIRS += classes
export:: classes
classes: $(call mkdir_deps,classes)
endif #}
endif #} JAVAFILES
ifdef ANDROID_APK_NAME #{
_ANDROID_RES_FLAG := -S $(or $(ANDROID_RES_DIR),res)
_ANDROID_ASSETS_FLAG := $(addprefix -A ,$(ANDROID_ASSETS_DIR))
GENERATED_DIRS += classes
classes.dex: $(call mkdir_deps,classes)
classes.dex: R.java
classes.dex: $(ANDROID_APK_NAME).ap_
classes.dex: $(JAVAFILES)
$(JAVAC) $(JAVAC_FLAGS) -d classes $(filter %.java,$^)
$(DX) --dex --output=$@ classes $(ANDROID_EXTRA_JARS)
# R.java and $(ANDROID_APK_NAME).ap_ are both produced by aapt. To
# save an aapt invocation, we produce them both at the same time.
R.java: .aapt.deps
$(ANDROID_APK_NAME).ap_: .aapt.deps
.aapt.deps: AndroidManifest.xml $(wildcard $(ANDROID_RES_DIR)) $(wildcard $(ANDROID_ASSETS_DIR))
$(AAPT) package -f -M $< -I $(ANDROID_SDK)/android.jar $(_ANDROID_RES_FLAG) $(_ANDROID_ASSETS_FLAG) \
-J ${@D} \
-F $(ANDROID_APK_NAME).ap_
@$(TOUCH) $@
$(ANDROID_APK_NAME)-unsigned-unaligned.apk: $(ANDROID_APK_NAME).ap_ classes.dex
cp $< $@
$(ZIP) -0 $@ classes.dex
$(ANDROID_APK_NAME)-unaligned.apk: $(ANDROID_APK_NAME)-unsigned-unaligned.apk
cp $< $@
$(DEBUG_JARSIGNER) $@
$(ANDROID_APK_NAME).apk: $(ANDROID_APK_NAME)-unaligned.apk
$(ZIPALIGN) -f -v 4 $< $@
GARBAGE += \
R.java \
classes.dex \
$(ANDROID_APK_NAME).ap_ \
$(ANDROID_APK_NAME)-unsigned-unaligned.apk \
$(ANDROID_APK_NAME)-unaligned.apk \
$(ANDROID_APK_NAME).apk \
$(NULL)
JAVA_CLASSPATH := $(ANDROID_SDK)/android.jar
ifdef ANDROID_EXTRA_JARS #{
JAVA_CLASSPATH := $(JAVA_CLASSPATH):$(subst $(NULL) ,:,$(strip $(ANDROID_EXTRA_JARS)))
endif #} ANDROID_EXTRA_JARS
# Include Android specific java flags, instead of what's in rules.mk.
include $(topsrcdir)/config/android-common.mk
endif #} ANDROID_APK_NAME
INCLUDED_JAVA_BUILD_MK := 1