mobile/android/base/Makefile.in

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 4
michael@0 5 DIST_FILES := \
michael@0 6 package-name.txt.in \
michael@0 7 $(NULL)
michael@0 8
michael@0 9 ifneq (,$(findstring -march=armv7,$(OS_CFLAGS)))
michael@0 10 MIN_CPU_VERSION=7
michael@0 11 else
michael@0 12 MIN_CPU_VERSION=5
michael@0 13 endif
michael@0 14
michael@0 15 MOZ_APP_BUILDID=$(shell cat $(DEPTH)/config/buildid)
michael@0 16
michael@0 17 ifeq (,$(ANDROID_VERSION_CODE))
michael@0 18 ifeq ($(CPU_ARCH),arm)
michael@0 19 ifeq ($(MIN_CPU_VERSION),7)
michael@0 20 ANDROID_VERSION_CODE=$(shell cat $(DEPTH)/config/buildid | cut -c1-10)
michael@0 21 else
michael@0 22 # See https://bugzilla.mozilla.org/show_bug.cgi?id=1042128#c11 for an explanation of this:
michael@0 23 ANDROID_VERSION_CODE=$(shell cat $(topsrcdir)/mobile/android/config/armv6_play_store_version_code.txt)
michael@0 24 endif
michael@0 25 else #not arm, so x86
michael@0 26 # increment the version code by 1 for x86 builds so they are offered to x86 phones that have arm emulators
michael@0 27 ANDROID_VERSION_CODE=$(shell echo $$((`cat $(DEPTH)/config/buildid | cut -c1-10` + 1)))
michael@0 28 endif
michael@0 29 endif
michael@0 30
michael@0 31 UA_BUILDID=$(shell echo $(ANDROID_VERSION_CODE) | cut -c1-8)
michael@0 32
michael@0 33 MOZ_BUILD_TIMESTAMP=$(shell echo `$(PYTHON) $(topsrcdir)/toolkit/xre/make-platformini.py --print-timestamp`)
michael@0 34
michael@0 35 DEFINES += \
michael@0 36 -DANDROID_VERSION_CODE=$(ANDROID_VERSION_CODE) \
michael@0 37 -DMOZ_ANDROID_SHARED_ID="$(MOZ_ANDROID_SHARED_ID)" \
michael@0 38 -DMOZ_ANDROID_SHARED_ACCOUNT_TYPE="$(MOZ_ANDROID_SHARED_ACCOUNT_TYPE)" \
michael@0 39 -DMOZ_ANDROID_SHARED_FXACCOUNT_TYPE="$(MOZ_ANDROID_SHARED_FXACCOUNT_TYPE)" \
michael@0 40 -DMOZ_APP_BUILDID=$(MOZ_APP_BUILDID) \
michael@0 41 -DMOZ_BUILD_TIMESTAMP=$(MOZ_BUILD_TIMESTAMP) \
michael@0 42 -DUA_BUILDID=$(UA_BUILDID) \
michael@0 43 -DMOZ_DEBUG=$(MOZ_DEBUG) \
michael@0 44 $(NULL)
michael@0 45
michael@0 46 GARBAGE += \
michael@0 47 AndroidManifest.xml \
michael@0 48 WebappManifestFragment.xml.frag \
michael@0 49 classes.dex \
michael@0 50 gecko.ap_ \
michael@0 51 res/values/strings.xml \
michael@0 52 .aapt.deps \
michael@0 53 fennec_ids.txt \
michael@0 54 javah.out \
michael@0 55 jni-stubs.inc \
michael@0 56 GeneratedJNIWrappers.cpp \
michael@0 57 GeneratedJNIWrappers.h \
michael@0 58 $(NULL)
michael@0 59
michael@0 60 GARBAGE_DIRS += classes db jars res sync services generated
michael@0 61
michael@0 62 JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar
michael@0 63
michael@0 64 ALL_JARS = \
michael@0 65 gecko-R.jar \
michael@0 66 gecko-browser.jar \
michael@0 67 gecko-mozglue.jar \
michael@0 68 gecko-util.jar \
michael@0 69 squareup-picasso.jar \
michael@0 70 sync-thirdparty.jar \
michael@0 71 websockets.jar \
michael@0 72 $(NULL)
michael@0 73
michael@0 74 ifdef MOZ_WEBRTC
michael@0 75 ALL_JARS += webrtc.jar
michael@0 76 endif
michael@0 77
michael@0 78 include $(topsrcdir)/config/config.mk
michael@0 79
michael@0 80 # Note that we're going to set up a dependency directly between embed_android.dex and the java files
michael@0 81 # Instead of on the .class files, since more than one .class file might be produced per .java file
michael@0 82 # Sync dependencies are provided in a single jar. Sync classes themselves are delivered as source,
michael@0 83 # because Android resource classes must be compiled together in order to avoid overlapping resource
michael@0 84 # indices.
michael@0 85
michael@0 86 classes.dex: .proguard.deps
michael@0 87 $(REPORT_BUILD)
michael@0 88 $(DX) --dex --output=classes.dex jars-proguarded $(ANDROID_COMPAT_LIB)
michael@0 89
michael@0 90 ifdef MOZ_DISABLE_PROGUARD
michael@0 91 PROGUARD_PASSES=0
michael@0 92 else
michael@0 93 ifdef MOZ_DEBUG
michael@0 94 PROGUARD_PASSES=1
michael@0 95 else
michael@0 96 PROGUARD_PASSES=6
michael@0 97 endif
michael@0 98 endif
michael@0 99
michael@0 100 # We touch the target file before invoking Proguard so that Proguard's
michael@0 101 # outputs are fresher than the target, preventing a subsequent
michael@0 102 # invocation from thinking Proguard's outputs are stale. This is safe
michael@0 103 # because Make removes the target file if any recipe command fails.
michael@0 104 .proguard.deps: $(ALL_JARS)
michael@0 105 $(REPORT_BUILD)
michael@0 106 @$(TOUCH) $@
michael@0 107 java -jar $(ANDROID_SDK_ROOT)/tools/proguard/lib/proguard.jar \
michael@0 108 @$(topsrcdir)/mobile/android/config/proguard.cfg \
michael@0 109 -optimizationpasses $(PROGUARD_PASSES) \
michael@0 110 -injars $(subst ::,:,$(subst $(NULL) ,:,$(strip $(ALL_JARS)))) \
michael@0 111 -outjars jars-proguarded \
michael@0 112 -libraryjars $(ANDROID_SDK)/android.jar:$(ANDROID_COMPAT_LIB)
michael@0 113
michael@0 114 CLASSES_WITH_JNI= \
michael@0 115 org.mozilla.gecko.ANRReporter \
michael@0 116 org.mozilla.gecko.GeckoAppShell \
michael@0 117 org.mozilla.gecko.GeckoJavaSampler \
michael@0 118 org.mozilla.gecko.gfx.NativePanZoomController \
michael@0 119 org.mozilla.gecko.util.NativeJSContainer \
michael@0 120 org.mozilla.gecko.util.NativeJSObject \
michael@0 121 $(NULL)
michael@0 122
michael@0 123 ifdef MOZ_WEBSMS_BACKEND
michael@0 124 # Note: if you are building with MOZ_WEBSMS_BACKEND turned on, then
michael@0 125 # you will get a build error because the generated jni-stubs.inc will
michael@0 126 # be different than the one checked in (i.e. it will have the sms-related
michael@0 127 # JNI stubs as well). Just copy the generated file to mozglue/android/
michael@0 128 # like the error message says and rebuild. All should be well after that.
michael@0 129 CLASSES_WITH_JNI += org.mozilla.gecko.GeckoSmsManager
michael@0 130 endif
michael@0 131
michael@0 132 jni-stubs.inc: gecko-browser.jar gecko-mozglue.jar gecko-util.jar sync-thirdparty.jar
michael@0 133 $(JAVAH) -o javah.out -bootclasspath $(JAVA_BOOTCLASSPATH) -classpath $(subst $(NULL) $(NULL),:,$^) $(CLASSES_WITH_JNI)
michael@0 134 $(PYTHON) $(topsrcdir)/mobile/android/base/jni-generator.py javah.out $@
michael@0 135
michael@0 136 ANNOTATION_PROCESSOR_JAR_FILES := $(DEPTH)/build/annotationProcessors/annotationProcessors.jar
michael@0 137
michael@0 138 GeneratedJNIWrappers.cpp: $(ANNOTATION_PROCESSOR_JAR_FILES)
michael@0 139 GeneratedJNIWrappers.cpp: $(ALL_JARS)
michael@0 140 $(JAVA) -classpath gecko-mozglue.jar:$(JAVA_BOOTCLASSPATH):$(ANNOTATION_PROCESSOR_JAR_FILES) org.mozilla.gecko.annotationProcessors.AnnotationProcessor $(ALL_JARS)
michael@0 141
michael@0 142 gecko_package_dir = generated/org/mozilla/gecko
michael@0 143 # Like generated/org/mozilla/fennec_$USERID.
michael@0 144 android_package_dir = $(addprefix generated/,$(subst .,/,$(ANDROID_PACKAGE_NAME)))
michael@0 145
michael@0 146 # These _PP_JAVAFILES are specified in moz.build and defined in
michael@0 147 # backend.mk, which is included by config.mk. Therefore this needs to
michael@0 148 # be defined after config.mk is included.
michael@0 149 PP_JAVAFILES := $(filter-out $(gecko_package_dir)/R.java,$(gecko-mozglue_PP_JAVAFILES) $(gecko-browser_PP_JAVAFILES))
michael@0 150
michael@0 151 manifest := \
michael@0 152 AndroidManifest.xml.in \
michael@0 153 WebappManifestFragment.xml.frag.in \
michael@0 154 $(NULL)
michael@0 155
michael@0 156 PP_TARGETS += manifest
michael@0 157
michael@0 158 # Certain source files need to be preprocessed. This special rule
michael@0 159 # generates these files into generated/org/mozilla/gecko for
michael@0 160 # consumption by the build system and IDEs.
michael@0 161
michael@0 162 preprocessed := $(addsuffix .in,$(subst $(gecko_package_dir)/,,$(filter $(gecko_package_dir)/%,$(PP_JAVAFILES))))
michael@0 163
michael@0 164 preprocessed_PATH := $(gecko_package_dir)
michael@0 165 preprocessed_KEEP_PATH := 1
michael@0 166
michael@0 167 PP_TARGETS += preprocessed
michael@0 168
michael@0 169 # Certain source files have Java package name @ANDROID_PACKAGE_NAME@.
michael@0 170 # We hate these files but they are necessary for backwards
michael@0 171 # compatibility. These special rules generate these files into
michael@0 172 # generated/org/mozilla/{firefox,firefox_beta,fennec,fennec_$USER} for
michael@0 173 # consumption by the build system and IDEs.
michael@0 174
michael@0 175 preprocessed_package := $(addsuffix .in,$(subst $(android_package_dir)/,,$(filter $(android_package_dir)/%,$(PP_JAVAFILES))))
michael@0 176
michael@0 177 preprocessed_package_PATH := $(android_package_dir)
michael@0 178 preprocessed_package_KEEP_PATH := 1
michael@0 179
michael@0 180 PP_TARGETS += preprocessed_package
michael@0 181
michael@0 182 include $(topsrcdir)/config/rules.mk
michael@0 183
michael@0 184 not_android_res_files := \
michael@0 185 *.mkdir.done* \
michael@0 186 *.DS_Store* \
michael@0 187 *\#* \
michael@0 188 *.rej \
michael@0 189 *.orig \
michael@0 190 $(NULL)
michael@0 191
michael@0 192 # This uses the fact that Android resource directories list all
michael@0 193 # resource files one subdirectory below the parent resource directory.
michael@0 194 android_res_files := $(filter-out $(not_android_res_files),$(wildcard $(addsuffix /*,$(wildcard $(addsuffix /*,$(ANDROID_RES_DIRS))))))
michael@0 195
michael@0 196 $(ANDROID_GENERATED_RESFILES): $(call mkdir_deps,$(sort $(dir $(ANDROID_GENERATED_RESFILES))))
michael@0 197
michael@0 198 # [Comment 1/3] We don't have correct dependencies for strings.xml at
michael@0 199 # this point, so we always recursively invoke the submake to check the
michael@0 200 # dependencies. Sigh. And, with multilocale builds, there will be
michael@0 201 # multiple strings.xml files, and we need to rebuild gecko.ap_ if any
michael@0 202 # of them change. But! mobile/android/base/locales does not have
michael@0 203 # enough information to actually build res/values/strings.xml during a
michael@0 204 # language repack. So rather than adding rules into the main
michael@0 205 # makefile, and trying to work around the lack of information, we
michael@0 206 # force a rebuild of gecko.ap_ during packaging. See below.
michael@0 207
michael@0 208 res/values/strings.xml: FORCE
michael@0 209 $(MAKE) -C locales
michael@0 210
michael@0 211 all_resources = \
michael@0 212 $(CURDIR)/AndroidManifest.xml \
michael@0 213 $(CURDIR)/WebappManifestFragment.xml.frag \
michael@0 214 $(android_res_files) \
michael@0 215 $(ANDROID_GENERATED_RESFILES) \
michael@0 216 $(NULL)
michael@0 217
michael@0 218 # For GeckoView, we want a zip of an Android res/ directory that
michael@0 219 # merges the contents of all the ANDROID_RES_DIRS. The inner res/
michael@0 220 # directory must have the Android resource two-layer hierarchy.
michael@0 221
michael@0 222 # The following helper zips files in a directory into a zip file while
michael@0 223 # maintaining the directory structure rooted below the directory.
michael@0 224 # (adding or creating said file as appropriate). For example, if the
michael@0 225 # dir contains dir/subdir/file, calling with directory dir would
michael@0 226 # create a zip containing subdir/file. Note: the trailing newline is
michael@0 227 # necessary.
michael@0 228
michael@0 229 # $(1): zip file to add to (or create).
michael@0 230 # $(2): directory to zip contents of.
michael@0 231 define zip_directory_with_relative_paths
michael@0 232 cd $(2) && zip -q $(1) -r * -x $(not_android_res_files)
michael@0 233
michael@0 234 endef
michael@0 235
michael@0 236 geckoview_resources.zip: $(all_resources) $(GLOBAL_DEPS)
michael@0 237 $(foreach dir,$(ANDROID_RES_DIRS),$(call zip_directory_with_relative_paths,$(CURDIR)/$@,$(dir)))
michael@0 238
michael@0 239 # All of generated/org/mozilla/gecko/R.java, gecko.ap_, and R.txt are
michael@0 240 # produced by aapt; this saves aapt invocations. The trailing
michael@0 241 # semi-colon defines an empty recipe; defining no recipe at all causes
michael@0 242 # Make to treat the target differently, in a way that defeats our
michael@0 243 # dependencies.
michael@0 244
michael@0 245 $(gecko_package_dir)/R.java: .aapt.deps ;
michael@0 246 gecko.ap_: .aapt.deps ;
michael@0 247 R.txt: .aapt.deps ;
michael@0 248
michael@0 249 # [Comment 2/3] This tom-foolery provides a target that forces a
michael@0 250 # rebuild of gecko.ap_. This is used during packaging to ensure that
michael@0 251 # resources are fresh. The alternative would be complicated; see
michael@0 252 # [Comment 1/3].
michael@0 253
michael@0 254 gecko-nodeps/R.java: .aapt.nodeps ;
michael@0 255 gecko-nodeps.ap_: .aapt.nodeps ;
michael@0 256 gecko-nodeps/R.txt: .aapt.nodeps ;
michael@0 257
michael@0 258 # This ignores the default set of resources ignored by aapt, plus
michael@0 259 # files starting with '#'. (Emacs produces temp files named #temp#.)
michael@0 260 # This doesn't actually set the environment variable; it's used as a
michael@0 261 # parameter in the aapt invocation below. Consider updating
michael@0 262 # not_android_res_files as well.
michael@0 263
michael@0 264 ANDROID_AAPT_IGNORE := !.svn:!.git:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~:\#*:*.rej:*.orig
michael@0 265
michael@0 266 # 1: target file.
michael@0 267 # 2: dependencies.
michael@0 268 # 3: name of ap_ file to write.
michael@0 269 # 4: directory to write R.java into.
michael@0 270 # 5: directory to write R.txt into.
michael@0 271 # We touch the target file before invoking aapt so that aapt's outputs
michael@0 272 # are fresher than the target, preventing a subsequent invocation from
michael@0 273 # thinking aapt's outputs are stale. This is safe because Make
michael@0 274 # removes the target file if any recipe command fails.
michael@0 275 define aapt_command
michael@0 276 $(1): $$(call mkdir_deps,$(filter-out ./,$(dir $(3) $(4) $(5)))) $(2)
michael@0 277 @$$(TOUCH) $$@
michael@0 278 $$(AAPT) package -f -M AndroidManifest.xml -I $$(ANDROID_SDK)/android.jar \
michael@0 279 --auto-add-overlay \
michael@0 280 $$(addprefix -S ,$$(ANDROID_RES_DIRS)) \
michael@0 281 --custom-package org.mozilla.gecko --non-constant-id \
michael@0 282 -F $(3) \
michael@0 283 -J $(4) \
michael@0 284 --output-text-symbols $(5) \
michael@0 285 --ignore-assets "$$(ANDROID_AAPT_IGNORE)"
michael@0 286 endef
michael@0 287
michael@0 288 # [Comment 3/3] The first of these rules is used during regular
michael@0 289 # builds. The second writes an ap_ file that is only used during
michael@0 290 # packaging. It doesn't write the normal ap_, or R.java, since we
michael@0 291 # don't want the packaging step to write anything that would make a
michael@0 292 # further no-op build do work. See also
michael@0 293 # toolkit/mozapps/installer/packager.mk.
michael@0 294
michael@0 295 # .aapt.deps: $(all_resources)
michael@0 296 $(eval $(call aapt_command,.aapt.deps,$(all_resources),gecko.ap_,$(gecko_package_dir)/,./))
michael@0 297
michael@0 298 # .aapt.nodeps: $(CURDIR)/AndroidManifest.xml FORCE
michael@0 299 $(eval $(call aapt_command,.aapt.nodeps,$(CURDIR)/AndroidManifest.xml FORCE,gecko-nodeps.ap_,gecko-nodeps/,gecko-nodeps/))
michael@0 300
michael@0 301 fennec_ids.txt: $(gecko_package_dir)/R.java fennec-ids-generator.py
michael@0 302 $(PYTHON) $(topsrcdir)/mobile/android/base/fennec-ids-generator.py -i $< -o $@
michael@0 303
michael@0 304 # Override the Java settings with some specific android settings
michael@0 305 include $(topsrcdir)/config/android-common.mk
michael@0 306
michael@0 307 libs:: geckoview_resources.zip classes.dex jni-stubs.inc GeneratedJNIWrappers.cpp fennec_ids.txt
michael@0 308 $(INSTALL) geckoview_resources.zip $(FINAL_TARGET)
michael@0 309 $(INSTALL) classes.dex $(FINAL_TARGET)
michael@0 310 @(diff jni-stubs.inc $(topsrcdir)/mozglue/android/jni-stubs.inc >/dev/null && diff GeneratedJNIWrappers.cpp $(topsrcdir)/widget/android/GeneratedJNIWrappers.cpp >/dev/null) || \
michael@0 311 (echo '*****************************************************' && \
michael@0 312 echo '*** Error: The generated JNI code has changed ***' && \
michael@0 313 echo '* To update generated code in the tree, please run *' && \
michael@0 314 echo && \
michael@0 315 echo ' cp $(CURDIR)/jni-stubs.inc $(topsrcdir)/mozglue/android && cp $(CURDIR)/GeneratedJNIWrappers.* $(topsrcdir)/widget/android' && \
michael@0 316 echo && \
michael@0 317 echo '* Repeat the build, and check in any changes. *' && \
michael@0 318 echo '*****************************************************' && \
michael@0 319 exit 1)

mercurial