Revision control

Copy as Markdown

plugins {
id "com.jetbrains.python.envs" version "0.0.26"
}
apply plugin: 'com.android.application'
apply from: "$project.rootDir/tools/gradle/versionCode.gradle"
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "org.mozilla.telemetry.glean-gradle-plugin"
apply plugin: 'com.huawei.agconnect'
deps.telemetry.glean_unittests = "org.mozilla.telemetry:glean-forUnitTests:$project.ext.glean_version"
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
def getTaskclusterBuild = { ->
if (gradle.hasProperty("userProperties.taskclusterBuild")) {
return gradle."userProperties.taskclusterBuild"
}
return "false"
}
def getCrashRestartDisabled = { ->
if (gradle.hasProperty("userProperties.disableCrashRestart")) {
return gradle."userProperties.disableCrashRestart"
}
return "false"
}
def getDevApplicationIdSuffix = { ->
if (gradle.hasProperty("userProperties.simultaneousDevProduction")) {
return gradle."userProperties.simultaneousDevProduction" == "true" ? ".dev" : ""
}
return ""
}
def getUseDebugSigningOnRelease = { ->
if (gradle.hasProperty("userProperties.useDebugSigningOnRelease")) {
return gradle."userProperties.useDebugSigningOnRelease" == "true"
}
return false
}
def getOpenXRFlags = { ->
if (gradle.hasProperty("userProperties.openxr")) {
return gradle."userProperties.openxr" == "true" ? " -DOPENXR" : ""
}
return ""
}
def getOpenXRCMakeFlags = { ->
if (gradle.hasProperty("userProperties.openxr")) {
return gradle."userProperties.openxr" == "true" ? "-DOPENXR=ON" : ""
}
return ""
}
def getHVRMLApiKey = { ->
if (gradle.hasProperty("userProperties.HVR_ML_API_KEY")) {
return gradle."userProperties.HVR_ML_API_KEY"
}
return ""
}
// Glean: Generate markdown docs for the collected metrics.
ext.gleanGenerateMarkdownDocs = true
ext.gleanDocsDirectory = "$rootDir/docs"
android {
compileSdkVersion build_versions.target_sdk
defaultConfig {
applicationId "org.mozilla.vrbrowser"
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "13.0"
buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
buildConfigField "Boolean", "DISABLE_CRASH_RESTART", getCrashRestartDisabled()
buildConfigField "Boolean", "TASKCLUSTER_BUILD", getTaskclusterBuild()
buildConfigField "String", "AMO_COLLECTION", "\"fxr\""
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-std=c++14 -fexceptions -frtti -Werror" +
" -I" + file("src/main/cpp").absolutePath +
" -I" + file("src/main/cpp/vrb/include").absolutePath
arguments "-DANDROID_STL=c++_shared"
}
}
javaCompileOptions {
annotationProcessorOptions {
arguments = [
"room.schemaLocation":"$projectDir/schemas".toString(),
"room.incremental":"true",
"room.expandProjection":"true"]
}
}
vectorDrawables.useSupportLibrary = true
}
if (gradle.hasProperty('userProperties.taskclusterBuild')) {
project.archivesBaseName = "FirefoxReality-$defaultConfig.versionName-$generatedVersionCode"
defaultConfig.versionCode = generatedVersionCode
} else {
project.archivesBaseName = "FirefoxReality"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig getUseDebugSigningOnRelease() ? debug.signingConfig : release.signingConfig
buildConfigField 'String', 'PROPS_ENDPOINT', '"http://mixedreality.mozilla.org/FirefoxReality/props.json"'
}
debug {
applicationIdSuffix getDevApplicationIdSuffix()
pseudoLocalesEnabled true
buildConfigField 'String', 'PROPS_ENDPOINT', '"http://mixedreality.mozilla.org/FirefoxReality/props.json"'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
dataBinding {
enabled = true
}
lintOptions {
disable "ExtraTranslation"
}
flavorDimensions "platform", "abi"
productFlavors {
// Supported platforms
oculusvr {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags "-DOCULUSVR -DSTORE_BUILD=0" + getOpenXRFlags()
arguments "-DVR_SDK_LIB=oculusvr-lib", "-DVR_SDK_EXTRA_LIB=ovrplatform-lib", "-DOCULUSVR=ON", getOpenXRCMakeFlags()
}
}
manifestPlaceholders = [ headtrackingRequired:"false", permissionToRemove:"android.permission.RECEIVE_BOOT_COMPLETED" ]
}
oculusvrStore {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags "-DOCULUSVR -DSTORE_BUILD=1" + getOpenXRFlags()
arguments "-DVR_SDK_LIB=oculusvr-lib", "-DVR_SDK_EXTRA_LIB=ovrplatform-lib", "-DOCULUSVR=ON", getOpenXRCMakeFlags()
}
}
manifestPlaceholders = [ headtrackingRequired:"false", permissionToRemove:"android.permission.RECEIVE_BOOT_COMPLETED" ]
}
oculusvr3dofStore {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags "-DOCULUSVR -DSTORE_BUILD=1" + getOpenXRFlags()
arguments "-DVR_SDK_LIB=oculusvr-lib", "-DVR_SDK_EXTRA_LIB=ovrplatform-lib", "-DOCULUSVR=ON", getOpenXRCMakeFlags()
}
}
manifestPlaceholders = [ headtrackingRequired:"false", permissionToRemove:"android.permission.CAMERA" ]
}
wavevr {
minSdkVersion build_versions.min_sdk_wave
targetSdkVersion build_versions.target_sdk_wave
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -I" + file("${project.rootDir}/third_party/wavesdk/build/wvr_client-${versions.wavevr}/include").absolutePath +
" -DWAVEVR"
arguments "-DVR_SDK_LIB=wavevr-lib", "-DWAVEVR=ON", "-DWAVE_SDK_VERSION=${versions.wavevr}"
}
}
applicationIdSuffix ".internal"
}
wavevrStore {
minSdkVersion build_versions.min_sdk_wave
targetSdkVersion build_versions.target_sdk_wave
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -I" + file("${project.rootDir}/third_party/wavesdk/build/wvr_client-${versions.wavevr}/include").absolutePath +
" -DWAVEVR"
arguments "-DVR_SDK_LIB=wavevr-lib", "-DWAVEVR=ON", "-DWAVE_SDK_VERSION=${versions.wavevr}"
}
}
}
picovr {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -DPICOVR"
arguments "-DPICOVR=ON"
}
}
applicationIdSuffix ".internal"
}
picovrStore {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -DPICOVR"
arguments "-DPICOVR=ON"
}
}
}
hvr {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -DHVR -DHVR_6DOF -DOPENXR -I" + file("src/openxr/cpp").absolutePath
arguments "-DVR_SDK_LIB=hvr-lib", "-DHVR=ON", "-DOPENXR=ON"
}
}
buildConfigField "String", "HVR_ML_API_KEY", "\"${getHVRMLApiKey()}\""
}
noapi {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -DVRBROWSER_NO_VR_API"
arguments "-DNOAPI=ON"
}
}
}
// Supported ABIs
arm64 {
dimension "abi"
ndk {
abiFilters "arm64-v8a"
}
}
x86_64 {
dimension "abi"
ndk {
abiFilters "x86_64"
}
}
}
variantFilter { variant ->
def needed = variant.name in [
'oculusvrArm64Debug',
'oculusvrArm64Release',
'oculusvrStoreArm64Debug',
'oculusvrStoreArm64Release',
'oculusvr3dofStoreArm64Debug',
'oculusvr3dofStoreArm64Release',
'picovrArm64Debug',
'picovrArm64Release',
'picovrStoreArm64Debug',
'picovrStoreArm64Release',
'wavevrArm64Debug',
'wavevrArm64Release',
'wavevrStoreArm64Debug',
'wavevrStoreArm64Release',
'noapiArm64Debug',
'noapiArm64Release',
'noapiX86_64Debug',
'noapiX86_64Release',
'hvrArm64Debug',
'hvrArm64Release'
]
variant.setIgnore(!needed)
}
sourceSets {
main {
java.srcDirs = [
'app',
'src/common/shared',
'src/main/cpp/vrb/android/java'
]
}
release {
manifest.srcFile getUseDebugSigningOnRelease() ? "src/debug/AndroidManifest.xml"
: manifest.srcFile
}
oculusvr {
java.srcDirs = [
'src/oculusvr/java'
]
}
oculusvrStore {
java.srcDirs = [
'src/oculusvr/java'
]
assets.srcDirs = [
'src/oculusvr/assets'
]
res.srcDirs = [
'src/oculusvr/res'
]
}
oculusvr3dofStore {
java.srcDirs = [
'src/oculusvr/java'
]
assets.srcDirs = [
'src/oculusvr/assets'
]
res.srcDirs = [
'src/oculusvr/res'
]
}
oculusvrArm64Debug {
manifest.srcFile "src/oculusvrArmDebug/AndroidManifest.xml"
}
oculusvrArm64Release {
manifest.srcFile getUseDebugSigningOnRelease() ? "src/oculusvrArmDebug/AndroidManifest.xml"
: "src/oculusvrArmRelease/AndroidManifest.xml"
}
oculusvrStoreArm64Debug {
manifest.srcFile "src/oculusvrArmDebug/AndroidManifest.xml"
}
oculusvrStoreArm64Release {
manifest.srcFile getUseDebugSigningOnRelease() ? "src/oculusvrArmDebug/AndroidManifest.xml"
: "src/oculusvrArmRelease/AndroidManifest.xml"
}
oculusvr3dofStoreArm64Debug {
manifest.srcFile "src/oculusvrArmDebug/AndroidManifest.xml"
}
oculusvr3dofStoreArm64Release {
manifest.srcFile getUseDebugSigningOnRelease() ? "src/oculusvrArmDebug/AndroidManifest.xml"
: "src/oculusvrArmRelease/AndroidManifest.xml"
}
wavevr {
java.srcDirs = [
'src/wavevr/java'
]
res.srcDirs = [
'src/wavevr/res'
]
jniLibs.srcDirs = ["${project.rootDir}/third_party/wavesdk/build/wvr_client-${versions.wavevr}/jni"]
}
wavevrStore {
java.srcDirs = [
'src/wavevr/java'
]
res.srcDirs = [
'src/wavevr/res'
]
assets.srcDirs = [
'src/wavevr/assets'
]
jniLibs.srcDirs = ["${project.rootDir}/third_party/wavesdk/build/wvr_client-${versions.wavevr}/jni"]
manifest.srcFile "src/wavevr/AndroidManifest.xml"
}
picovr {
java.srcDirs = [
'src/picovr/java'
]
jniLibs.srcDirs = ["${project.rootDir}/third_party/picovr"]
}
picovrStore {
java.srcDirs = [
'src/picovr/java'
]
assets.srcDirs = [
'src/picovr/assets'
]
res.srcDirs = [
'src/picovr/res'
]
jniLibs.srcDirs = ["${project.rootDir}/third_party/picovr"]
manifest.srcFile "src/picovr/AndroidManifest.xml"
}
hvr {
java.srcDirs = [
'src/hvr/java'
]
assets.srcDirs = [
'src/hvr/assets'
]
res.srcDirs = [
'src/hvr/res'
]
}
noapi {
java.srcDirs = [
'src/noapi/java'
]
}
}
testOptions {
unitTests.includeAndroidResources = true
}
aaptOptions {
noCompress 'ja'
}
}
configurations {
jnaForTest
armImplementation
x86Implementation
}
repositories {
flatDir {
dirs 'aars'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation deps.openwnn
// Common
implementation deps.lifecycle.runtime
implementation deps.lifecycle.viewmodel
implementation deps.lifecycle.java8
implementation deps.lifecycle.process
implementation deps.support.cardview
implementation deps.support.app_compat
implementation deps.support.vector_drawable
implementation deps.support.annotations
implementation deps.constraint_layout
implementation deps.gson
implementation deps.room.runtime
annotationProcessor deps.room.compiler
// Android Components
implementation deps.mozilla_speech.library
implementation deps.mozilla_speech.utils
implementation deps.android_components.browser_errorpages
implementation deps.android_components.browser_search
implementation deps.android_components.browser_state
implementation deps.android_components.browser_storage
implementation deps.android_components.browser_domains
implementation deps.android_components.service_accounts
implementation deps.android_components.service_sync_logins
implementation deps.android_components.mozilla_service_location
implementation deps.android_components.ui_autocomplete
implementation deps.android_components.concept_engine
implementation deps.android_components.concept_fetch
implementation deps.android_components.lib_fetch
implementation deps.android_components.lib_dataprotect
implementation deps.android_components.support_rustlog
implementation deps.android_components.support_rusthttp
implementation deps.android_components.support_webextensions
implementation deps.android_components.support_ktx
implementation deps.android_components.feature_accounts
implementation deps.android_components.feature_webcompat
implementation deps.android_components.feature_webcompat_reporter
implementation deps.android_components.feature_addons
implementation deps.android_components.glean
implementation deps.app_services.rustlog
// Kotlin dependency
implementation deps.kotlin.stdlib
implementation deps.kotlin.coroutines
implementation deps.kotlin.coroutines_jdk8
// SQLite helper to handle DBs from assets
implementation deps.sqlite.sqlite
// DiskLRUCache used to cache snapshots
implementation deps.disklrucache.disklrucache
// Testing
androidTestImplementation deps.atsl.runner
androidTestImplementation deps.espresso.core
testImplementation deps.junit
testImplementation deps.atsl.core
testImplementation deps.robolectric
testImplementation deps.app_services.rustlog
testImplementation deps.android_components.support_test
testImplementation deps.android_components.support_test_appservices
jnaForTest deps.jna
testImplementation files(configurations.jnaForTest.copyRecursive().files)
testImplementation deps.telemetry.glean_unittests
testImplementation deps.work.testing
// Pico
picovrImplementation fileTree(dir: "${project.rootDir}/third_party/picovr/", include: ['*.aar'])
picovrStoreImplementation fileTree(dir: "${project.rootDir}/third_party/picovr/", include: ['*.aar'])
// HVR
hvrImplementation fileTree(dir: "${project.rootDir}/third_party/hvr", include: ['*.jar'])
hvrImplementation 'com.huawei.agconnect:agconnect-core-harmony:1.0.0.300'
hvrImplementation 'com.huawei.agconnect:agconnect-core:1.6.0.300'
hvrImplementation 'com.huawei.hms:ml-computer-voice-asr:3.1.0.300'
}
if (findProject(':servo')) {
dependencies {
oculusvrImplementation project(':servo')
}
}
if (findProject(':wavesdk')) {
dependencies {
wavevrImplementation fileTree(dir: "${project.rootDir}/third_party/wavesdk/", include: ['*.aar'])
wavevrStoreImplementation fileTree(dir: "${project.rootDir}/third_party/wavesdk/", include: ['*.aar'])
}
}
dependencies {
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
// "nightly" or "beta" or "release"
def branch = "nightly"
arm64Implementation deps.gecko_view."${branch}_arm64"
x86_64Implementation deps.gecko_view."${branch}_x86_64"
}
if (gradle.hasProperty('geckoViewLocalArm') || gradle.hasProperty('geckoViewLocalX86')) {
throw new GradleException("geckoViewLocal{Arm,X86} are deprecated: use geckoViewLocalTopsrcdir and geckoViewLocalTopobjdir")
}
if (gradle.hasProperty('localProperties.dependencySubstitutions.geckoviewTopsrcdir')) {
if (gradle.hasProperty('localProperties.dependencySubstitutions.geckoviewTopobjdir')) {
ext.topobjdir = gradle."localProperties.dependencySubstitutions.geckoviewTopobjdir"
}
ext.topsrcdir = gradle."localProperties.dependencySubstitutions.geckoviewTopsrcdir"
apply from: "${topsrcdir}/substitute-local-geckoview.gradle"
}
// -------------------------------------------------------------------------------------------------
// MLS: Read token from local file if it exists
// -------------------------------------------------------------------------------------------------
android.applicationVariants.all { variant ->
print("MLS token: ")
try {
def token = new File("${rootDir}/.mls_token").text.trim()
buildConfigField 'String', 'MLS_TOKEN', '"' + token + '"'
println "(Added from .mls_token file)"
} catch (FileNotFoundException ignored) {
buildConfigField 'String', 'MLS_TOKEN', '""'
println("X_X")
}
}
// -------------------------------------------------------------------------------------------------
// Dynamically set versionCode (See tools/build/versionCode.gradle
// -------------------------------------------------------------------------------------------------
android.applicationVariants.all { variant ->
if (gradle.hasProperty('userProperties.taskclusterBuild')) {
variant.outputs.each { output ->
output.versionCodeOverride = generatedVersionCode
}
}
}