-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the Godot OpenXR loader to match the new Android plugin pack…
…aging format for Godot 4.2 The new format gives a lot of flexibility and allows each vendor plugin to provide its own set of parameters in the export window. Those parameters in turn influences how the Android manifest is generated.
- Loading branch information
Showing
30 changed files
with
872 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Workflow to automatically create the godot openxr loaders addon | ||
name: Build on push | ||
|
||
on: | ||
[push, pull_request] | ||
|
||
jobs: | ||
build: | ||
name: Assembling artifacts | ||
runs-on: ubuntu-20.04 | ||
|
||
# Note, to satisfy the asset library we need to make sure our zip files have a root folder | ||
# this is why we checkout into aar and build into asset | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
path: aar | ||
- name: Setup java | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: 11 | ||
distribution: 'adopt' | ||
- name: Validate Gradle wrapper | ||
uses: gradle/wrapper-validation-action@v1 | ||
- name: Create Godot OpenXR loader AARs | ||
run: | | ||
cd aar | ||
./gradlew build | ||
cd .. | ||
# GODOT 4.2 ADDON GENERATION SECTION | ||
- name: Create Godot OpenXR loader Addon | ||
run: | | ||
mkdir asset | ||
cp -r aar/demo/addons asset | ||
cp aar/CHANGES.md asset/addons/godotopenxr/GodotOpenXRLoaders_CHANGES.md | ||
- name: Adding vendor licences | ||
run: | | ||
cp aar/godotopenxrmeta/LICENSE.txt asset/addons/godotopenxr/export/meta/ | ||
cp aar/godotopenxrpico/src/main/jniLibs/arm64-v8a/README.md asset/addons/godotopenxr/export/pico/LICENSE.md | ||
cp aar/godotopenxrkhr/LICENSE asset/addons/godotopenxr/export/khr/LICENSE | ||
- name: Create Godot OpenXR loader addon artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: GodotOpenXRLoadersAddon | ||
path: | | ||
asset | ||
- name: Zip addon | ||
run: | | ||
zip -qq -r godotopenxrloadersaddon.zip asset | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
- name: Create and upload asset | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
allowUpdates: true | ||
artifacts: "godotopenxrloadersaddon.zip" | ||
omitNameDuringUpdate: true | ||
omitBodyDuringUpdate: true | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Normalize EOL for all files that Git considers text files. | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Godot 4+ specific ignores | ||
.godot/ | ||
/addons/godotopenxr/export/*/*.aar | ||
/android/ |
Empty file.
120 changes: 120 additions & 0 deletions
120
demo/addons/godotopenxr/export/godot_openxr_editor_export_plugin.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
@tool | ||
class_name GodotOpenXREditorExportPlugin extends EditorExportPlugin | ||
|
||
const OPENXR_MODE_VALUE = 1 | ||
|
||
var _vendor: String | ||
var _plugin_version: String | ||
|
||
func _init(vendor: String, version: String): | ||
_vendor = vendor | ||
_plugin_version = version | ||
|
||
|
||
func _get_name() -> String: | ||
return "GodotOpenXR" + _vendor.capitalize() | ||
|
||
|
||
# Path to the Android library aar file | ||
# If this is not available, we fall back to the maven central dependency | ||
func _get_android_aar_file_path(debug: bool) -> String: | ||
return "res://addons/godotopenxr/export/" + _vendor + "/godotopenxr" + _vendor + "-" + ("debug.aar" if debug else "release.aar") | ||
|
||
|
||
# Maven central dependency used as fall back when the Android library aar file is not available | ||
func _get_android_maven_central_dependency() -> String: | ||
return "org.godotengine:godot-openxr-loaders-" + _vendor + ":" + _plugin_version | ||
|
||
|
||
func _get_vendor_toggle_option_name() -> String: | ||
return "xr_features/enable_" + _vendor + "_plugin" | ||
|
||
|
||
func _get_vendor_toggle_option() -> Dictionary: | ||
var toggle_option = { | ||
"option": { | ||
"name": _get_vendor_toggle_option_name(), | ||
"class_name": "", | ||
"type": TYPE_BOOL, | ||
"hint": PROPERTY_HINT_NONE, | ||
"hint_string": "", | ||
"usage": PROPERTY_USAGE_DEFAULT, | ||
}, | ||
"default_value": false, | ||
"update_visibility": false, | ||
} | ||
return toggle_option | ||
|
||
|
||
func _is_openxr_enabled() -> bool: | ||
return _get_int_option("xr_features/xr_mode", 0) == OPENXR_MODE_VALUE | ||
|
||
|
||
func _get_export_options(platform) -> Array[Dictionary]: | ||
if not _supports_platform(platform): | ||
return [] | ||
|
||
return [ | ||
_get_vendor_toggle_option(), | ||
] | ||
|
||
|
||
func _get_export_option_warning(platform, option) -> String: | ||
if not _supports_platform(platform): | ||
return "" | ||
|
||
if option != _get_vendor_toggle_option_name(): | ||
return "" | ||
|
||
if not(_is_openxr_enabled()) and _get_bool_option(option): | ||
return "\"Enable " + _vendor.capitalize() + " Plugin\" requires \"XR Mode\" to be \"OpenXR\".\n" | ||
|
||
return "" | ||
|
||
|
||
func _supports_platform(platform) -> bool: | ||
if platform is EditorExportPlatformAndroid: | ||
return true | ||
return false | ||
|
||
|
||
func _get_bool_option(option: String) -> bool: | ||
var option_enabled = get_option(option) | ||
if option_enabled is bool: | ||
return option_enabled | ||
return false | ||
|
||
|
||
func _get_int_option(option: String, default_value: int) -> int: | ||
var option_value = get_option(option) | ||
if option_value is int: | ||
return option_value | ||
return default_value | ||
|
||
|
||
func _is_vendor_plugin_enabled() -> bool: | ||
return _get_bool_option(_get_vendor_toggle_option_name()) | ||
|
||
|
||
func _is_android_aar_file_available(debug: bool) -> bool: | ||
return FileAccess.file_exists(_get_android_aar_file_path(debug)) | ||
|
||
|
||
func _get_android_dependencies(platform, debug) -> PackedStringArray: | ||
if not _supports_platform(platform): | ||
return PackedStringArray() | ||
|
||
if _is_vendor_plugin_enabled() and not _is_android_aar_file_available(debug): | ||
return PackedStringArray([_get_android_maven_central_dependency()]) | ||
|
||
return PackedStringArray() | ||
|
||
|
||
func _get_android_libraries(platform, debug) -> PackedStringArray: | ||
if not _supports_platform(platform): | ||
return PackedStringArray() | ||
|
||
if _is_vendor_plugin_enabled() and _is_android_aar_file_available(debug): | ||
return PackedStringArray([_get_android_aar_file_path(debug)]) | ||
|
||
return PackedStringArray() |
Oops, something went wrong.