2012-05-21 11:12:37 +00:00
# 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/.
2011-11-18 18:28:17 +00:00
2014-02-05 16:51:48 +00:00
DIST_FILES := \
package-name.txt.in \
$( NULL)
2011-11-18 18:28:17 +00:00
i f n e q ( , $( findstring -march =armv 7,$ ( OS_CFLAGS ) ) )
MIN_CPU_VERSION = 7
e l s e
MIN_CPU_VERSION = 5
e n d i f
2012-08-31 13:31:29 +00:00
MOZ_APP_BUILDID = $( shell cat $( DEPTH) /config/buildid)
2011-11-18 18:28:17 +00:00
i f e q ( , $( ANDROID_VERSION_CODE ) )
2013-06-03 17:22:18 +00:00
i f e q ( $( CPU_ARCH ) , a r m )
2012-07-23 14:12:19 +00:00
i f e q ( $( MIN_CPU_VERSION ) , 7 )
2012-08-09 21:57:41 +00:00
ANDROID_VERSION_CODE = $( shell cat $( DEPTH) /config/buildid | cut -c1-10)
2012-07-23 14:12:19 +00:00
e l s e
# decrement the version code by 1 for armv6 builds so armv7 builds will win any compatability ties
2012-08-09 21:57:41 +00:00
ANDROID_VERSION_CODE = $( shell echo $$ ( ( ` cat $( DEPTH) /config/buildid | cut -c1-10` - 1) ) )
2012-07-23 14:12:19 +00:00
e n d i f
2013-06-03 17:22:18 +00:00
e l s e #not arm, so x86
# increment the version code by 1 for x86 builds so they are offered to x86 phones that have arm emulators
ANDROID_VERSION_CODE = $( shell echo $$ ( ( ` cat $( DEPTH) /config/buildid | cut -c1-10` + 1) ) )
e n d i f
2011-11-18 18:28:17 +00:00
e n d i f
2012-08-09 21:57:41 +00:00
UA_BUILDID = $( shell echo $( ANDROID_VERSION_CODE) | cut -c1-8)
2012-01-10 07:50:56 +00:00
2013-02-06 04:15:36 +00:00
MOZ_BUILD_TIMESTAMP = $( shell echo ` $( PYTHON) $( topsrcdir) /toolkit/xre/make-platformini.py --print-timestamp` )
2011-11-18 18:28:17 +00:00
DEFINES += \
2013-05-16 03:08:43 +00:00
-DANDROID_VERSION_CODE= $( ANDROID_VERSION_CODE) \
2013-10-10 23:08:58 +00:00
-DMOZ_ANDROID_SHARED_ID= " $( MOZ_ANDROID_SHARED_ID) " \
-DMOZ_ANDROID_SHARED_ACCOUNT_TYPE= " $( MOZ_ANDROID_SHARED_ACCOUNT_TYPE) " \
2013-10-13 04:50:38 +00:00
-DMOZ_ANDROID_SHARED_FXACCOUNT_TYPE= " $( MOZ_ANDROID_SHARED_FXACCOUNT_TYPE) " \
2013-05-16 03:08:43 +00:00
-DMOZ_APP_BUILDID= $( MOZ_APP_BUILDID) \
-DMOZ_BUILD_TIMESTAMP= $( MOZ_BUILD_TIMESTAMP) \
-DUA_BUILDID= $( UA_BUILDID) \
2011-11-18 18:28:17 +00:00
$( NULL)
GARBAGE += \
2012-06-11 21:54:17 +00:00
AndroidManifest.xml \
2014-02-12 07:41:05 +00:00
WebappManifestFragment.xml.frag \
2011-11-18 18:28:17 +00:00
classes.dex \
2012-06-11 21:54:17 +00:00
gecko.ap_ \
res/values/strings.xml \
2013-11-12 04:39:16 +00:00
.aapt.deps \
2013-05-20 18:39:49 +00:00
fennec_ids.txt \
2013-02-08 21:42:13 +00:00
javah.out \
jni-stubs.inc \
2013-09-09 12:57:37 +00:00
GeneratedJNIWrappers.cpp \
GeneratedJNIWrappers.h \
2011-11-18 18:28:17 +00:00
$( NULL)
2013-11-12 04:39:16 +00:00
GARBAGE_DIRS += classes db jars res sync services generated
2011-11-18 18:28:17 +00:00
JAVA_CLASSPATH = $( ANDROID_SDK) /android.jar
2013-04-04 11:48:02 +00:00
ALL_JARS = \
2014-03-05 16:57:09 +00:00
gecko-R.jar \
2013-10-24 22:38:22 +00:00
gecko-browser.jar \
gecko-mozglue.jar \
gecko-util.jar \
2014-02-06 21:06:38 +00:00
squareup-picasso.jar \
2013-10-24 22:38:22 +00:00
sync-thirdparty.jar \
websockets.jar \
2013-04-04 11:48:02 +00:00
$( NULL)
i f d e f M O Z _ W E B R T C
2013-10-24 22:38:22 +00:00
ALL_JARS += webrtc.jar
2013-04-04 11:48:02 +00:00
e n d i f
2013-11-12 04:39:16 +00:00
i n c l u d e $( topsrcdir ) / c o n f i g / c o n f i g . m k
2011-11-18 18:28:17 +00:00
# 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
2011-12-21 16:44:06 +00:00
# Sync dependencies are provided in a single jar. Sync classes themselves are delivered as source,
# because Android resource classes must be compiled together in order to avoid overlapping resource
# indices.
2013-12-03 09:39:56 +00:00
2014-02-11 17:55:47 +00:00
classes.dex : .proguard .deps
$( REPORT_BUILD)
2013-11-19 01:30:00 +00:00
$( DX) --dex --output= classes.dex jars-proguarded $( ANDROID_COMPAT_LIB)
2013-12-09 12:21:38 +00:00
i f d e f M O Z _ D I S A B L E _ P R O G U A R D
PROGUARD_PASSES = 0
2013-11-19 01:30:00 +00:00
e l s e
2013-12-09 12:21:38 +00:00
ifdef MOZ_DEBUG
PROGUARD_PASSES = 1
else
PROGUARD_PASSES = 6
endif
2013-11-19 01:30:00 +00:00
e n d i f
2014-02-11 17:55:47 +00:00
.proguard.deps : $( ALL_JARS )
$( REPORT_BUILD)
java -jar $( ANDROID_SDK_ROOT) /tools/proguard/lib/proguard.jar \
@$( topsrcdir) /mobile/android/config/proguard.cfg \
-optimizationpasses $( PROGUARD_PASSES) \
-injars $( subst ::,:,$( subst $( NULL) ,:,$( strip $( ALL_JARS) ) ) ) \
-outjars jars-proguarded \
-libraryjars $( ANDROID_SDK) /android.jar:$( ANDROID_COMPAT_LIB)
@$( TOUCH) $@
2011-11-18 18:28:17 +00:00
2013-02-08 21:42:14 +00:00
CLASSES_WITH_JNI = \
org.mozilla.gecko.GeckoAppShell \
2013-04-26 17:24:28 +00:00
org.mozilla.gecko.GeckoJavaSampler \
org.mozilla.gecko.gfx.NativePanZoomController \
2013-06-14 16:42:10 +00:00
org.mozilla.gecko.ANRReporter \
2013-02-08 21:42:14 +00:00
$( NULL)
i f d e f M O Z _ W E B S M S _ B A C K E N D
# Note: if you are building with MOZ_WEBSMS_BACKEND turned on, then
# you will get a build error because the generated jni-stubs.inc will
# be different than the one checked in (i.e. it will have the sms-related
# JNI stubs as well). Just copy the generated file to mozglue/android/
# like the error message says and rebuild. All should be well after that.
CLASSES_WITH_JNI += org.mozilla.gecko.GeckoSmsManager
e n d i f
2013-10-24 22:38:22 +00:00
jni-stubs.inc : gecko -browser .jar gecko -mozglue .jar gecko -util .jar sync -thirdparty .jar
2013-02-08 21:42:14 +00:00
$( JAVAH) -o javah.out -bootclasspath $( JAVA_BOOTCLASSPATH) -classpath $( subst $( NULL) $( NULL) ,:,$^) $( CLASSES_WITH_JNI)
2013-02-07 14:37:06 +00:00
$( PYTHON) $( topsrcdir) /mobile/android/base/jni-generator.py javah.out $@
2013-10-10 00:05:37 +00:00
ANNOTATION_PROCESSOR_JAR_FILES := $( DEPTH) /build/annotationProcessors/annotationProcessors.jar
2013-09-09 12:57:37 +00:00
2013-10-10 00:05:37 +00:00
GeneratedJNIWrappers.cpp : $( ANNOTATION_PROCESSOR_JAR_FILES )
GeneratedJNIWrappers.cpp : $( ALL_JARS )
2013-11-21 20:41:28 +00:00
$( JAVA) -classpath gecko-mozglue.jar:$( JAVA_BOOTCLASSPATH) :$( ANNOTATION_PROCESSOR_JAR_FILES) org.mozilla.gecko.annotationProcessors.AnnotationProcessor $( ALL_JARS)
2013-09-09 12:57:37 +00:00
2013-11-12 04:39:16 +00:00
gecko_package_dir = generated/org/mozilla/gecko
# Like generated/org/mozilla/fennec_$USERID.
android_package_dir = $( addprefix generated/,$( subst .,/,$( ANDROID_PACKAGE_NAME) ) )
2012-01-25 23:53:13 +00:00
2013-11-12 04:39:16 +00:00
# These _PP_JAVAFILES are specified in moz.build and defined in
# backend.mk, which is included by config.mk. Therefore this needs to
# be defined after config.mk is included.
PP_JAVAFILES := $( filter-out $( gecko_package_dir) /R.java,$( gecko-mozglue_PP_JAVAFILES) $( gecko-browser_PP_JAVAFILES) )
2012-06-11 21:54:17 +00:00
2013-11-12 04:39:16 +00:00
manifest := \
AndroidManifest.xml.in \
2014-02-12 07:41:05 +00:00
WebappManifestFragment.xml.frag.in \
2012-05-03 10:22:33 +00:00
$( NULL)
2013-11-12 04:39:16 +00:00
PP_TARGETS += manifest
# Certain source files need to be preprocessed. This special rule
# generates these files into generated/org/mozilla/gecko for
# consumption by the build system and IDEs.
preprocessed := $( addsuffix .in,$( subst $( gecko_package_dir) /,,$( filter $( gecko_package_dir) /%,$( PP_JAVAFILES) ) ) )
preprocessed_PATH := $( gecko_package_dir)
preprocessed_KEEP_PATH := 1
PP_TARGETS += preprocessed
# Certain source files have Java package name @ANDROID_PACKAGE_NAME@.
# We hate these files but they are necessary for backwards
# compatibility. These special rules generate these files into
# generated/org/mozilla/{firefox,firefox_beta,fennec,fennec_$USER} for
# consumption by the build system and IDEs.
preprocessed_package := $( addsuffix .in,$( subst $( android_package_dir) /,,$( filter $( android_package_dir) /%,$( PP_JAVAFILES) ) ) )
preprocessed_package_PATH := $( android_package_dir)
preprocessed_package_KEEP_PATH := 1
PP_TARGETS += preprocessed_package
2011-11-18 18:28:17 +00:00
2013-12-12 05:20:07 +00:00
i n c l u d e $( topsrcdir ) / c o n f i g / r u l e s . m k
2012-11-21 19:53:25 +00:00
2014-02-05 16:51:48 +00:00
not_android_res_files := \
*.mkdir.done* \
*.DS_Store* \
$( NULL)
2013-12-12 05:20:07 +00:00
# This uses the fact that Android resource directories list all
# resource files one subdirectory below the parent resource directory.
2014-02-05 16:51:48 +00:00
android_res_files := $( filter-out $( not_android_res_files) ,$( wildcard $( addsuffix /*,$( wildcard $( addsuffix /*,$( ANDROID_RES_DIRS) ) ) ) ) )
# For GeckoView, we want a zip of an Android res/ directory that
# merges the contents of all the ANDROID_RES_DIRS. The inner res/
# directory must have the Android resource two-layer hierarchy.
# The following helper zips files in a directory into a zip file while
# maintaining the directory structure rooted below the directory.
# (adding or creating said file as appropriate). For example, if the
# dir contains dir/subdir/file, calling with directory dir would
# create a zip containing subdir/file. Note: the trailing newline is
# necessary.
# $(1): zip file to add to (or create).
# $(2): directory to zip contents of.
d e f i n e z i p _ d i r e c t o r y _ w i t h _ r e l a t i v e _ p a t h s
c d $( 2) & & z i p - q $( 1) - r * - x $( not_android_res_files )
e n d e f
geckoview_resources.zip : $( android_res_files ) $( GLOBAL_DEPS )
$( foreach dir,$( ANDROID_RES_DIRS) ,$( call zip_directory_with_relative_paths,$( CURDIR) /$@ ,$( dir) ) )
2013-10-09 23:19:00 +00:00
2013-12-12 05:20:07 +00:00
$(ANDROID_GENERATED_RESFILES) : $( call mkdir_deps ,$ ( sort $ ( dir $ ( ANDROID_GENERATED_RESFILES ) ) ) )
2012-06-11 21:54:17 +00:00
2013-12-12 05:20:07 +00:00
# [Comment 1/3] We don't have correct dependencies for strings.xml at
# this point, so we always recursively invoke the submake to check the
# dependencies. Sigh. And, with multilocale builds, there will be
# multiple strings.xml files, and we need to rebuild gecko.ap_ if any
# of them change. But! mobile/android/base/locales does not have
# enough information to actually build res/values/strings.xml during a
# language repack. So rather than adding rules into the main
# makefile, and trying to work around the lack of information, we
# force a rebuild of gecko.ap_ during packaging. See below.
2011-11-18 18:28:17 +00:00
2013-12-12 05:20:07 +00:00
res/values/strings.xml : FORCE
2013-07-02 19:57:16 +00:00
$( MAKE) -C locales
2011-12-20 15:28:12 +00:00
2013-07-18 22:09:03 +00:00
all_resources = \
2013-12-14 23:36:17 +00:00
$( CURDIR) /AndroidManifest.xml \
2014-02-12 07:41:05 +00:00
$( CURDIR) /WebappManifestFragment.xml.frag \
2013-12-12 05:20:07 +00:00
$( android_res_files) \
2013-10-09 23:19:00 +00:00
$( ANDROID_GENERATED_RESFILES) \
2013-07-18 22:09:03 +00:00
$( NULL)
2013-12-12 05:20:07 +00:00
# All of generated/org/mozilla/gecko/R.java, gecko.ap_, and R.txt are
# produced by aapt; this saves aapt invocations.
2013-11-12 04:39:16 +00:00
2014-02-11 14:35:12 +00:00
$(gecko_package_dir)/R.java : .aapt .deps
2013-11-12 04:39:16 +00:00
gecko.ap_ : .aapt .deps
2013-12-12 05:20:07 +00:00
R.txt : .aapt .deps
# [Comment 2/3] This tom-foolery provides a target that forces a
# rebuild of gecko.ap_. This is used during packaging to ensure that
# resources are fresh. The alternative would be complicated; see
# [Comment 1/3].
2014-02-11 14:35:12 +00:00
gecko-nodeps/R.java : .aapt .nodeps
2013-12-12 05:20:07 +00:00
gecko-nodeps.ap_ : .aapt .nodeps
gecko-nodeps/R.txt : .aapt .nodeps
# 1: target file.
# 2: dependencies.
# 3: name of ap_ file to write.
# 4: directory to write R.java into.
# 5: directory to write R.txt into.
d e f i n e a a p t _ c o m m a n d
$(1) : $$( call mkdir_deps ,$ ( filter -out ./,$ ( dir $ ( 3) $ ( 4) $ ( 5) ) ) ) $( 2)
$$ ( AAPT) package -f -M AndroidManifest.xml -I $$ ( ANDROID_SDK) /android.jar \
--auto-add-overlay \
$$ ( addprefix -S ,$$ ( ANDROID_RES_DIRS) ) \
--custom-package org.mozilla.gecko --non-constant-id \
-F $( 3) \
-J $( 4) \
--output-text-symbols $( 5)
@$$ ( TOUCH) $$ @
e n d e f
# [Comment 3/3] The first of these rules is used during regular
# builds. The second writes an ap_ file that is only used during
# packaging. It doesn't write the normal ap_, or R.java, since we
# don't want the packaging step to write anything that would make a
# further no-op build do work. See also
# toolkit/mozapps/installer/packager.mk.
# .aapt.deps: $(all_resources)
$( eval $ ( call aapt_command ,.aapt .deps ,$ ( all_resources ) ,gecko .ap_ ,$ ( gecko_package_dir ) /,./) )
2013-12-14 23:36:17 +00:00
# .aapt.nodeps: $(CURDIR)/AndroidManifest.xml FORCE
$( eval $ ( call aapt_command ,.aapt .nodeps ,$ ( CURDIR ) /AndroidManifest .xml FORCE ,gecko -nodeps .ap_ ,gecko -nodeps /,gecko -nodeps /) )
2013-11-12 04:39:16 +00:00
2014-02-11 14:35:12 +00:00
fennec_ids.txt : $( gecko_package_dir ) /R .java fennec -ids -generator .py
2013-11-12 04:39:16 +00:00
$( PYTHON) $( topsrcdir) /mobile/android/base/fennec-ids-generator.py -i $< -o $@
2011-11-18 18:28:17 +00:00
2013-11-12 04:39:16 +00:00
# Override the Java settings with some specific android settings
i n c l u d e $( topsrcdir ) / c o n f i g / a n d r o i d - c o m m o n . m k
2013-05-20 18:39:49 +00:00
2014-02-05 16:51:48 +00:00
libs :: geckoview_resources .zip classes .dex jni -stubs .inc GeneratedJNIWrappers .cpp fennec_ids .txt
$( INSTALL) geckoview_resources.zip $( FINAL_TARGET)
2012-06-11 21:54:17 +00:00
$( INSTALL) classes.dex $( FINAL_TARGET)
2013-09-09 12:57:37 +00:00
@( diff jni-stubs.inc $( topsrcdir) /mozglue/android/jni-stubs.inc >/dev/null && diff GeneratedJNIWrappers.cpp $( topsrcdir) /widget/android/GeneratedJNIWrappers.cpp >/dev/null) || \
2013-12-02 21:34:21 +00:00
( echo '*** Error: The generated JNI code has changed. Please run cp $(CURDIR)/jni-stubs.inc $(topsrcdir)/mozglue/android && cp $(CURDIR)/GeneratedJNIWrappers.* $(topsrcdir)/widget/android and repeat the build.' && exit 1)