From 7ee47c2f86d98b93dfe44414c217a040ae750c46 Mon Sep 17 00:00:00 2001 From: Clint Talbert Date: Mon, 21 Jun 2010 14:26:55 -0700 Subject: [PATCH] Bug 567945 Android agent needs to build in mozilla-central r=ted --- build/Makefile.in | 4 + build/mobile/sutagent/android/Makefile.in | 110 ++++++++++++++++++++++ config/android-common.mk | 78 +++++++++++++++ embedding/android/Makefile.in | 21 +---- 4 files changed, 196 insertions(+), 17 deletions(-) create mode 100644 build/mobile/sutagent/android/Makefile.in create mode 100644 config/android-common.mk diff --git a/build/Makefile.in b/build/Makefile.in index 3f7ba909213..4e1c4fda02a 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -71,6 +71,10 @@ endif DIRS += pgo +ifeq (Android,$(OS_TARGET)) + DIRS += mobile/sutagent/android +endif + include $(topsrcdir)/config/rules.mk # we install to _leaktest/ diff --git a/build/mobile/sutagent/android/Makefile.in b/build/mobile/sutagent/android/Makefile.in new file mode 100644 index 00000000000..a1b32920372 --- /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 +# +# 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 -) + diff --git a/config/android-common.mk b/config/android-common.mk new file mode 100644 index 00000000000..4fab96959a9 --- /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 +# +# 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. + diff --git a/embedding/android/Makefile.in b/embedding/android/Makefile.in index cff222a381f..c16272e4e56 100644 --- a/embedding/android/Makefile.in +++ b/embedding/android/Makefile.in @@ -42,11 +42,6 @@ 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 \ @@ -71,10 +66,6 @@ GARBAGE += \ 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 @@ -108,16 +99,12 @@ DIST_LINK_FILES = \ 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