Bug 1413362 - part 3: Add support to build system for GoogleVR based WebVR on Android r=froydnj,nalexander
☠☠ backed out by 0b32504fcef2 ☠ ☠
authorRandall Barker <rbarker@mozilla.com>
Thu, 02 Nov 2017 17:16:11 -0700
changeset 390424 8b15dfaeecaa4cc729c180fe0d09de97b8228633
parent 390423 2d9da0d19d04c54d04f87f8ca5d13cc81f3ba048
child 390425 92427a65f57e1f621e85ca00b28a1040c205f802
push id97042
push userrbarker@mozilla.com
push dateTue, 07 Nov 2017 01:43:38 +0000
treeherdermozilla-inbound@8b15dfaeecaa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, nalexander
bugs1413362
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1413362 - part 3: Add support to build system for GoogleVR based WebVR on Android r=froydnj,nalexander MozReview-Commit-ID: 8BHBnvor5VT
build/moz.configure/android-ndk.configure
mobile/android/app/moz.build
mobile/android/installer/package-manifest.in
toolkit/library/moz.build
--- a/build/moz.configure/android-ndk.configure
+++ b/build/moz.configure/android-ndk.configure
@@ -6,16 +6,19 @@
 
 
 js_option('--with-android-ndk', nargs=1,
           help='location where the Android NDK can be found')
 
 js_option('--with-android-toolchain', nargs=1,
           help='location of the Android toolchain')
 
+option('--with-android-googlevr-sdk', nargs=1,
+       help='location of the Android GoogleVR SDK')
+
 
 @depends(target)
 def min_android_version(target):
     if target.cpu in ['aarch64', 'x86_64', 'mips64']:
         # 64-bit support was added in API 21.
         return '21'
     return '9'
 
@@ -295,8 +298,50 @@ def android_clang_compiler(host, ndk):
     if not isdir(llvm_path):
         die("Couldn't find path to LLVM toolchain at %s" % llvm_path)
 
     clang = '%s/clang' % llvm_path
     if not exists(clang):
         die("Couln't find clang in LLVM toolchain at %s" % clang)
 
     return clang
+
+
+@depends('--with-android-googlevr-sdk', target)
+@checking('for GoogleVR SDK', lambda x: x.result)
+@imports(_from='os.path', _import='exists')
+@imports(_from='os.path', _import='abspath')
+def googlevr_sdk(value, target):
+    if not value:
+        return namespace(
+            result='Not specified'
+        )
+    path = abspath(value[0])
+    if not exists(path):
+        die('Could not find GoogleVR SDK %s', path)
+    include = '%s/libraries/headers/' % path
+    if 'arm' == target.cpu:
+        arch = 'armeabi-v7a'
+    elif 'aarch64' == target.cpu:
+        arch = 'arm64-v8a'
+    elif 'x86' == target.cpu:
+        arch = 'x86'
+    else:
+        die('Unsupported GoogleVR cpu architecture %s' % target.cpu)
+
+    libs = '{0}/libraries/jni/{1}/'.format(path, arch)
+
+    if not exists(libs):
+        die('Could not find GoogleVR NDK at %s. Did you try running '
+            '\'./gradlew :extractNdk\' in %s?', libs, path)
+
+    return namespace(
+        result=path,
+        include=include,
+        libs=libs,
+        enabled=True,
+    )
+
+
+set_define('MOZ_ANDROID_GOOGLE_VR', googlevr_sdk.enabled)
+set_config('MOZ_ANDROID_GOOGLE_VR', googlevr_sdk.enabled)
+set_config('MOZ_ANDROID_GOOGLE_VR_INCLUDE', googlevr_sdk.include)
+set_config('MOZ_ANDROID_GOOGLE_VR_LIBS', googlevr_sdk.libs)
--- a/mobile/android/app/moz.build
+++ b/mobile/android/app/moz.build
@@ -50,8 +50,13 @@ if CONFIG['MOZ_PKG_SPECIAL']:
 
 JS_PREFERENCE_PP_FILES += [
      'mobile.js',
 ]
 
 FINAL_TARGET_PP_FILES += [
   'ua-update.json.in',
 ]
+
+if CONFIG['MOZ_ANDROID_GOOGLE_VR']:
+    FINAL_TARGET_FILES += [
+        '/' + CONFIG['MOZ_ANDROID_GOOGLE_VR_LIBS'] + 'libgvr.so',
+    ]
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -71,16 +71,20 @@
 #endif
 
 [lib destdir="lib/@ANDROID_CPU_ARCH@"]
 @BINPATH@/@DLL_PREFIX@mozglue@DLL_SUFFIX@
 # This should be MOZ_CHILD_PROCESS_NAME, but that has a "lib/" prefix.
 @BINPATH@/@MOZ_CHILD_PROCESS_NAME@
 @BINPATH@/@MOZ_CHILD_PROCESS_NAME_PIE@
 
+#ifdef MOZ_ANDROID_GOOGLE_VR
+@BINPATH@/@DLL_PREFIX@gvr@DLL_SUFFIX@
+#endif
+
 [xpcom]
 @BINPATH@/package-name.txt
 @BINPATH@/classes.dex
 
 [browser]
 ; [Base Browser Files]
 @BINPATH@/application.ini
 @BINPATH@/platform.ini
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -205,16 +205,22 @@ if CONFIG['OS_ARCH'] == 'WINNT':
         'winspool',
     ]
 
 if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android':
     OS_LIBS += [
         'rt',
     ]
 
+if CONFIG['MOZ_ANDROID_GOOGLE_VR']:
+    OS_LIBS += [
+        '-L%s' % CONFIG['MOZ_ANDROID_GOOGLE_VR_LIBS'],
+        '-lgvr',
+    ]
+
 OS_LIBS += CONFIG['MOZ_CAIRO_OSLIBS']
 OS_LIBS += CONFIG['MOZ_WEBRTC_X11_LIBS']
 
 if CONFIG['SERVO_TARGET_DIR']:
     if CONFIG['_MSC_VER']:
         OS_LIBS += ['%s/geckoservo' % CONFIG['SERVO_TARGET_DIR']]
     else:
         OS_LIBS += ['-L%s' % CONFIG['SERVO_TARGET_DIR'], '-lgeckoservo']