Bug 567945 Android agent needs to build in mozilla-central r=ted
authorClint Talbert <ctalbert@mozilla.com>
Mon, 21 Jun 2010 14:26:55 -0700
changeset 43915 da2d8dc257d54fb2d0d4c5ec43ede6291dcaeab2
parent 43914 7f2f32d46ed86598f76d3ce449b738f1ef57d5ff
child 43916 f8e71992be6b08fbc1a563a29169622593c97669
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs567945
milestone1.9.3a6pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 567945 Android agent needs to build in mozilla-central r=ted
build/Makefile.in
build/mobile/sutagent/android/Makefile.in
config/android-common.mk
embedding/android/Makefile.in
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -66,16 +66,20 @@ DIRS += wince/tools \
 	wince/shunt \
 	$(DEPTH)/memory/mozalloc \
 	$(NULL)
 endif
 endif
 
 DIRS += pgo
 
+ifeq (Android,$(OS_TARGET))
+  DIRS += mobile/sutagent/android
+endif
+
 include $(topsrcdir)/config/rules.mk
 
 # we install to _leaktest/
 TARGET_DEPTH = ..
 include $(srcdir)/automation-build.mk
 
 _LEAKTEST_DIR = $(DEPTH)/_leaktest
 GARBAGE_DIRS += $(_LEAKTEST_DIR)
new file mode 100644
--- /dev/null
+++ b/build/mobile/sutagent/android/Makefile.in
@@ -0,0 +1,110 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (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.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is the Android sutagent for testing.
+#
+# The Initial Developer of the Original Code is
+#   Mozilla Foundation
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#   Clint Talbert <ctalbert@mozilla.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH		= ../../../..
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH		= @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = sutAgentAndroid
+
+JAVAFILES = \
+  AlertLooperThread.java \
+  ASMozStub.java \
+  CmdWorkerThread.java \
+  DataWorkerThread.java \
+  DoAlert.java \
+  DoCommand.java \
+  Power.java \
+  RedirOutputThread.java \
+  RunCmdThread.java \
+  RunDataThread.java \
+  SUTAgentAndroid.java \
+  SUTStartupIntentReceiver.java \
+  WifiConfiguration.java \
+  R.java \
+  $(NULL)
+
+RES_FILES = \
+  res/drawable/icon.png \
+  res/layout/main.xml \
+  res/values/strings.xml \
+  $(NULL)
+
+GARBAGE += \
+  AndroidManifest.xml  \
+  classes.dex  \
+  sutAgentAndroid.apk  \
+  $(NULL)
+
+GARBAGE_DIRS += res classes network-libs
+
+JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar:$(srcdir)/network-libs/commons-net-2.0.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:: sutAgentAndroid.apk
+
+classes.dex: $(JAVAFILES)
+	$(NSINSTALL) -D classes
+	$(JAVAC) $(JAVAC_FLAGS) -d classes  $(addprefix $(srcdir)/,$(JAVAFILES))
+	$(DX) --dex --output=$@ classes
+
+sutAgentAndroid.ap_: $(srcdir)/AndroidManifest.xml
+	$(AAPT) package -f -M $(srcdir)/AndroidManifest.xml -I $(ANDROID_SDK)/android.jar  -S res -F $@
+
+sutAgentAndroid-unsigned-unaligned.apk: sutAgentAndroid.ap_ classes.dex
+	$(APKBUILDER) $@ -v $(APKBUILDER_FLAGS) -z sutAgentAndroid.ap_ -f classes.dex
+
+sutAgentAndroid-unaligned.apk: sutAgentAndroid-unsigned-unaligned.apk
+	cp  sutAgentAndroid-unsigned-unaligned.apk $@
+ifdef JARSIGNER
+  $(JARSIGNER) $@
+endif
+
+sutAgentAndroid.apk: sutAgentAndroid-unaligned.apk
+	$(ZIPALIGN) -f -v 4 sutAgentAndroid-unaligned.apk $@
+
+export::
+	$(NSINSTALL) -D res
+	@(cd $(srcdir)/res && tar $(TAR_CREATE_FLAGS) - *) | (cd $(DEPTH)/build/mobile/sutagent/android/res && tar -xf -)
+
new file mode 100644
--- /dev/null
+++ b/config/android-common.mk
@@ -0,0 +1,78 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (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.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Android Java Make Settings.
+#
+# The Initial Developer of the Original Code is
+# Mozilla Foundation.
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#   Clint Talbert <cmtalbert@gmail.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+# Ensure JAVA_CLASSPATH and ANDROID_SDK are defined before including this file.
+# We use common android defaults for boot class path and java version.
+ifndef ANDROID_SDK
+  $(error ANDROID_SDK must be defined before including android-common.mk)
+endif
+
+ifndef JAVA_CLASSPATH
+  $(error JAVA_CLASSPATH must be defined before including android-common.mk)
+endif
+
+DX=$(ANDROID_SDK)/tools/dx
+AAPT=$(ANDROID_SDK)/tools/aapt
+APKBUILDER=$(ANDROID_SDK)/../../tools/apkbuilder
+ZIPALIGN=$(ANDROID_SDK)/../../tools/zipalign
+
+ifdef JARSIGNER
+  APKBUILDER_FLAGS += -u
+endif
+
+# For Android, this defaults to $(ANDROID_SDK)/android.jar
+ifndef JAVA_BOOTCLASSPATH
+  JAVA_BOOTCLASSPATH = $(ANDROID_SDK)/android.jar
+endif
+
+# For Android, we default to 1.5
+ifndef JAVA_VERSION
+  JAVA_VERSION = 1.5
+endif
+
+JAVAC_FLAGS = \
+  -target $(JAVA_VERSION) \
+  -classpath $(JAVA_CLASSPATH) \
+  -bootclasspath $(JAVA_BOOTCLASSPATH) \
+  -encoding ascii \
+  -g \
+  $(NULL)
+
+# Note that we're going to set up a dependency directly between embed_android.dex and the java files
+# Instead of on the .class files, since more than one .class file might be produced per .java file
+# The $JAVAFILES_IN are for any optional, interpolated java files that are needed.
+
--- a/embedding/android/Makefile.in
+++ b/embedding/android/Makefile.in
@@ -37,21 +37,16 @@
 
 DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DX=$(ANDROID_SDK)/tools/dx
-AAPT=$(ANDROID_SDK)/tools/aapt
-APKBUILDER=$(ANDROID_SDK)/../../tools/apkbuilder
-ZIPALIGN=$(ANDROID_SDK)/../../tools/zipalign
-
 JAVAFILES = \
   GeckoApp.java \
   GeckoAppShell.java \
   GeckoEvent.java \
   GeckoSurfaceView.java \
   $(NULL)
 
 DEFINES += \
@@ -66,20 +61,16 @@ GARBAGE += \
   Restarter.java \
   gecko.ap_  \
   gecko-unaligned.apk  \
   gecko-unsigned-unaligned.apk \
   $(NULL)
 
 GARBAGE_DIRS += res libs dist classes
 
-ifdef JARSIGNER
-  APKBUILDER_FLAGS += -u
-endif
-
 # Bug 567884 - Need a way to find appropriate icons during packaging
 ifeq ($(MOZ_APP_NAME),fennec)
 ICON_PATH = $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/content/fennec_48x48.png
 ICON_PATH_HI = $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/content/fennec_72x72.png
 else
 ICON_PATH = $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/content/icon48.png
 ICON_PATH_HI = $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/content/icon64.png
 endif
@@ -103,26 +94,22 @@ DIST_LINK_FILES = \
   res \
   application.ini \
   platform.ini \
   greprefs.js \
   browserconfig.properties \
   blocklist.xml \
   $(NULL)
 
+JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar
+
 include $(topsrcdir)/config/rules.mk
 
-# rules.mk has some java stuff, but we're going to ignore it for now
-JAVAC_FLAGS = \
-  -target 1.5 \
-  -classpath $(ANDROID_SDK)/android.jar \
-  -bootclasspath $(ANDROID_SDK)/android.jar \
-  -encoding ascii \
-  -g \
-  $(NULL)
+# Override the Java settings with some specific android settings
+include $(topsrcdir)/config/android-common.mk
 
 tools:: $(MOZ_APP_NAME).apk
 
 # Note that we're going to set up a dependency directly between embed_android.dex and the java files
 # Instead of on the .class files, since more than one .class file might be produced per .java file
 classes.dex: $(JAVAFILES) App.java Restarter.java
 	$(NSINSTALL) -D classes
 	$(JAVAC) $(JAVAC_FLAGS) -d classes  $(addprefix $(srcdir)/,$(JAVAFILES)) App.java Restarter.java