mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1119520 - Add opt-in Gradle build mode for mobile/android. r=gps
Opt-in by adding --enable-gradle-mobile-android-builds. Gradle dependencies (including the Android-Gradle plugin) are assumed to be present. Local developers will fetch them from the jcentral repository. Android-specific Maven dependencies are shipped as "extras" with the Android SDK, and should be found automatically by the Android-Gradle plugin. MozReview-Commit-ID: 966XgddWgEu --HG-- extra : rebase_source : 8e8c6156e1d06813c250662e104fd14c621d91ab extra : source : 306cf0271d3e3a344fcbfd2baf75e0450c288cf1 extra : histedit_source : d17446714236c408699a0953882e84ac3a192380%2Cc21b166af79ef1e00215748820bc2670405ac1dc
This commit is contained in:
parent
c4f4d0e3d9
commit
bc112329f3
24
configure.in
24
configure.in
@ -3758,6 +3758,7 @@ MOZ_SCTP=
|
||||
MOZ_ANDROID_OMX=
|
||||
MOZ_MEDIA_NAVIGATOR=
|
||||
MOZ_OMX_PLUGIN=
|
||||
MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE=
|
||||
MOZ_VPX_ERROR_CONCEALMENT=
|
||||
MOZ_WEBSPEECH=1
|
||||
MOZ_WEBSPEECH_MODELS=
|
||||
@ -5366,8 +5367,26 @@ if test -n "$MOZ_OMX_PLUGIN"; then
|
||||
dnl Only allow building OMX plugin on Gonk (B2G) or Android
|
||||
AC_DEFINE(MOZ_OMX_PLUGIN)
|
||||
else
|
||||
dnl fail if we're not building on Gonk or Android
|
||||
AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
|
||||
dnl fail if we're not building on Gonk or Android
|
||||
AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Enable building mobile/android with Gradle
|
||||
dnl ========================================================
|
||||
MOZ_ARG_ENABLE_BOOL(gradle-mobile-android-builds,
|
||||
[ --enable-gradle-mobile-android-builds Enable building mobile/android with Gradle],
|
||||
MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE=1,
|
||||
MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE=)
|
||||
|
||||
if test -n "$MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE"; then
|
||||
if test "$OS_TARGET" = "Android" -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
|
||||
dnl Only allow building mobile/android with Gradle.
|
||||
AC_DEFINE(MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE)
|
||||
else
|
||||
dnl fail if we're not building mobile/android.
|
||||
AC_MSG_ERROR([Can only build mobile/android with Gradle])
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -8900,6 +8919,7 @@ AC_SUBST(MOZ_DIRECTSHOW)
|
||||
AC_SUBST(MOZ_ANDROID_OMX)
|
||||
AC_SUBST(MOZ_APPLEMEDIA)
|
||||
AC_SUBST(MOZ_OMX_PLUGIN)
|
||||
AC_SUBST(MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE)
|
||||
AC_SUBST(MOZ_VPX_ERROR_CONCEALMENT)
|
||||
AC_SUBST(VPX_AS)
|
||||
AC_SUBST_LIST(VPX_ASFLAGS)
|
||||
|
@ -2,6 +2,12 @@
|
||||
# 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/.
|
||||
|
||||
# We call mach -> Make -> gradle -> mach, which races to find and
|
||||
# create .mozconfig files and to generate targets.
|
||||
ifdef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE
|
||||
.NOTPARALLEL:
|
||||
endif
|
||||
|
||||
MOZ_BUILDID := $(shell awk '{print $$3}' $(DEPTH)/buildid.h)
|
||||
|
||||
# Set the appropriate version code, based on the existance of the
|
||||
@ -201,9 +207,23 @@ endif # MOZ_INSTALL_TRACKING
|
||||
|
||||
library_jars := $(subst $(NULL) ,:,$(strip $(library_jars)))
|
||||
|
||||
gradle_dir := $(topobjdir)/gradle/build/mobile/android
|
||||
|
||||
ifdef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE
|
||||
.gradle.deps: .aapt.deps FORCE
|
||||
@$(TOUCH) $@
|
||||
$(topsrcdir)/mach gradle \
|
||||
$(if $(MOZILLA_OFFICIAL),--no-daemon --offline --info) \
|
||||
app:assembleAutomationDebug app:assembleAutomationDebugAndroidTest -x lint
|
||||
|
||||
classes.dex: .gradle.deps
|
||||
$(REPORT_BUILD)
|
||||
cp $(gradle_dir)/app/intermediates/transforms/dex/automation/debug/folders/1000/1f/main/classes.dex $@
|
||||
else
|
||||
classes.dex: .proguard.deps
|
||||
$(REPORT_BUILD)
|
||||
$(DX) --dex --output=classes.dex jars-proguarded
|
||||
endif
|
||||
|
||||
ifdef MOZ_DISABLE_PROGUARD
|
||||
PROGUARD_PASSES=0
|
||||
@ -501,8 +521,13 @@ endef
|
||||
# .aapt.deps: $(all_resources)
|
||||
$(eval $(call aapt_command,.aapt.deps,$(all_resources),gecko.ap_,generated/,./))
|
||||
|
||||
# .aapt.nodeps: $(abspath $(CURDIR)/AndroidManifest.xml) FORCE
|
||||
$(eval $(call aapt_command,.aapt.nodeps,$(abspath $(CURDIR)/AndroidManifest.xml) FORCE,gecko-nodeps.ap_,gecko-nodeps/,gecko-nodeps/))
|
||||
ifdef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE
|
||||
.aapt.nodeps: FORCE
|
||||
cp $(gradle_dir)/app/intermediates/res/resources-automation-debug.ap_ gecko-nodeps.ap_
|
||||
else
|
||||
# .aapt.nodeps: $(CURDIR)/AndroidManifest.xml FORCE
|
||||
$(eval $(call aapt_command,.aapt.nodeps,$(CURDIR)/AndroidManifest.xml FORCE,gecko-nodeps.ap_,gecko-nodeps/,gecko-nodeps/))
|
||||
endif
|
||||
|
||||
# Override the Java settings with some specific android settings
|
||||
include $(topsrcdir)/config/android-common.mk
|
||||
@ -532,7 +557,14 @@ gradle-targets: $(foreach f,$(constants_PP_JAVAFILES),$(f))
|
||||
gradle-targets: $(abspath AndroidManifest.xml)
|
||||
gradle-targets: $(ANDROID_GENERATED_RESFILES)
|
||||
|
||||
gradle-omnijar: $(ABS_DIST)/fennec/$(OMNIJAR_NAME)
|
||||
ifndef MOZILLA_OFFICIAL
|
||||
# Local developers update omni.ja during their builds. There's a
|
||||
# chicken-and-egg problem here.
|
||||
gradle-omnijar: $(abspath $(DIST)/fennec/$(OMNIJAR_NAME))
|
||||
else
|
||||
# In automation, omni.ja is built only during packaging.
|
||||
gradle-omnijar:
|
||||
endif
|
||||
|
||||
.PHONY: gradle-targets gradle-omnijar
|
||||
|
||||
@ -543,8 +575,8 @@ endif
|
||||
|
||||
# GeneratedJNIWrappers.cpp target also generates
|
||||
# GeneratedJNIWrappers.h and GeneratedJNINatives.h
|
||||
libs:: classes.dex jni-stubs.inc GeneratedJNIWrappers.cpp $(CURDIR)/fennec_ids.txt
|
||||
$(INSTALL) classes.dex $(FINAL_TARGET)
|
||||
ifndef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE
|
||||
libs:: jni-stubs.inc GeneratedJNIWrappers.cpp
|
||||
@(diff jni-stubs.inc $(topsrcdir)/mozglue/android/jni-stubs.inc >/dev/null && \
|
||||
diff GeneratedJNIWrappers.cpp $(topsrcdir)/widget/android/GeneratedJNIWrappers.cpp >/dev/null && \
|
||||
diff GeneratedJNIWrappers.h $(topsrcdir)/widget/android/GeneratedJNIWrappers.h >/dev/null && \
|
||||
@ -558,3 +590,9 @@ libs:: classes.dex jni-stubs.inc GeneratedJNIWrappers.cpp $(CURDIR)/fennec_ids.t
|
||||
echo '* Repeat the build, and check in any changes. *' && \
|
||||
echo '*****************************************************' && \
|
||||
exit 1)
|
||||
endif
|
||||
|
||||
libs:: $(CURDIR)/fennec_ids.txt
|
||||
|
||||
libs:: classes.dex
|
||||
$(INSTALL) classes.dex $(FINAL_TARGET)
|
||||
|
@ -21,16 +21,6 @@ from mach.decorators import (
|
||||
Command,
|
||||
)
|
||||
|
||||
SUCCESS = '''
|
||||
You should be ready to build with Gradle and import into IntelliJ! Test with
|
||||
|
||||
./mach gradle build
|
||||
|
||||
and in IntelliJ select File > Import project... and choose
|
||||
|
||||
{topobjdir}/mobile/android/gradle
|
||||
'''
|
||||
|
||||
|
||||
# NOTE python/mach/mach/commands/commandinfo.py references this function
|
||||
# by name. If this function is renamed or removed, that file should
|
||||
|
@ -29,8 +29,9 @@ DIRS += [
|
||||
if CONFIG['MOZ_ANDROID_PACKAGE_INSTALL_BOUNCER']:
|
||||
DIRS += ['bouncer'] # No ordering implied with respect to base.
|
||||
|
||||
TEST_DIRS += [
|
||||
'tests',
|
||||
]
|
||||
if not CONFIG['MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE']:
|
||||
TEST_DIRS += [
|
||||
'tests',
|
||||
]
|
||||
|
||||
SPHINX_TREES['fennec'] = 'docs'
|
||||
|
@ -107,7 +107,7 @@ class MozconfigLoader(ProcessExecutionMixin):
|
||||
if 'MOZ_MYCONFIG' in env:
|
||||
raise MozconfigFindException(MOZ_MYCONFIG_ERROR)
|
||||
|
||||
env_path = env.get('MOZCONFIG', None)
|
||||
env_path = env.get('MOZCONFIG', None) or None
|
||||
if env_path is not None:
|
||||
if not os.path.isabs(env_path):
|
||||
potential_roots = [self.topsrcdir, os.getcwd()]
|
||||
|
@ -14,10 +14,12 @@ include $(topsrcdir)/config/android-common.mk
|
||||
|
||||
stage-package:
|
||||
$(NSINSTALL) -D $(_DEST_DIR)
|
||||
ifndef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE
|
||||
$(call RELEASE_SIGN_ANDROID_APK,\
|
||||
$(DEPTH)/mobile/android/tests/background/junit3/background-junit3-debug-unsigned-unaligned.apk,\
|
||||
$(_DEST_DIR)/background-junit3.apk)
|
||||
$(call RELEASE_SIGN_ANDROID_APK,\
|
||||
$(DEPTH)/mobile/android/tests/browser/junit3/browser-junit3-debug-unsigned-unaligned.apk,\
|
||||
$(_DEST_DIR)/browser-junit3.apk)
|
||||
endif
|
||||
@(cd $(DEPTH)/_tests/ && tar $(TAR_CREATE_FLAGS) - instrumentation) | (cd $(PKG_STAGE) && tar -xf -)
|
||||
|
@ -107,11 +107,15 @@ $(_DEST_DIR):
|
||||
ifeq ($(MOZ_BUILD_APP),mobile/android)
|
||||
include $(topsrcdir)/config/android-common.mk
|
||||
|
||||
ifndef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE
|
||||
robocop_apk := $(topobjdir)/mobile/android/tests/browser/robocop/robocop-debug-unsigned-unaligned.apk
|
||||
else
|
||||
robocop_apk := $(topobjdir)/gradle/build/mobile/android/app/outputs/apk/app-automation-debug-androidTest-unaligned.apk
|
||||
endif
|
||||
|
||||
stage-package-android:
|
||||
$(NSINSTALL) -D $(_DEST_DIR)
|
||||
$(call RELEASE_SIGN_ANDROID_APK,\
|
||||
$(DEPTH)/mobile/android/tests/browser/robocop/robocop-debug-unsigned-unaligned.apk,\
|
||||
$(_DEST_DIR)/robocop.apk)
|
||||
$(call RELEASE_SIGN_ANDROID_APK,$(robocop_apk),$(_DEST_DIR)/robocop.apk)
|
||||
|
||||
stage-package: stage-package-android
|
||||
endif
|
||||
|
@ -325,13 +325,18 @@ UPLOAD_EXTRA_FILES += geckoview_library/geckoview_assets.zip
|
||||
# Robocop/Robotium tests, Android Background tests, and Fennec need to
|
||||
# be signed with the same key, which means release signing them all.
|
||||
|
||||
ROBOCOP_PATH = $(topobjdir)/mobile/android/tests/browser/robocop
|
||||
ifndef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE
|
||||
robocop_apk := $(topobjdir)/mobile/android/tests/browser/robocop/robocop-debug-unsigned-unaligned.apk
|
||||
else
|
||||
robocop_apk := $(topobjdir)/gradle/build/mobile/android/app/outputs/apk/app-automation-debug-androidTest-unaligned.apk
|
||||
endif
|
||||
|
||||
# Normally, $(NSINSTALL) would be used instead of cp, but INNER_ROBOCOP_PACKAGE
|
||||
# is used in a series of commands that run under a "cd something", while
|
||||
# $(NSINSTALL) is relative.
|
||||
INNER_ROBOCOP_PACKAGE= \
|
||||
cp $(GECKO_APP_AP_PATH)/fennec_ids.txt $(ABS_DIST) && \
|
||||
$(call RELEASE_SIGN_ANDROID_APK,$(ROBOCOP_PATH)/robocop-debug-unsigned-unaligned.apk,$(ABS_DIST)/robocop.apk)
|
||||
$(call RELEASE_SIGN_ANDROID_APK,$(robocop_apk),$(ABS_DIST)/robocop.apk)
|
||||
endif
|
||||
else
|
||||
INNER_ROBOCOP_PACKAGE=echo 'Testing is disabled - No Android Robocop for you'
|
||||
@ -470,6 +475,15 @@ PKG_SUFFIX = .apk
|
||||
INNER_SZIP_LIBRARIES = \
|
||||
$(if $(ALREADY_SZIPPED),,$(foreach lib,$(SZIP_LIBRARIES),host/bin/szip $(MOZ_SZIP_FLAGS) $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib) && )) true
|
||||
|
||||
ifdef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE
|
||||
INNER_CHECK_R_TXT=echo 'No R.txt checking for you!'
|
||||
else
|
||||
INNER_CHECK_R_TXT=\
|
||||
((test ! -f $(GECKO_APP_AP_PATH)/R.txt && echo "*** Warning: The R.txt that is being packaged might not agree with the R.txt that was built. This is normal during l10n repacks.") || \
|
||||
diff $(GECKO_APP_AP_PATH)/R.txt $(GECKO_APP_AP_PATH)/gecko-nodeps/R.txt >/dev/null || \
|
||||
(echo "*** Error: The R.txt that was built and the R.txt that is being packaged are not the same. Rebuild mobile/android/base and re-package." && exit 1))
|
||||
endif
|
||||
|
||||
# Insert $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/classes.dex into
|
||||
# $(ABS_DIST)/gecko.ap_, producing $(ABS_DIST)/gecko.apk.
|
||||
INNER_MAKE_APK = \
|
||||
@ -490,13 +504,11 @@ INNER_MAKE_APK = \
|
||||
$(ZIPALIGN) -f -v 4 $(ABS_DIST)/gecko.apk $(PACKAGE)
|
||||
|
||||
ifeq ($(MOZ_BUILD_APP),mobile/android)
|
||||
INNER_MAKE_PACKAGE = \
|
||||
INNER_MAKE_PACKAGE = \
|
||||
$(INNER_SZIP_LIBRARIES) && \
|
||||
make -C $(GECKO_APP_AP_PATH) gecko-nodeps.ap_ && \
|
||||
cp $(GECKO_APP_AP_PATH)/gecko-nodeps.ap_ $(ABS_DIST)/gecko.ap_ && \
|
||||
( (test ! -f $(GECKO_APP_AP_PATH)/R.txt && echo "*** Warning: The R.txt that is being packaged might not agree with the R.txt that was built. This is normal during l10n repacks.") || \
|
||||
diff $(GECKO_APP_AP_PATH)/R.txt $(GECKO_APP_AP_PATH)/gecko-nodeps/R.txt >/dev/null || \
|
||||
(echo "*** Error: The R.txt that was built and the R.txt that is being packaged are not the same. Rebuild mobile/android/base and re-package." && exit 1)) && \
|
||||
$(INNER_CHECK_R_TXT) && \
|
||||
$(INNER_MAKE_APK) && \
|
||||
$(INNER_ROBOCOP_PACKAGE) && \
|
||||
$(INNER_INSTALL_BOUNCER_PACKAGE) && \
|
||||
@ -505,7 +517,7 @@ INNER_MAKE_PACKAGE = \
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_BUILD_APP),mobile/android/b2gdroid)
|
||||
INNER_MAKE_PACKAGE = \
|
||||
INNER_MAKE_PACKAGE = \
|
||||
$(INNER_SZIP_LIBRARIES) && \
|
||||
cp $(topobjdir)/mobile/android/b2gdroid/app/classes.dex $(ABS_DIST)/classes.dex && \
|
||||
cp $(topobjdir)/mobile/android/b2gdroid/app/b2gdroid-unsigned-unaligned.apk $(ABS_DIST)/gecko.ap_ && \
|
||||
|
Loading…
Reference in New Issue
Block a user