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.

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

mercurial