diff --git a/build/autoconf/android.m4 b/build/autoconf/android.m4 index 9f83eb7b9a7..e78dc38a4b3 100644 --- a/build/autoconf/android.m4 +++ b/build/autoconf/android.m4 @@ -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 Arg 1: target SDK version, like 22. dnl Arg 2: build tools version, like 22.0.1. diff --git a/configure.in b/configure.in index c93baa6586f..d8ce5bad744 100644 --- a/configure.in +++ b/configure.in @@ -4589,6 +4589,7 @@ dnl values set by configure.sh above. dnl ======================================================== MOZ_ANDROID_GOOGLE_PLAY_SERVICES +MOZ_ANDROID_GOOGLE_CLOUD_MESSAGING dnl ======================================================== diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index a4920daa6f3..ee68d962c8f 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -74,6 +74,14 @@ ifdef MOZ_NATIVE_DEVICES $(NULL) 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))) # Library jars that we're bundling: these are subject to Proguard before inclusion @@ -96,6 +104,18 @@ ifdef MOZ_NATIVE_DEVICES $(NULL) 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))) # 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/base/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 ; R.txt: .aapt.deps ; diff --git a/mobile/android/base/moz.build b/mobile/android/base/moz.build index de595b93ab6..92976d0ef8b 100644 --- a/mobile/android/base/moz.build +++ b/mobile/android/base/moz.build @@ -690,6 +690,28 @@ if CONFIG['MOZ_NATIVE_DEVICES']: ANDROID_EXTRA_RES_DIRS += ['%' + CONFIG['ANDROID_PLAY_SERVICES_CAST_AAR_RES']] 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_DESIGN_AAR_LIB']] gbjar.extra_jars += [CONFIG['ANDROID_RECYCLERVIEW_V7_AAR_LIB']] diff --git a/mobile/android/gradle/base/build.gradle b/mobile/android/gradle/base/build.gradle index 5bc3cb1d1f4..2f5c19c1144 100644 --- a/mobile/android/gradle/base/build.gradle +++ b/mobile/android/gradle/base/build.gradle @@ -105,6 +105,12 @@ dependencies { 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') testCompile 'junit:junit:4.12' diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index 33f7de6c58e..db1755365af 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -605,19 +605,23 @@ class RecursiveMakeBackend(CommonBackend): backend_file.write('DIST_FILES += %s\n' % f) elif isinstance(obj, AndroidResDirs): + # Order matters. for p in obj.paths: backend_file.write('ANDROID_RES_DIRS += %s\n' % p.full_path) elif isinstance(obj, AndroidAssetsDirs): + # Order matters. for p in obj.paths: backend_file.write('ANDROID_ASSETS_DIRS += %s\n' % p.full_path) elif isinstance(obj, AndroidExtraResDirs): - for p in obj.paths: - backend_file.write('ANDROID_EXTRA_RES_DIRS += %s\n' % p.full_path) + # Order does not matter. + 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): - 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) else: @@ -1248,7 +1252,7 @@ INSTALL_TARGETS += %(prefix)s (target, ' '.join(mozpath.join('generated', f) for f in jar.generated_sources))) if jar.extra_jars: backend_file.write('%s_EXTRA_JARS := %s\n' % - (target, ' '.join(jar.extra_jars))) + (target, ' '.join(sorted(set(jar.extra_jars))))) if jar.javac_flags: backend_file.write('%s_JAVAC_FLAGS := %s\n' % (target, ' '.join(jar.javac_flags)))