Bug 1413362 - part 3: Add support to build system for GoogleVR based WebVR on Android r=froydnj,nalexander draft
authorRandall Barker <rbarker@mozilla.com>
Thu, 02 Nov 2017 17:16:11 -0700
changeset 693026 c7da5c36058c5c54938a7920903d9e96425be2b6
parent 693025 11ffa2271383d63b367ebf734fc3117d8535999d
child 738919 1227a986e4f96e45ad37448364d2ffe673804683
push id87675
push userbmo:rbarker@mozilla.com
push dateFri, 03 Nov 2017 21:24:57 +0000
reviewersfroydnj, nalexander
bugs1413362
milestone58.0a1
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,48 @@ 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
+    arch = 'unknown'
+    if 'arm' in target.cpu:
+        arch = 'armeabi-v7a'
+    elif 'aarch64' in target.cpu:
+        arch = 'arm64-v8a'
+    elif 'x86' in 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
@@ -67,16 +67,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']