Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Added support for emu x86 (#567)
Browse files Browse the repository at this point in the history
* Support for x86 emulator

* Fixed MacOS issue with abis

* Fix version code error
  • Loading branch information
keianhzo authored and bluemarvin committed Sep 28, 2018
1 parent 2b8f04b commit 82a2d0b
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 37 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ Make certain to set the build flavor to `wavevrDebug` in Android Studio before b

## Using a custom GeckoView

Create a file called `user.properties` in the top-level project directory. Add a variable called `geckoViewLocal` and set it to the location of your locally built AAR:
Create a file called `user.properties` in the top-level project directory. Add a variable called `geckoViewLocalArm` and `geckoViewLocalX86` and set it to the location of your locally built AAR:

```ini
geckoViewLocal=/path/to/your/build/obj-arm-linux-androideabi/gradle/build/mobile/android/geckoview/outputs/aar/geckoview-local-withGeckoBinaries-noMinApi-debug.aar
geckoViewLocalArm=/path/to/your/build/geckoview-nightly-armeabi-v7a-64.0.20180924100359.aar
geckoViewLocalX86=/path/to/your/build/geckoview-nightly-x86-64.0.20180924100359.aar
```

## Debugging tips
Expand Down
87 changes: 61 additions & 26 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ android {
versionName "1.0.1"
buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a"
}
externalNativeBuild {
cmake {
cppFlags "-std=c++14 -fexceptions -frtti -Werror" +
Expand All @@ -34,6 +31,7 @@ android {
}
if (gradle.hasProperty('taskclusterBuild')) {
project.archivesBaseName = "FirefoxReality-$defaultConfig.versionName-$generatedVersionCode"
defaultConfig.versionCode = generatedVersionCode
} else {
project.archivesBaseName = "FirefoxReality"
}
Expand All @@ -53,11 +51,12 @@ android {
pickFirst '/lib/*/libgvr.so'
}

flavorDimensions "platform", "abi"

productFlavors {
// Supported platforms
googlevr {
//ndk {
// abiFilters "arm64-v8a"
//}
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -I" + file("${project.rootDir}/gvr-android-sdk/libraries/headers").absolutePath +
Expand All @@ -68,9 +67,7 @@ android {
}

googlevrFlat {
//ndk {
// abiFilters "arm64-v8a"
//}
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -I" + file("${project.rootDir}/gvr-android-sdk/libraries/headers").absolutePath +
Expand All @@ -81,9 +78,7 @@ android {
}

oculusvr {
//ndk {
// abiFilters "arm64-v8a"
//}
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -I" + file("${project.rootDir}/third_party/ovr_mobile/VrApi/Include").absolutePath +
Expand All @@ -94,6 +89,7 @@ android {
}
}
svr {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -I" + file("${project.rootDir}/third_party/svr/public").absolutePath +
Expand All @@ -104,6 +100,7 @@ android {
}
}
wavevr {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -I" + file("${project.rootDir}/third_party/wavesdk/build/wvr_client/include").absolutePath
Expand All @@ -112,19 +109,49 @@ android {
}
}
noapi {
//ndk {
// abiFilters "arm64-v8a"
//}
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -DVRBROWSER_NO_VR_API"
arguments "-DNOAPI=ON"
}
}
}

// Supported ABIs
arm {
dimension "abi"
ndk {
abiFilters "armeabi-v7a"
}
}

x86 {
dimension "abi"
ndk {
abiFilters "x86"
}
}
}

variantFilter { variant ->
def needed = variant.name in [
'googlevrArmDebug',
'googlevrArmRelease',
'oculusvrArmDebug',
'oculusvrArmRelease',
'svrArmDebug',
'svrArmRelease',
'wavevrArmDebug',
'wavevrArmRelease',
'noapiArmDebug',
'noapiArmRelease',
'noapiX86Debug',
'noapiX86Release'
]
variant.setIgnore(!needed)
}

flavorDimensions "default"

sourceSets {
main {
Expand Down Expand Up @@ -179,6 +206,11 @@ android {
}
}

configurations {
armImplementation
x86Implementation
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
Expand Down Expand Up @@ -209,7 +241,9 @@ if (findProject(':geckoview-local')) {
dependencies {
// To see what the latest geckoview-nightly version is go here:
// https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/geckoview-nightly-armeabi-v7a/
implementation 'org.mozilla.geckoview:geckoview-nightly-armeabi-v7a:64.0.20180914100149'

armImplementation "org.mozilla.geckoview:geckoview-nightly-armeabi-v7a:${rootProject.ext.geckoNightly['version']}"
x86Implementation "org.mozilla.geckoview:geckoview-nightly-x86:${rootProject.ext.geckoNightly['version']}"
}
}

Expand All @@ -219,6 +253,7 @@ if (findProject(':geckoview-local')) {
// -------------------------------------------------------------------------------------------------

android.applicationVariants.all { variant ->
def buildType = variant.buildType.name
if (gradle.hasProperty('taskclusterBuild')) {
def versionCode = generatedVersionCode

Expand All @@ -232,16 +267,16 @@ android.applicationVariants.all { variant ->
def multiplier = 100000000

// Currently only support arm7
//if (variant.flavorName.contains("X86")) {
// versionCode = versionCode + (3 * multiplier)
//} else if (variant.flavorName.contains("Aarch64")) {
// versionCode = versionCode + (2 * multiplier)
//} else if (variant.flavorName.contains("Arm")) {
if (variant.flavorName.contains("X86")) {
versionCode = versionCode + (3 * multiplier)
} else if (variant.flavorName.contains("Aarch64")) {
versionCode = versionCode + (2 * multiplier)
} else if (variant.flavorName.contains("Arm")) {
versionCode = versionCode + (1 * multiplier)
//}
variant.mergedFlavor.versionCode = versionCode
variant.outputs.all { output ->
output.setVersionCodeOverride(versionCode)
}

variant.outputs.each { output ->
output.versionCodeOverride = versionCode
}
}

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
android:name=".VRBrowserActivity"
android:launchMode="singleInstance"
android:configChanges="density|keyboardHidden|navigation|orientation|screenSize|uiMode"
android:windowSoftInputMode="stateAlwaysHidden"
>
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
Expand Down
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
// Gecko pinned version
ext.geckoNightly = [
version: '64.0.20180914100149'
]

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
41 changes: 37 additions & 4 deletions geckoview-local/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
import java.util.regex.Matcher
import java.util.regex.Pattern

configurations.maybeCreate('default')

if (gradle.hasProperty('geckoViewLocal')) {
def aar = new File(gradle.geckoViewLocal)
def getCurrentFlavor() {
Gradle gradle = getGradle()
String taskReqStr = gradle.getStartParameter().getTaskRequests().toString()
Pattern pattern
if (taskReqStr.contains("assemble")) {
pattern = Pattern.compile("assemble(\\w+)(Release|Debug)")
} else {
pattern = Pattern.compile("generate(\\w+)(Release|Debug)")
}
Matcher matcher = pattern.matcher(taskReqStr)
if (matcher.find()) {
String flavor = matcher.group(1)
// This makes first character to lowercase.
char[] c = flavor.toCharArray()
c[0] = Character.toLowerCase(c[0])
flavor = new String(c)
println "getCurrentFlavor:" + flavor
return flavor
} else {
println "getCurrentFlavor:cannot_find_current_flavor"
return ""
}
}

def addArtifact(path) {
def aar = new File(path)
if (aar.exists()) {
artifacts.add('default', aar)
} else {
throw new GradleException('Failed to find GeckoView AAR at: ' + gradle.geckoViewLocal)
}
} else {
throw new GradleException('Local GeckoView AAR path not defined')
}

def flavor = getCurrentFlavor()
if (flavor.contains("Arm") && gradle.hasProperty('geckoViewLocalArm')) {
addArtifact(gradle.geckoViewLocalArm)

} else if (flavor.contains("X86") && gradle.hasProperty('geckoViewLocalX86')) {
addArtifact(gradle.geckoViewLocalX86)
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (userPropertiesFile.exists()) {
println(prop.key + " = " + prop.value)
gradle.ext.set(prop.key, prop.value)
}
if (gradle.hasProperty('geckoViewLocal')) {
if (gradle.hasProperty('geckoViewLocalArm') || gradle.hasProperty('geckoViewLocalX86')) {
println("Using local build of geckoview")
include ':geckoview-local'
project(':geckoview-local').projectDir = new File('geckoview-local')
Expand Down

0 comments on commit 82a2d0b

Please sign in to comment.