Bug 1207708 - Part 2: Build against play-services-{basement,base,gcm} if MOZ_ANDROID_GCM. r=sebastian

Since MOZ_NATIVE_DEVICES builds against play-services-{basement,base,cast},
some ad-hoc de-duplication is necessary.
This commit is contained in:
Nick Alexander 2015-10-27 17:41:49 -07:00
parent 4e763c56da
commit 21e9816e85
6 changed files with 71 additions and 4 deletions

View File

@ -337,6 +337,19 @@ fi
]) ])
AC_DEFUN([MOZ_ANDROID_GOOGLE_CLOUD_MESSAGING],
[
if test -n "$MOZ_ANDROID_GCM" ; then
AC_SUBST(MOZ_ANDROID_GCM)
MOZ_ANDROID_AAR(play-services-base, 8.1.0, google, com/google/android/gms)
MOZ_ANDROID_AAR(play-services-basement, 8.1.0, google, com/google/android/gms)
MOZ_ANDROID_AAR(play-services-gcm, 8.1.0, google, com/google/android/gms)
fi
])
dnl Configure an Android SDK. dnl Configure an Android SDK.
dnl Arg 1: target SDK version, like 22. dnl Arg 1: target SDK version, like 22.
dnl Arg 2: build tools version, like 22.0.1. dnl Arg 2: build tools version, like 22.0.1.

View File

@ -4589,6 +4589,7 @@ dnl values set by configure.sh above.
dnl ======================================================== dnl ========================================================
MOZ_ANDROID_GOOGLE_PLAY_SERVICES MOZ_ANDROID_GOOGLE_PLAY_SERVICES
MOZ_ANDROID_GOOGLE_CLOUD_MESSAGING
dnl ======================================================== dnl ========================================================

View File

@ -74,6 +74,14 @@ ifdef MOZ_NATIVE_DEVICES
$(NULL) $(NULL)
endif endif
ifdef MOZ_ANDROID_GCM
JAVA_CLASSPATH += \
$(ANDROID_PLAY_SERVICES_BASE_AAR_LIB) \
$(ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB) \
$(ANDROID_PLAY_SERVICES_GCM_AAR_LIB) \
$(NULL)
endif
JAVA_CLASSPATH := $(subst $(NULL) ,:,$(strip $(JAVA_CLASSPATH))) JAVA_CLASSPATH := $(subst $(NULL) ,:,$(strip $(JAVA_CLASSPATH)))
# Library jars that we're bundling: these are subject to Proguard before inclusion # Library jars that we're bundling: these are subject to Proguard before inclusion
@ -96,6 +104,18 @@ ifdef MOZ_NATIVE_DEVICES
$(NULL) $(NULL)
endif endif
ifdef MOZ_ANDROID_GCM
java_bundled_libs += \
$(ANDROID_PLAY_SERVICES_BASE_AAR_LIB) \
$(ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB) \
$(ANDROID_PLAY_SERVICES_GCM_AAR_LIB) \
$(NULL)
endif
# uniq purloined from http://stackoverflow.com/a/16151140.
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
java_bundled_libs := $(call uniq,$(java_bundled_libs))
java_bundled_libs := $(subst $(NULL) ,:,$(strip $(java_bundled_libs))) java_bundled_libs := $(subst $(NULL) ,:,$(strip $(java_bundled_libs)))
# All the jars we're compiling from source. (not to be confused with # All the jars we're compiling from source. (not to be confused with
@ -371,6 +391,7 @@ generated/android/support/v7/recyclerview/R.java: .aapt.deps ;
generated/com/google/android/gms/R.java: .aapt.deps ; generated/com/google/android/gms/R.java: .aapt.deps ;
generated/com/google/android/gms/base/R.java: .aapt.deps ; generated/com/google/android/gms/base/R.java: .aapt.deps ;
generated/com/google/android/gms/cast/R.java: .aapt.deps ; generated/com/google/android/gms/cast/R.java: .aapt.deps ;
generated/com/google/android/gms/gcm/R.java: .aapt.deps ;
gecko.ap_: .aapt.deps ; gecko.ap_: .aapt.deps ;
R.txt: .aapt.deps ; R.txt: .aapt.deps ;

View File

@ -690,6 +690,28 @@ if CONFIG['MOZ_NATIVE_DEVICES']:
ANDROID_EXTRA_RES_DIRS += ['%' + CONFIG['ANDROID_PLAY_SERVICES_CAST_AAR_RES']] ANDROID_EXTRA_RES_DIRS += ['%' + CONFIG['ANDROID_PLAY_SERVICES_CAST_AAR_RES']]
resjar.generated_sources += ['com/google/android/gms/cast/R.java'] resjar.generated_sources += ['com/google/android/gms/cast/R.java']
if CONFIG['MOZ_ANDROID_GCM']:
gbjar.extra_jars += [
CONFIG['ANDROID_PLAY_SERVICES_BASE_AAR_LIB'],
CONFIG['ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB'],
CONFIG['ANDROID_PLAY_SERVICES_GCM_AAR_LIB'],
]
if CONFIG['ANDROID_PLAY_SERVICES_BASE_AAR']:
ANDROID_EXTRA_PACKAGES += ['com.google.android.gms']
ANDROID_EXTRA_RES_DIRS += ['%' + CONFIG['ANDROID_PLAY_SERVICES_BASE_AAR_RES']]
resjar.generated_sources += ['com/google/android/gms/R.java']
if CONFIG['ANDROID_PLAY_SERVICES_BASEMENT_AAR']:
ANDROID_EXTRA_PACKAGES += ['com.google.android.gms']
ANDROID_EXTRA_RES_DIRS += ['%' + CONFIG['ANDROID_PLAY_SERVICES_BASEMENT_AAR_RES']]
resjar.generated_sources += ['com/google/android/gms/R.java']
if CONFIG['ANDROID_PLAY_SERVICES_GCM_AAR']:
ANDROID_EXTRA_PACKAGES += ['com.google.android.gms.gcm']
ANDROID_EXTRA_RES_DIRS += ['%' + CONFIG['ANDROID_PLAY_SERVICES_GCM_AAR_RES']]
resjar.generated_sources += ['com/google/android/gms/gcm/R.java']
gbjar.extra_jars += [CONFIG['ANDROID_APPCOMPAT_V7_AAR_LIB']] gbjar.extra_jars += [CONFIG['ANDROID_APPCOMPAT_V7_AAR_LIB']]
gbjar.extra_jars += [CONFIG['ANDROID_DESIGN_AAR_LIB']] gbjar.extra_jars += [CONFIG['ANDROID_DESIGN_AAR_LIB']]
gbjar.extra_jars += [CONFIG['ANDROID_RECYCLERVIEW_V7_AAR_LIB']] gbjar.extra_jars += [CONFIG['ANDROID_RECYCLERVIEW_V7_AAR_LIB']]

View File

@ -105,6 +105,12 @@ dependencies {
compile 'com.google.android.gms:play-services-cast:8.1.0' compile 'com.google.android.gms:play-services-cast:8.1.0'
} }
if (mozconfig.substs.MOZ_ANDROID_GCM) {
compile 'com.google.android.gms:play-services-basement:8.1.0'
compile 'com.google.android.gms:play-services-base:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
}
compile project(':thirdparty') compile project(':thirdparty')
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'

View File

@ -605,19 +605,23 @@ class RecursiveMakeBackend(CommonBackend):
backend_file.write('DIST_FILES += %s\n' % f) backend_file.write('DIST_FILES += %s\n' % f)
elif isinstance(obj, AndroidResDirs): elif isinstance(obj, AndroidResDirs):
# Order matters.
for p in obj.paths: for p in obj.paths:
backend_file.write('ANDROID_RES_DIRS += %s\n' % p.full_path) backend_file.write('ANDROID_RES_DIRS += %s\n' % p.full_path)
elif isinstance(obj, AndroidAssetsDirs): elif isinstance(obj, AndroidAssetsDirs):
# Order matters.
for p in obj.paths: for p in obj.paths:
backend_file.write('ANDROID_ASSETS_DIRS += %s\n' % p.full_path) backend_file.write('ANDROID_ASSETS_DIRS += %s\n' % p.full_path)
elif isinstance(obj, AndroidExtraResDirs): elif isinstance(obj, AndroidExtraResDirs):
for p in obj.paths: # Order does not matter.
backend_file.write('ANDROID_EXTRA_RES_DIRS += %s\n' % p.full_path) for p in sorted(set(p.full_path for p in obj.paths)):
backend_file.write('ANDROID_EXTRA_RES_DIRS += %s\n' % p)
elif isinstance(obj, AndroidExtraPackages): elif isinstance(obj, AndroidExtraPackages):
for p in obj.packages: # Order does not matter.
for p in sorted(set(obj.packages)):
backend_file.write('ANDROID_EXTRA_PACKAGES += %s\n' % p) backend_file.write('ANDROID_EXTRA_PACKAGES += %s\n' % p)
else: else:
@ -1248,7 +1252,7 @@ INSTALL_TARGETS += %(prefix)s
(target, ' '.join(mozpath.join('generated', f) for f in jar.generated_sources))) (target, ' '.join(mozpath.join('generated', f) for f in jar.generated_sources)))
if jar.extra_jars: if jar.extra_jars:
backend_file.write('%s_EXTRA_JARS := %s\n' % backend_file.write('%s_EXTRA_JARS := %s\n' %
(target, ' '.join(jar.extra_jars))) (target, ' '.join(sorted(set(jar.extra_jars)))))
if jar.javac_flags: if jar.javac_flags:
backend_file.write('%s_JAVAC_FLAGS := %s\n' % backend_file.write('%s_JAVAC_FLAGS := %s\n' %
(target, ' '.join(jar.javac_flags))) (target, ' '.join(jar.javac_flags)))