Merge pull request #96967 from m4gr3d/update_android_editor_flavors

[Android editor] Update the Android editor flavors
This commit is contained in:
Rémi Verschelde 2024-09-16 13:35:28 +02:00
commit 7174e2192b
No known key found for this signature in database
GPG Key ID: C3336907360768E1
10 changed files with 32 additions and 28 deletions

View File

@ -86,7 +86,7 @@ jobs:
run: | run: |
cd platform/android/java cd platform/android/java
./gradlew generateGodotEditor ./gradlew generateGodotEditor
./gradlew generateGodotMetaEditor ./gradlew generateGodotHorizonOSEditor
cd ../../.. cd ../../..
ls -l bin/android_editor_builds/ ls -l bin/android_editor_builds/

View File

@ -25,7 +25,7 @@ allprojects {
ext { ext {
supportedAbis = ["arm32", "arm64", "x86_32", "x86_64"] supportedAbis = ["arm32", "arm64", "x86_32", "x86_64"]
supportedFlavors = ["editor", "template"] supportedFlavors = ["editor", "template"]
supportedEditorVendors = ["google", "meta"] supportedAndroidDistributions = ["android", "horizonos"]
supportedFlavorsBuildTypes = [ supportedFlavorsBuildTypes = [
"editor": ["dev", "debug", "release"], "editor": ["dev", "debug", "release"],
"template": ["dev", "debug", "release"] "template": ["dev", "debug", "release"]
@ -94,17 +94,17 @@ def templateExcludedBuildTask() {
/** /**
* Generates the build tasks for the given flavor * Generates the build tasks for the given flavor
* @param flavor Must be one of the supported flavors ('template' / 'editor') * @param flavor Must be one of the supported flavors ('template' / 'editor')
* @param editorVendor Must be one of the supported editor vendors ('google' / 'meta') * @param androidDistro Must be one of the supported Android distributions ('android' / 'horizonos')
*/ */
def generateBuildTasks(String flavor = "template", String editorVendor = "google") { def generateBuildTasks(String flavor = "template", String androidDistro = "android") {
if (!supportedFlavors.contains(flavor)) { if (!supportedFlavors.contains(flavor)) {
throw new GradleException("Invalid build flavor: $flavor") throw new GradleException("Invalid build flavor: $flavor")
} }
if (!supportedEditorVendors.contains(editorVendor)) { if (!supportedAndroidDistributions.contains(androidDistro)) {
throw new GradleException("Invalid editor vendor: $editorVendor") throw new GradleException("Invalid Android distribution: $androidDistro")
} }
String capitalizedEditorVendor = editorVendor.capitalize() String capitalizedAndroidDistro = androidDistro.capitalize()
def buildTasks = [] def buildTasks = []
// Only build the binary files for which we have native shared libraries unless we intend // Only build the binary files for which we have native shared libraries unless we intend
@ -170,28 +170,28 @@ def generateBuildTasks(String flavor = "template", String editorVendor = "google
} }
} else { } else {
// Copy the generated editor apk to the bin directory. // Copy the generated editor apk to the bin directory.
String copyEditorApkTaskName = "copyEditor${capitalizedEditorVendor}${capitalizedTarget}ApkToBin" String copyEditorApkTaskName = "copyEditor${capitalizedAndroidDistro}${capitalizedTarget}ApkToBin"
if (tasks.findByName(copyEditorApkTaskName) != null) { if (tasks.findByName(copyEditorApkTaskName) != null) {
buildTasks += tasks.getByName(copyEditorApkTaskName) buildTasks += tasks.getByName(copyEditorApkTaskName)
} else { } else {
buildTasks += tasks.create(name: copyEditorApkTaskName, type: Copy) { buildTasks += tasks.create(name: copyEditorApkTaskName, type: Copy) {
dependsOn ":editor:assemble${capitalizedEditorVendor}${capitalizedTarget}" dependsOn ":editor:assemble${capitalizedAndroidDistro}${capitalizedTarget}"
from("editor/build/outputs/apk/${editorVendor}/${target}") from("editor/build/outputs/apk/${androidDistro}/${target}")
into(androidEditorBuildsDir) into(androidEditorBuildsDir)
include("android_editor-${editorVendor}-${target}*.apk") include("android_editor-${androidDistro}-${target}*.apk")
} }
} }
// Copy the generated editor aab to the bin directory. // Copy the generated editor aab to the bin directory.
String copyEditorAabTaskName = "copyEditor${capitalizedEditorVendor}${capitalizedTarget}AabToBin" String copyEditorAabTaskName = "copyEditor${capitalizedAndroidDistro}${capitalizedTarget}AabToBin"
if (tasks.findByName(copyEditorAabTaskName) != null) { if (tasks.findByName(copyEditorAabTaskName) != null) {
buildTasks += tasks.getByName(copyEditorAabTaskName) buildTasks += tasks.getByName(copyEditorAabTaskName)
} else { } else {
buildTasks += tasks.create(name: copyEditorAabTaskName, type: Copy) { buildTasks += tasks.create(name: copyEditorAabTaskName, type: Copy) {
dependsOn ":editor:bundle${capitalizedEditorVendor}${capitalizedTarget}" dependsOn ":editor:bundle${capitalizedAndroidDistro}${capitalizedTarget}"
from("editor/build/outputs/bundle/${editorVendor}${capitalizedTarget}") from("editor/build/outputs/bundle/${androidDistro}${capitalizedTarget}")
into(androidEditorBuildsDir) into(androidEditorBuildsDir)
include("android_editor-${editorVendor}-${target}*.aab") include("android_editor-${androidDistro}-${target}*.aab")
} }
} }
} }
@ -204,7 +204,7 @@ def generateBuildTasks(String flavor = "template", String editorVendor = "google
} }
/** /**
* Generate the Godot Editor Android binaries. * Generate the Godot Editor binaries for Android devices.
* *
* Note: Unless the 'generateNativeLibs` argument is specified, the Godot 'tools' shared libraries * Note: Unless the 'generateNativeLibs` argument is specified, the Godot 'tools' shared libraries
* must have been generated (via scons) prior to running this gradle task. * must have been generated (via scons) prior to running this gradle task.
@ -212,19 +212,19 @@ def generateBuildTasks(String flavor = "template", String editorVendor = "google
*/ */
task generateGodotEditor { task generateGodotEditor {
gradle.startParameter.excludedTaskNames += templateExcludedBuildTask() gradle.startParameter.excludedTaskNames += templateExcludedBuildTask()
dependsOn = generateBuildTasks("editor", "google") dependsOn = generateBuildTasks("editor", "android")
} }
/** /**
* Generate the Godot Editor Android binaries for Meta devices. * Generate the Godot Editor binaries for HorizonOS devices.
* *
* Note: Unless the 'generateNativeLibs` argument is specified, the Godot 'tools' shared libraries * Note: Unless the 'generateNativeLibs` argument is specified, the Godot 'tools' shared libraries
* must have been generated (via scons) prior to running this gradle task. * must have been generated (via scons) prior to running this gradle task.
* The task will only build the binaries for which the shared libraries is available. * The task will only build the binaries for which the shared libraries is available.
*/ */
task generateGodotMetaEditor { task generateGodotHorizonOSEditor {
gradle.startParameter.excludedTaskNames += templateExcludedBuildTask() gradle.startParameter.excludedTaskNames += templateExcludedBuildTask()
dependsOn = generateBuildTasks("editor", "meta") dependsOn = generateBuildTasks("editor", "horizonos")
} }
/** /**

View File

@ -145,14 +145,14 @@ android {
} }
} }
flavorDimensions = ["vendor"] flavorDimensions = ["android_distribution"]
productFlavors { productFlavors {
google { android {
dimension "vendor" dimension "android_distribution"
missingDimensionStrategy 'products', 'editor' missingDimensionStrategy 'products', 'editor'
} }
meta { horizonos {
dimension "vendor" dimension "android_distribution"
missingDimensionStrategy 'products', 'editor' missingDimensionStrategy 'products', 'editor'
ndk { ndk {
//noinspection ChromeOsAbiSupport //noinspection ChromeOsAbiSupport
@ -176,5 +176,5 @@ dependencies {
implementation "org.bouncycastle:bcprov-jdk15to18:1.77" implementation "org.bouncycastle:bcprov-jdk15to18:1.77"
// Meta dependencies // Meta dependencies
metaImplementation "org.godotengine:godot-openxr-vendors-meta:3.0.0-stable" horizonosImplementation "org.godotengine:godot-openxr-vendors-meta:3.0.0-stable"
} }

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -36,7 +36,7 @@ import org.godotengine.godot.utils.isNativeXRDevice
/** /**
* Primary window of the Godot Editor. * Primary window of the Godot Editor.
* *
* This is the implementation of the editor used when running on Meta devices. * This is the implementation of the editor used when running on HorizonOS devices.
*/ */
open class GodotEditor : BaseGodotEditor() { open class GodotEditor : BaseGodotEditor() {

View File

@ -517,6 +517,10 @@ abstract class BaseGodotEditor : GodotActivity() {
return isNativeXRDevice(); return isNativeXRDevice();
} }
if (featureTag == "horizonos") {
return isHorizonOSDevice()
}
return false return false
} }
} }

View File

@ -38,7 +38,7 @@ package org.godotengine.godot.utils
import android.os.Build import android.os.Build
/** /**
* Returns true if running on Meta's Horizon OS. * Returns true if running on Meta Horizon OS.
*/ */
fun isHorizonOSDevice(): Boolean { fun isHorizonOSDevice(): Boolean {
return "Oculus".equals(Build.BRAND, true) return "Oculus".equals(Build.BRAND, true)