1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/base/Makefile.in Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,319 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +DIST_FILES := \ 1.9 + package-name.txt.in \ 1.10 + $(NULL) 1.11 + 1.12 +ifneq (,$(findstring -march=armv7,$(OS_CFLAGS))) 1.13 +MIN_CPU_VERSION=7 1.14 +else 1.15 +MIN_CPU_VERSION=5 1.16 +endif 1.17 + 1.18 +MOZ_APP_BUILDID=$(shell cat $(DEPTH)/config/buildid) 1.19 + 1.20 +ifeq (,$(ANDROID_VERSION_CODE)) 1.21 +ifeq ($(CPU_ARCH),arm) 1.22 +ifeq ($(MIN_CPU_VERSION),7) 1.23 +ANDROID_VERSION_CODE=$(shell cat $(DEPTH)/config/buildid | cut -c1-10) 1.24 +else 1.25 +# See https://bugzilla.mozilla.org/show_bug.cgi?id=1042128#c11 for an explanation of this: 1.26 +ANDROID_VERSION_CODE=$(shell cat $(topsrcdir)/mobile/android/config/armv6_play_store_version_code.txt) 1.27 +endif 1.28 +else #not arm, so x86 1.29 +# increment the version code by 1 for x86 builds so they are offered to x86 phones that have arm emulators 1.30 +ANDROID_VERSION_CODE=$(shell echo $$((`cat $(DEPTH)/config/buildid | cut -c1-10` + 1))) 1.31 +endif 1.32 +endif 1.33 + 1.34 +UA_BUILDID=$(shell echo $(ANDROID_VERSION_CODE) | cut -c1-8) 1.35 + 1.36 +MOZ_BUILD_TIMESTAMP=$(shell echo `$(PYTHON) $(topsrcdir)/toolkit/xre/make-platformini.py --print-timestamp`) 1.37 + 1.38 +DEFINES += \ 1.39 + -DANDROID_VERSION_CODE=$(ANDROID_VERSION_CODE) \ 1.40 + -DMOZ_ANDROID_SHARED_ID="$(MOZ_ANDROID_SHARED_ID)" \ 1.41 + -DMOZ_ANDROID_SHARED_ACCOUNT_TYPE="$(MOZ_ANDROID_SHARED_ACCOUNT_TYPE)" \ 1.42 + -DMOZ_ANDROID_SHARED_FXACCOUNT_TYPE="$(MOZ_ANDROID_SHARED_FXACCOUNT_TYPE)" \ 1.43 + -DMOZ_APP_BUILDID=$(MOZ_APP_BUILDID) \ 1.44 + -DMOZ_BUILD_TIMESTAMP=$(MOZ_BUILD_TIMESTAMP) \ 1.45 + -DUA_BUILDID=$(UA_BUILDID) \ 1.46 + -DMOZ_DEBUG=$(MOZ_DEBUG) \ 1.47 + $(NULL) 1.48 + 1.49 +GARBAGE += \ 1.50 + AndroidManifest.xml \ 1.51 + WebappManifestFragment.xml.frag \ 1.52 + classes.dex \ 1.53 + gecko.ap_ \ 1.54 + res/values/strings.xml \ 1.55 + .aapt.deps \ 1.56 + fennec_ids.txt \ 1.57 + javah.out \ 1.58 + jni-stubs.inc \ 1.59 + GeneratedJNIWrappers.cpp \ 1.60 + GeneratedJNIWrappers.h \ 1.61 + $(NULL) 1.62 + 1.63 +GARBAGE_DIRS += classes db jars res sync services generated 1.64 + 1.65 +JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar 1.66 + 1.67 +ALL_JARS = \ 1.68 + gecko-R.jar \ 1.69 + gecko-browser.jar \ 1.70 + gecko-mozglue.jar \ 1.71 + gecko-util.jar \ 1.72 + squareup-picasso.jar \ 1.73 + sync-thirdparty.jar \ 1.74 + websockets.jar \ 1.75 + $(NULL) 1.76 + 1.77 +ifdef MOZ_WEBRTC 1.78 +ALL_JARS += webrtc.jar 1.79 +endif 1.80 + 1.81 +include $(topsrcdir)/config/config.mk 1.82 + 1.83 +# Note that we're going to set up a dependency directly between embed_android.dex and the java files 1.84 +# Instead of on the .class files, since more than one .class file might be produced per .java file 1.85 +# Sync dependencies are provided in a single jar. Sync classes themselves are delivered as source, 1.86 +# because Android resource classes must be compiled together in order to avoid overlapping resource 1.87 +# indices. 1.88 + 1.89 +classes.dex: .proguard.deps 1.90 + $(REPORT_BUILD) 1.91 + $(DX) --dex --output=classes.dex jars-proguarded $(ANDROID_COMPAT_LIB) 1.92 + 1.93 +ifdef MOZ_DISABLE_PROGUARD 1.94 + PROGUARD_PASSES=0 1.95 +else 1.96 + ifdef MOZ_DEBUG 1.97 + PROGUARD_PASSES=1 1.98 + else 1.99 + PROGUARD_PASSES=6 1.100 + endif 1.101 +endif 1.102 + 1.103 +# We touch the target file before invoking Proguard so that Proguard's 1.104 +# outputs are fresher than the target, preventing a subsequent 1.105 +# invocation from thinking Proguard's outputs are stale. This is safe 1.106 +# because Make removes the target file if any recipe command fails. 1.107 +.proguard.deps: $(ALL_JARS) 1.108 + $(REPORT_BUILD) 1.109 + @$(TOUCH) $@ 1.110 + java -jar $(ANDROID_SDK_ROOT)/tools/proguard/lib/proguard.jar \ 1.111 + @$(topsrcdir)/mobile/android/config/proguard.cfg \ 1.112 + -optimizationpasses $(PROGUARD_PASSES) \ 1.113 + -injars $(subst ::,:,$(subst $(NULL) ,:,$(strip $(ALL_JARS)))) \ 1.114 + -outjars jars-proguarded \ 1.115 + -libraryjars $(ANDROID_SDK)/android.jar:$(ANDROID_COMPAT_LIB) 1.116 + 1.117 +CLASSES_WITH_JNI= \ 1.118 + org.mozilla.gecko.ANRReporter \ 1.119 + org.mozilla.gecko.GeckoAppShell \ 1.120 + org.mozilla.gecko.GeckoJavaSampler \ 1.121 + org.mozilla.gecko.gfx.NativePanZoomController \ 1.122 + org.mozilla.gecko.util.NativeJSContainer \ 1.123 + org.mozilla.gecko.util.NativeJSObject \ 1.124 + $(NULL) 1.125 + 1.126 +ifdef MOZ_WEBSMS_BACKEND 1.127 +# Note: if you are building with MOZ_WEBSMS_BACKEND turned on, then 1.128 +# you will get a build error because the generated jni-stubs.inc will 1.129 +# be different than the one checked in (i.e. it will have the sms-related 1.130 +# JNI stubs as well). Just copy the generated file to mozglue/android/ 1.131 +# like the error message says and rebuild. All should be well after that. 1.132 +CLASSES_WITH_JNI += org.mozilla.gecko.GeckoSmsManager 1.133 +endif 1.134 + 1.135 +jni-stubs.inc: gecko-browser.jar gecko-mozglue.jar gecko-util.jar sync-thirdparty.jar 1.136 + $(JAVAH) -o javah.out -bootclasspath $(JAVA_BOOTCLASSPATH) -classpath $(subst $(NULL) $(NULL),:,$^) $(CLASSES_WITH_JNI) 1.137 + $(PYTHON) $(topsrcdir)/mobile/android/base/jni-generator.py javah.out $@ 1.138 + 1.139 +ANNOTATION_PROCESSOR_JAR_FILES := $(DEPTH)/build/annotationProcessors/annotationProcessors.jar 1.140 + 1.141 +GeneratedJNIWrappers.cpp: $(ANNOTATION_PROCESSOR_JAR_FILES) 1.142 +GeneratedJNIWrappers.cpp: $(ALL_JARS) 1.143 + $(JAVA) -classpath gecko-mozglue.jar:$(JAVA_BOOTCLASSPATH):$(ANNOTATION_PROCESSOR_JAR_FILES) org.mozilla.gecko.annotationProcessors.AnnotationProcessor $(ALL_JARS) 1.144 + 1.145 +gecko_package_dir = generated/org/mozilla/gecko 1.146 +# Like generated/org/mozilla/fennec_$USERID. 1.147 +android_package_dir = $(addprefix generated/,$(subst .,/,$(ANDROID_PACKAGE_NAME))) 1.148 + 1.149 +# These _PP_JAVAFILES are specified in moz.build and defined in 1.150 +# backend.mk, which is included by config.mk. Therefore this needs to 1.151 +# be defined after config.mk is included. 1.152 +PP_JAVAFILES := $(filter-out $(gecko_package_dir)/R.java,$(gecko-mozglue_PP_JAVAFILES) $(gecko-browser_PP_JAVAFILES)) 1.153 + 1.154 +manifest := \ 1.155 + AndroidManifest.xml.in \ 1.156 + WebappManifestFragment.xml.frag.in \ 1.157 + $(NULL) 1.158 + 1.159 +PP_TARGETS += manifest 1.160 + 1.161 +# Certain source files need to be preprocessed. This special rule 1.162 +# generates these files into generated/org/mozilla/gecko for 1.163 +# consumption by the build system and IDEs. 1.164 + 1.165 +preprocessed := $(addsuffix .in,$(subst $(gecko_package_dir)/,,$(filter $(gecko_package_dir)/%,$(PP_JAVAFILES)))) 1.166 + 1.167 +preprocessed_PATH := $(gecko_package_dir) 1.168 +preprocessed_KEEP_PATH := 1 1.169 + 1.170 +PP_TARGETS += preprocessed 1.171 + 1.172 +# Certain source files have Java package name @ANDROID_PACKAGE_NAME@. 1.173 +# We hate these files but they are necessary for backwards 1.174 +# compatibility. These special rules generate these files into 1.175 +# generated/org/mozilla/{firefox,firefox_beta,fennec,fennec_$USER} for 1.176 +# consumption by the build system and IDEs. 1.177 + 1.178 +preprocessed_package := $(addsuffix .in,$(subst $(android_package_dir)/,,$(filter $(android_package_dir)/%,$(PP_JAVAFILES)))) 1.179 + 1.180 +preprocessed_package_PATH := $(android_package_dir) 1.181 +preprocessed_package_KEEP_PATH := 1 1.182 + 1.183 +PP_TARGETS += preprocessed_package 1.184 + 1.185 +include $(topsrcdir)/config/rules.mk 1.186 + 1.187 +not_android_res_files := \ 1.188 + *.mkdir.done* \ 1.189 + *.DS_Store* \ 1.190 + *\#* \ 1.191 + *.rej \ 1.192 + *.orig \ 1.193 + $(NULL) 1.194 + 1.195 +# This uses the fact that Android resource directories list all 1.196 +# resource files one subdirectory below the parent resource directory. 1.197 +android_res_files := $(filter-out $(not_android_res_files),$(wildcard $(addsuffix /*,$(wildcard $(addsuffix /*,$(ANDROID_RES_DIRS)))))) 1.198 + 1.199 +$(ANDROID_GENERATED_RESFILES): $(call mkdir_deps,$(sort $(dir $(ANDROID_GENERATED_RESFILES)))) 1.200 + 1.201 +# [Comment 1/3] We don't have correct dependencies for strings.xml at 1.202 +# this point, so we always recursively invoke the submake to check the 1.203 +# dependencies. Sigh. And, with multilocale builds, there will be 1.204 +# multiple strings.xml files, and we need to rebuild gecko.ap_ if any 1.205 +# of them change. But! mobile/android/base/locales does not have 1.206 +# enough information to actually build res/values/strings.xml during a 1.207 +# language repack. So rather than adding rules into the main 1.208 +# makefile, and trying to work around the lack of information, we 1.209 +# force a rebuild of gecko.ap_ during packaging. See below. 1.210 + 1.211 +res/values/strings.xml: FORCE 1.212 + $(MAKE) -C locales 1.213 + 1.214 +all_resources = \ 1.215 + $(CURDIR)/AndroidManifest.xml \ 1.216 + $(CURDIR)/WebappManifestFragment.xml.frag \ 1.217 + $(android_res_files) \ 1.218 + $(ANDROID_GENERATED_RESFILES) \ 1.219 + $(NULL) 1.220 + 1.221 +# For GeckoView, we want a zip of an Android res/ directory that 1.222 +# merges the contents of all the ANDROID_RES_DIRS. The inner res/ 1.223 +# directory must have the Android resource two-layer hierarchy. 1.224 + 1.225 +# The following helper zips files in a directory into a zip file while 1.226 +# maintaining the directory structure rooted below the directory. 1.227 +# (adding or creating said file as appropriate). For example, if the 1.228 +# dir contains dir/subdir/file, calling with directory dir would 1.229 +# create a zip containing subdir/file. Note: the trailing newline is 1.230 +# necessary. 1.231 + 1.232 +# $(1): zip file to add to (or create). 1.233 +# $(2): directory to zip contents of. 1.234 +define zip_directory_with_relative_paths 1.235 +cd $(2) && zip -q $(1) -r * -x $(not_android_res_files) 1.236 + 1.237 +endef 1.238 + 1.239 +geckoview_resources.zip: $(all_resources) $(GLOBAL_DEPS) 1.240 + $(foreach dir,$(ANDROID_RES_DIRS),$(call zip_directory_with_relative_paths,$(CURDIR)/$@,$(dir))) 1.241 + 1.242 +# All of generated/org/mozilla/gecko/R.java, gecko.ap_, and R.txt are 1.243 +# produced by aapt; this saves aapt invocations. The trailing 1.244 +# semi-colon defines an empty recipe; defining no recipe at all causes 1.245 +# Make to treat the target differently, in a way that defeats our 1.246 +# dependencies. 1.247 + 1.248 +$(gecko_package_dir)/R.java: .aapt.deps ; 1.249 +gecko.ap_: .aapt.deps ; 1.250 +R.txt: .aapt.deps ; 1.251 + 1.252 +# [Comment 2/3] This tom-foolery provides a target that forces a 1.253 +# rebuild of gecko.ap_. This is used during packaging to ensure that 1.254 +# resources are fresh. The alternative would be complicated; see 1.255 +# [Comment 1/3]. 1.256 + 1.257 +gecko-nodeps/R.java: .aapt.nodeps ; 1.258 +gecko-nodeps.ap_: .aapt.nodeps ; 1.259 +gecko-nodeps/R.txt: .aapt.nodeps ; 1.260 + 1.261 +# This ignores the default set of resources ignored by aapt, plus 1.262 +# files starting with '#'. (Emacs produces temp files named #temp#.) 1.263 +# This doesn't actually set the environment variable; it's used as a 1.264 +# parameter in the aapt invocation below. Consider updating 1.265 +# not_android_res_files as well. 1.266 + 1.267 +ANDROID_AAPT_IGNORE := !.svn:!.git:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~:\#*:*.rej:*.orig 1.268 + 1.269 +# 1: target file. 1.270 +# 2: dependencies. 1.271 +# 3: name of ap_ file to write. 1.272 +# 4: directory to write R.java into. 1.273 +# 5: directory to write R.txt into. 1.274 +# We touch the target file before invoking aapt so that aapt's outputs 1.275 +# are fresher than the target, preventing a subsequent invocation from 1.276 +# thinking aapt's outputs are stale. This is safe because Make 1.277 +# removes the target file if any recipe command fails. 1.278 +define aapt_command 1.279 +$(1): $$(call mkdir_deps,$(filter-out ./,$(dir $(3) $(4) $(5)))) $(2) 1.280 + @$$(TOUCH) $$@ 1.281 + $$(AAPT) package -f -M AndroidManifest.xml -I $$(ANDROID_SDK)/android.jar \ 1.282 + --auto-add-overlay \ 1.283 + $$(addprefix -S ,$$(ANDROID_RES_DIRS)) \ 1.284 + --custom-package org.mozilla.gecko --non-constant-id \ 1.285 + -F $(3) \ 1.286 + -J $(4) \ 1.287 + --output-text-symbols $(5) \ 1.288 + --ignore-assets "$$(ANDROID_AAPT_IGNORE)" 1.289 +endef 1.290 + 1.291 +# [Comment 3/3] The first of these rules is used during regular 1.292 +# builds. The second writes an ap_ file that is only used during 1.293 +# packaging. It doesn't write the normal ap_, or R.java, since we 1.294 +# don't want the packaging step to write anything that would make a 1.295 +# further no-op build do work. See also 1.296 +# toolkit/mozapps/installer/packager.mk. 1.297 + 1.298 +# .aapt.deps: $(all_resources) 1.299 +$(eval $(call aapt_command,.aapt.deps,$(all_resources),gecko.ap_,$(gecko_package_dir)/,./)) 1.300 + 1.301 +# .aapt.nodeps: $(CURDIR)/AndroidManifest.xml FORCE 1.302 +$(eval $(call aapt_command,.aapt.nodeps,$(CURDIR)/AndroidManifest.xml FORCE,gecko-nodeps.ap_,gecko-nodeps/,gecko-nodeps/)) 1.303 + 1.304 +fennec_ids.txt: $(gecko_package_dir)/R.java fennec-ids-generator.py 1.305 + $(PYTHON) $(topsrcdir)/mobile/android/base/fennec-ids-generator.py -i $< -o $@ 1.306 + 1.307 +# Override the Java settings with some specific android settings 1.308 +include $(topsrcdir)/config/android-common.mk 1.309 + 1.310 +libs:: geckoview_resources.zip classes.dex jni-stubs.inc GeneratedJNIWrappers.cpp fennec_ids.txt 1.311 + $(INSTALL) geckoview_resources.zip $(FINAL_TARGET) 1.312 + $(INSTALL) classes.dex $(FINAL_TARGET) 1.313 + @(diff jni-stubs.inc $(topsrcdir)/mozglue/android/jni-stubs.inc >/dev/null && diff GeneratedJNIWrappers.cpp $(topsrcdir)/widget/android/GeneratedJNIWrappers.cpp >/dev/null) || \ 1.314 + (echo '*****************************************************' && \ 1.315 + echo '*** Error: The generated JNI code has changed ***' && \ 1.316 + echo '* To update generated code in the tree, please run *' && \ 1.317 + echo && \ 1.318 + echo ' cp $(CURDIR)/jni-stubs.inc $(topsrcdir)/mozglue/android && cp $(CURDIR)/GeneratedJNIWrappers.* $(topsrcdir)/widget/android' && \ 1.319 + echo && \ 1.320 + echo '* Repeat the build, and check in any changes. *' && \ 1.321 + echo '*****************************************************' && \ 1.322 + exit 1)