2013-01-26 00:22:13 +04:00
|
|
|
# -*- makefile -*-
|
|
|
|
# vim:set ts=8 sw=8 sts=8 noet:
|
|
|
|
#
|
|
|
|
# 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/.
|
|
|
|
|
|
|
|
ifndef INCLUDED_JAVA_BUILD_MK #{
|
|
|
|
|
|
|
|
ifdef JAVAFILES #{
|
|
|
|
GENERATED_DIRS += classes
|
2013-03-19 23:34:59 +04:00
|
|
|
|
|
|
|
export:: classes
|
|
|
|
classes: $(call mkdir_deps,classes)
|
2013-10-01 23:43:30 +04:00
|
|
|
endif #} JAVAFILES
|
|
|
|
|
|
|
|
|
|
|
|
ifdef ANDROID_APK_NAME #{
|
2013-12-12 09:20:07 +04:00
|
|
|
android_res_dirs := $(addprefix $(srcdir)/,$(or $(ANDROID_RES_DIRS),res))
|
|
|
|
_ANDROID_RES_FLAG := $(addprefix -S ,$(android_res_dirs))
|
2013-10-01 23:43:30 +04:00
|
|
|
_ANDROID_ASSETS_FLAG := $(addprefix -A ,$(ANDROID_ASSETS_DIR))
|
2014-02-25 11:18:47 +04:00
|
|
|
android_manifest := $(or $(ANDROID_MANIFEST_FILE),AndroidManifest.xml)
|
2013-10-01 23:43:30 +04:00
|
|
|
|
|
|
|
GENERATED_DIRS += classes
|
|
|
|
|
|
|
|
classes.dex: $(call mkdir_deps,classes)
|
|
|
|
classes.dex: R.java
|
|
|
|
classes.dex: $(ANDROID_APK_NAME).ap_
|
2014-02-25 06:24:45 +04:00
|
|
|
classes.dex: $(ANDROID_EXTRA_JARS)
|
2013-10-01 23:43:30 +04:00
|
|
|
classes.dex: $(JAVAFILES)
|
2014-02-25 06:24:45 +04:00
|
|
|
$(JAVAC) $(JAVAC_FLAGS) -d classes $(filter %.java,$^) \
|
|
|
|
$(if $(strip $(ANDROID_EXTRA_JARS)),-classpath $(subst $(NULL) ,:,$(strip $(ANDROID_EXTRA_JARS))))
|
2013-10-01 23:43:30 +04:00
|
|
|
$(DX) --dex --output=$@ classes $(ANDROID_EXTRA_JARS)
|
|
|
|
|
|
|
|
# R.java and $(ANDROID_APK_NAME).ap_ are both produced by aapt. To
|
Bug 979388 - Make aapt invocation rebuild R.java. r=glandium
This commit adds an empty recipe to dependencies of .aapt.deps, which
forces the appropriate gecko-R.jar rebuild. This is because Make treats
targets with no recipe at all differently than targets with an empty
recipe, in a way that defeats our dependencies.
What appeared to be happening is the following:
Touch a resource. On the next build, .aapt.deps is stale, so aapt is
invoked, which generates R.java, and we touch .aapt.deps.
Now R.java depends on .aapt.deps, but this does not appear to force Make
to consider targets that depend on R.java to be stale. A target that
depends on R.java (such as gecko-R.jar) itself compares timestamps and
finds that gecko-R.jar is newer than R.java (from the previous build),
and this comparison appears to happen before aapt is invoked. So even
though .aapt.deps is seen to be stale, and by transitivity R.java is
stale, this does not mark gecko-R.jar as stale. The timestamp check
between R.java and gecko-R.jar appears to happen *before* aapt is
invoked.
On the second build following the update, the R.java generated in the
previous build is newer than gecko-R.jar, triggering the observed
rebuild of gecko-R.jar.
2014-03-13 04:22:27 +04:00
|
|
|
# save an aapt invocation, we produce them both at the same time. The
|
|
|
|
# trailing semi-colon defines an empty recipe; defining no recipe at
|
|
|
|
# all causes Make to treat the target differently, in a way that
|
|
|
|
# defeats our dependencies.
|
2013-10-01 23:43:30 +04:00
|
|
|
|
Bug 979388 - Make aapt invocation rebuild R.java. r=glandium
This commit adds an empty recipe to dependencies of .aapt.deps, which
forces the appropriate gecko-R.jar rebuild. This is because Make treats
targets with no recipe at all differently than targets with an empty
recipe, in a way that defeats our dependencies.
What appeared to be happening is the following:
Touch a resource. On the next build, .aapt.deps is stale, so aapt is
invoked, which generates R.java, and we touch .aapt.deps.
Now R.java depends on .aapt.deps, but this does not appear to force Make
to consider targets that depend on R.java to be stale. A target that
depends on R.java (such as gecko-R.jar) itself compares timestamps and
finds that gecko-R.jar is newer than R.java (from the previous build),
and this comparison appears to happen before aapt is invoked. So even
though .aapt.deps is seen to be stale, and by transitivity R.java is
stale, this does not mark gecko-R.jar as stale. The timestamp check
between R.java and gecko-R.jar appears to happen *before* aapt is
invoked.
On the second build following the update, the R.java generated in the
previous build is newer than gecko-R.jar, triggering the observed
rebuild of gecko-R.jar.
2014-03-13 04:22:27 +04:00
|
|
|
R.java: .aapt.deps ;
|
|
|
|
$(ANDROID_APK_NAME).ap_: .aapt.deps ;
|
2013-10-01 23:43:30 +04:00
|
|
|
|
2013-12-12 09:20:07 +04:00
|
|
|
# This uses the fact that Android resource directories list all
|
|
|
|
# resource files one subdirectory below the parent resource directory.
|
|
|
|
android_res_files := $(wildcard $(addsuffix /*,$(wildcard $(addsuffix /*,$(android_res_dirs)))))
|
|
|
|
|
2014-02-25 11:18:47 +04:00
|
|
|
.aapt.deps: $(android_manifest) $(android_res_files) $(wildcard $(ANDROID_ASSETS_DIR))
|
Bug 979388 - Make aapt invocation rebuild R.java. r=glandium
This commit adds an empty recipe to dependencies of .aapt.deps, which
forces the appropriate gecko-R.jar rebuild. This is because Make treats
targets with no recipe at all differently than targets with an empty
recipe, in a way that defeats our dependencies.
What appeared to be happening is the following:
Touch a resource. On the next build, .aapt.deps is stale, so aapt is
invoked, which generates R.java, and we touch .aapt.deps.
Now R.java depends on .aapt.deps, but this does not appear to force Make
to consider targets that depend on R.java to be stale. A target that
depends on R.java (such as gecko-R.jar) itself compares timestamps and
finds that gecko-R.jar is newer than R.java (from the previous build),
and this comparison appears to happen before aapt is invoked. So even
though .aapt.deps is seen to be stale, and by transitivity R.java is
stale, this does not mark gecko-R.jar as stale. The timestamp check
between R.java and gecko-R.jar appears to happen *before* aapt is
invoked.
On the second build following the update, the R.java generated in the
previous build is newer than gecko-R.jar, triggering the observed
rebuild of gecko-R.jar.
2014-03-13 04:22:27 +04:00
|
|
|
@$(TOUCH) $@
|
2013-10-01 23:43:30 +04:00
|
|
|
$(AAPT) package -f -M $< -I $(ANDROID_SDK)/android.jar $(_ANDROID_RES_FLAG) $(_ANDROID_ASSETS_FLAG) \
|
|
|
|
-J ${@D} \
|
|
|
|
-F $(ANDROID_APK_NAME).ap_
|
|
|
|
|
|
|
|
$(ANDROID_APK_NAME)-unsigned-unaligned.apk: $(ANDROID_APK_NAME).ap_ classes.dex
|
|
|
|
cp $< $@
|
|
|
|
$(ZIP) -0 $@ classes.dex
|
|
|
|
|
|
|
|
$(ANDROID_APK_NAME)-unaligned.apk: $(ANDROID_APK_NAME)-unsigned-unaligned.apk
|
|
|
|
cp $< $@
|
|
|
|
$(DEBUG_JARSIGNER) $@
|
|
|
|
|
|
|
|
$(ANDROID_APK_NAME).apk: $(ANDROID_APK_NAME)-unaligned.apk
|
|
|
|
$(ZIPALIGN) -f -v 4 $< $@
|
|
|
|
|
|
|
|
GARBAGE += \
|
|
|
|
R.java \
|
|
|
|
classes.dex \
|
|
|
|
$(ANDROID_APK_NAME).ap_ \
|
|
|
|
$(ANDROID_APK_NAME)-unsigned-unaligned.apk \
|
|
|
|
$(ANDROID_APK_NAME)-unaligned.apk \
|
|
|
|
$(ANDROID_APK_NAME).apk \
|
|
|
|
$(NULL)
|
|
|
|
|
|
|
|
JAVA_CLASSPATH := $(ANDROID_SDK)/android.jar
|
|
|
|
|
|
|
|
# Include Android specific java flags, instead of what's in rules.mk.
|
|
|
|
include $(topsrcdir)/config/android-common.mk
|
|
|
|
endif #} ANDROID_APK_NAME
|
2013-01-26 00:22:13 +04:00
|
|
|
|
2013-10-10 04:05:36 +04:00
|
|
|
|
|
|
|
ifdef JAVA_JAR_TARGETS #{
|
|
|
|
# Arg 1: Output target name with .jar suffix, like jars/jarfile.jar.
|
|
|
|
# Intermediate class files are generated in jars/jarfile-classes.
|
|
|
|
# Arg 2: Java sources list. We use VPATH and $^ so sources can be
|
|
|
|
# relative to $(srcdir) or $(CURDIR).
|
|
|
|
# Arg 3: List of extra jars to link against. We do not use VPATH so
|
|
|
|
# jars must be relative to $(CURDIR).
|
|
|
|
# Arg 4: Additional JAVAC_FLAGS.
|
2014-02-11 21:55:47 +04:00
|
|
|
|
|
|
|
# Note: Proguard fails when stale .class files corresponding to
|
|
|
|
# removed inner classes are present in the object directory. These
|
|
|
|
# stale class files get packaged into the .jar file, which then gets
|
|
|
|
# processed by Proguard. To work around this, we always delete any
|
|
|
|
# existing jarfile-classes directory and start fresh.
|
|
|
|
|
2013-10-10 04:05:36 +04:00
|
|
|
define java_jar_template
|
|
|
|
$(1): $(2) $(3)
|
|
|
|
$$(REPORT_BUILD)
|
2014-02-11 21:55:47 +04:00
|
|
|
@$$(RM) -rf $(1:.jar=)-classes
|
2013-10-10 04:05:36 +04:00
|
|
|
@$$(NSINSTALL) -D $(1:.jar=)-classes
|
2013-10-10 04:14:20 +04:00
|
|
|
@$$(if $$(filter-out .,$$(@D)),$$(NSINSTALL) -D $$(@D))
|
2013-10-10 04:05:36 +04:00
|
|
|
$$(JAVAC) $$(JAVAC_FLAGS)\
|
|
|
|
$(4)\
|
|
|
|
-d $(1:.jar=)-classes\
|
|
|
|
$(if $(strip $(3)),-classpath $(subst $(NULL) ,:,$(strip $(3))))\
|
|
|
|
$$(filter %.java,$$^)
|
|
|
|
$$(JAR) cMf $$@ -C $(1:.jar=)-classes .
|
|
|
|
|
|
|
|
GARBAGE += $(1)
|
|
|
|
|
|
|
|
GARBAGE_DIRS += $(1:.jar=)-classes
|
|
|
|
endef
|
|
|
|
|
|
|
|
$(foreach jar,$(JAVA_JAR_TARGETS),\
|
|
|
|
$(if $($(jar)_DEST),,$(error Missing $(jar)_DEST))\
|
2014-03-05 20:57:09 +04:00
|
|
|
$(if $($(jar)_JAVAFILES) $($(jar)_PP_JAVAFILES),,$(error Must provide at least one of $(jar)_JAVAFILES and $(jar)_PP_JAVAFILES))\
|
2014-02-11 18:35:12 +04:00
|
|
|
$(eval $(call java_jar_template,$($(jar)_DEST),$($(jar)_JAVAFILES) $($(jar)_PP_JAVAFILES),$($(jar)_EXTRA_JARS),$($(jar)_JAVAC_FLAGS)))\
|
2013-10-10 04:05:36 +04:00
|
|
|
)
|
|
|
|
endif #} JAVA_JAR_TARGETS
|
|
|
|
|
|
|
|
|
2013-01-26 00:22:13 +04:00
|
|
|
INCLUDED_JAVA_BUILD_MK := 1
|
|
|
|
|
|
|
|
endif #} INCLUDED_JAVA_BUILD_MK
|