Skip to content

Commit

Permalink
Merge GDExtension into a single implementation
Browse files Browse the repository at this point in the history
Move all the gdextension logic intom the `common` directory so to share the same functionality across all vendors.

For the editor, this enables a single `scons` build file and a single gdextension that can be loaded by the editor.

For Android vendor platforms, we still maintains separate `cmake` build files which allows to omit / include platform specific dependencies via pre-processor directives in order to generate platform specific shared libraries, which are included in platform specific AAR binaries.
  • Loading branch information
m4gr3d committed Feb 1, 2024
1 parent e946c3a commit 8ad906c
Show file tree
Hide file tree
Showing 50 changed files with 142 additions and 666 deletions.
47 changes: 19 additions & 28 deletions .github/workflows/build-addon-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,43 @@ jobs:
platform: linux
flags: arch=x86_64
artifact_name: build-files-linux-x86_64
artifact_path: aar/demo/addons/godotopenxrvendors/*/.bin/*.so
artifact_path: aar/demo/addons/godotopenxrvendors/.bin/linux/*/*/*.so
# Not sure how to cross compile these
# - name: Linux (arm64)
# os: ubuntu-20.04
# platform: linux
# flags: arch=arm64
# artifact_name: build-files-linux-arm64
# artifact_path: aar/demo/addons/godotopenxrvendors/*/.bin/*.so
# artifact_path: aar/demo/addons/godotopenxrvendors/.bin/linux/*/*/*.so
# - name: Linux (rv64)
# os: ubuntu-20.04
# platform: linux
# flags: arch=rv64
# artifact_name: build-files-linux-rv64
# artifact_path: aar/demo/addons/godotopenxrvendors/*/.bin/*.so
# artifact_path: aar/demo/addons/godotopenxrvendors/.bin/linux/*/*/*.so
- name: Windows
os: windows-latest
platform: windows
artifact_name: build-files-windows
artifact_path: aar/demo/addons/godotopenxrvendors/*/.bin/*.dll
artifact_path: aar/demo/addons/godotopenxrvendors/.bin/windows/*/*/*.dll
- name: MacOS
os: macos-11
platform: macos
flags: arch=universal
artifact_name: build-files-macos
artifact_path: aar/demo/addons/godotopenxrvendors/*/.bin/*.framework
- name: Android
artifact_path: aar/demo/addons/godotopenxrvendors/.bin/macos/*/*.framework
- name: Android AAR
os: ubuntu-20.04
platform: android
flags: arch=arm64
artifact_name: build-files-android
artifact_path: aar/demo/addons/godotopenxrvendors/*/.bin/*/*.aar
artifact_name: build-files-android-aar
artifact_path: aar/demo/addons/godotopenxrvendors/.bin/android/*/*.aar
- name: Android SO
os: ubuntu-20.04
platform: android
flags: arch=arm64
artifact_name: build-files-android-so
artifact_path: aar/demo/addons/godotopenxrvendors/.bin/android/*/*/*.so

# 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
Expand Down Expand Up @@ -75,7 +81,6 @@ jobs:
scons platform=${{ matrix.platform }} target=template_debug ${{ matrix.flags }}
scons platform=${{ matrix.platform }} target=template_release ${{ matrix.flags }}
cd ..
if: matrix.platform != 'android'
# On Android we build our loaders and build our extension with gradlew
- name: Setup java
Expand Down Expand Up @@ -137,25 +142,11 @@ jobs:
- name: Copying artifacts
run: |
cp -r build-files-android/khronos/.bin asset/addons/godotopenxrvendors/khronos/
cp -r build-files-android/lynx/.bin asset/addons/godotopenxrvendors/lynx/
cp -r build-files-android/meta/.bin asset/addons/godotopenxrvendors/meta/
cp -r build-files-android/pico/.bin asset/addons/godotopenxrvendors/pico/
cp build-files-linux-x86_64/khronos/.bin/*.so asset/addons/godotopenxrvendors/khronos/.bin/
cp build-files-linux-x86_64/lynx/.bin/*.so asset/addons/godotopenxrvendors/lynx/.bin/
cp build-files-linux-x86_64/meta/.bin/*.so asset/addons/godotopenxrvendors/meta/.bin/
cp build-files-linux-x86_64/pico/.bin/*.so asset/addons/godotopenxrvendors/pico/.bin/
cp build-files-windows/khronos/.bin/*.dll asset/addons/godotopenxrvendors/khronos/.bin/
cp build-files-windows/lynx/.bin/*.dll asset/addons/godotopenxrvendors/lynx/.bin/
cp build-files-windows/meta/.bin/*.dll asset/addons/godotopenxrvendors/meta/.bin/
cp build-files-windows/pico/.bin/*.dll asset/addons/godotopenxrvendors/pico/.bin/
cp -r build-files-macos/khronos/.bin/*.framework asset/addons/godotopenxrvendors/khronos/.bin/
cp -r build-files-macos/lynx/.bin/*.framework asset/addons/godotopenxrvendors/lynx/.bin/
cp -r build-files-macos/meta/.bin/*.framework asset/addons/godotopenxrvendors/meta/.bin/
cp -r build-files-macos/pico/.bin/*.framework asset/addons/godotopenxrvendors/pico/.bin/
cp -r build-files-android-aar/.bin/android asset/addons/godotopenxrvendors/.bin/
cp -r build-files-android-so/.bin/android asset/addons/godotopenxrvendors/.bin/
cp -r build-files-linux-x86_64/.bin/linux asset/addons/godotopenxrvendors/.bin/
cp -r build-files-windows/.bin/windows asset/addons/godotopenxrvendors/.bin/
cp -r build-files-macos/.bin/macos asset/addons/godotopenxrvendors/.bin/
- name: Create Godot OpenXR Vendor addon artifact
uses: actions/upload-artifact@v3
Expand Down
43 changes: 34 additions & 9 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,37 @@ env.Append(CPPPATH=[
"#thirdparty/openxr/include/",
])

common_objects = []
common_objects.append(env.SharedObject(Glob("#common/src/main/cpp/export/*.cpp")))

SConscript([
"godotopenxrmeta/SConstruct",
"godotopenxrpico/SConstruct",
"godotopenxrlynx/SConstruct",
"godotopenxrkhronos/SConstruct",
], 'env common_objects')
sources = []
sources += Glob("#common/src/main/cpp/*.cpp")
sources += Glob("#common/src/main/cpp/export/*.cpp")
sources += Glob("#common/src/main/cpp/extensions/*.cpp")

binary_path = '#demo/addons/godotopenxrvendors/.bin'
project_name = 'godotopenxr'

# Create the library target
if env["platform"] == "macos":
library = env.SharedLibrary(
"{0}/{1}/{2}/lib{3}.{1}.framework/{3}.{1}".format(
binary_path,
env["platform"],
env["target"],
project_name,
),
source=sources,
)
else:
library = env.SharedLibrary(
"{}/{}/{}/{}/lib{}{}".format(
binary_path,
env["platform"],
env["target"],
env["arch"],
project_name,
env["SHLIBSUFFIX"],
),
source=sources,
)

Default(library)

2 changes: 1 addition & 1 deletion common/src/main/cpp/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ String OpenXREditorExportPlugin::_get_name() const {

String OpenXREditorExportPlugin::_get_android_aar_file_path(bool debug) const {
const String debug_label = debug ? "debug" : "release";
return "res://addons/godotopenxrvendors/" + _vendor + "/.bin/" + debug_label + "/godotopenxr" + _vendor + "-" + debug_label + ".aar";
return "res://addons/godotopenxrvendors/.bin/android/" + debug_label + "/godotopenxr" + _vendor + "-" + debug_label + ".aar";
}

String OpenXREditorExportPlugin::_get_android_maven_central_dependency() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

#include <godot_cpp/classes/open_xr_extension_wrapper_extension.hpp>
#include <openxr/openxr.h>
#include <openxr/fb_scene_capture.h>
#include <godot_cpp/variant/utility_functions.hpp>

#include "util.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#include <godot_cpp/classes/open_xr_extension_wrapper_extension.hpp>
#include <openxr/openxr.h>
#include <openxr/fb_scene.h>
#include <godot_cpp/templates/hash_map.hpp>
#include <godot_cpp/templates/vector.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#include <godot_cpp/classes/open_xr_extension_wrapper_extension.hpp>
#include <openxr/openxr.h>
#include <openxr/fb_spatial_entity_container.h>
#include <godot_cpp/templates/hash_map.hpp>
#include <godot_cpp/templates/vector.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#include <godot_cpp/classes/open_xr_extension_wrapper_extension.hpp>
#include <openxr/openxr.h>
#include <openxr/fb_spatial_entity.h>
#include <godot_cpp/templates/hash_map.hpp>
#include <godot_cpp/variant/utility_functions.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

#include <godot_cpp/classes/open_xr_extension_wrapper_extension.hpp>
#include <openxr/openxr.h>
#include <openxr/fb_spatial_entity.h>
#include <openxr/fb_spatial_entity_query.h>
#include <godot_cpp/templates/hash_map.hpp>
#include <godot_cpp/templates/vector.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#include <godot_cpp/classes/open_xrapi_extension.hpp>
#include <godot_cpp/classes/object.hpp>

#ifdef META_VENDOR_ENABLED
#include <openxr/fb_scene.h>
#endif

#include "include/openxr_fb_spatial_entity_extension_wrapper.h"

using namespace godot;
Expand Down Expand Up @@ -97,11 +101,14 @@ std::optional<String> OpenXRFbSceneExtensionWrapper::get_semantic_labels(const X
// List from https://developer.oculus.com/documentation/native/android/mobile-scene-api-ref/
static const CharString recognizedLabels =
"CEILING,DOOR_FRAME,FLOOR,INVISIBLE_WALL_FACE,WALL_ART,WALL_FACE,WINDOW_FRAME,COUCH,TABLE,BED,LAMP,PLANT,SCREEN,STORAGE,GLOBAL_MESH,OTHER";
XrSemanticLabelsSupportFlagsFB flags = XR_SEMANTIC_LABELS_SUPPORT_MULTIPLE_SEMANTIC_LABELS_BIT_FB | XR_SEMANTIC_LABELS_SUPPORT_ACCEPT_DESK_TO_TABLE_MIGRATION_BIT_FB;
#ifdef META_VENDOR_ENABLED
flags |= XR_SEMANTIC_LABELS_SUPPORT_ACCEPT_INVISIBLE_WALL_FACE_BIT_FB;
#endif
const XrSemanticLabelsSupportInfoFB semanticLabelsSupportInfo = {
XR_TYPE_SEMANTIC_LABELS_SUPPORT_INFO_FB,
nullptr,
XR_SEMANTIC_LABELS_SUPPORT_MULTIPLE_SEMANTIC_LABELS_BIT_FB | XR_SEMANTIC_LABELS_SUPPORT_ACCEPT_DESK_TO_TABLE_MIGRATION_BIT_FB |
XR_SEMANTIC_LABELS_SUPPORT_ACCEPT_INVISIBLE_WALL_FACE_BIT_FB,
flags,
recognizedLabels.ptr(),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@
#include <godot_cpp/godot.hpp>
#include <godot_cpp/variant/utility_functions.hpp>

#include "include/openxr_fb_scene_extension_wrapper.h"
#include "include/openxr_fb_scene_capture_extension_wrapper.h"
#include "include/openxr_fb_spatial_entity_extension_wrapper.h"
#include "include/openxr_fb_spatial_entity_container_extension_wrapper.h"
#include "include/openxr_fb_spatial_entity_query_extension_wrapper.h"

#include "export/export_plugin.h"
#include "export/khronos_export_plugin.h"
#include "export/lynx_export_plugin.h"
#include "export/meta_export_plugin.h"
#include "export/pico_export_plugin.h"

#include "extensions/include/openxr_fb_scene_extension_wrapper.h"
#include "extensions/include/openxr_fb_scene_capture_extension_wrapper.h"
#include "extensions/include/openxr_fb_spatial_entity_extension_wrapper.h"
#include "extensions/include/openxr_fb_spatial_entity_container_extension_wrapper.h"
#include "extensions/include/openxr_fb_spatial_entity_query_extension_wrapper.h"

using namespace godot;

Expand Down Expand Up @@ -81,10 +84,20 @@ void initialize_plugin_module(ModuleInitializationLevel p_level)

case MODULE_INITIALIZATION_LEVEL_EDITOR: {
ClassDB::register_class<OpenXREditorExportPlugin>();

ClassDB::register_class<KhronosEditorExportPlugin>();
ClassDB::register_class<KhronosEditorPlugin>();
EditorPlugins::add_by_type<KhronosEditorPlugin>();

ClassDB::register_class<LynxEditorPlugin>();
EditorPlugins::add_by_type<LynxEditorPlugin>();

ClassDB::register_class<MetaEditorExportPlugin>();
ClassDB::register_class<MetaEditorPlugin>();

EditorPlugins::add_by_type<MetaEditorPlugin>();

ClassDB::register_class<PicoEditorPlugin>();
EditorPlugins::add_by_type<PicoEditorPlugin>();
} break;

case MODULE_INITIALIZATION_LEVEL_MAX:
Expand Down
File renamed without changes.
13 changes: 7 additions & 6 deletions config.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
ext {
versions = [
gradlePluginVersion : '7.4.0',
compileSdk : 33,
gradlePluginVersion : '8.2.0',
compileSdk : 34,
minSdk : 21,
targetSdk : 33,
targetSdk : 34,
javaVersion : JavaVersion.VERSION_17,
nexusPublishVersion : '1.3.0',
kotlinVersion : '1.7.0',
kotlinVersion : '1.9.20',
cmakeVersion : '3.22.1',
ndkVersion : '23.2.8568313'
]

libraries = [
godotAndroidLib: "org.godotengine:godot:4.2.0.stable",
godotAndroidLib: "org.godotengine:godot:4.2.1.stable",
]
}

// Parse the release version from the gradle project properties (e.g: -Prelease_version=<version>)
ext.getReleaseVersion = { ->
final String defaultVersion = "2.1.0-dev-SNAPSHOT"
final String defaultVersion = "3.0.0-dev-SNAPSHOT"

String releaseVersion = project.hasProperty("release_version") ? project.property("release_version") : defaultVersion
if (releaseVersion == null || releaseVersion.isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion demo/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Godot 4+ specific ignores
.godot/
/addons/godotopenxrvendors/*/.bin
/addons/godotopenxrvendors/.bin
/android/
18 changes: 0 additions & 18 deletions demo/addons/godotopenxrvendors/khronos/plugin.gdextension

This file was deleted.

16 changes: 0 additions & 16 deletions demo/addons/godotopenxrvendors/lynx/plugin.gdextension

This file was deleted.

16 changes: 0 additions & 16 deletions demo/addons/godotopenxrvendors/meta/plugin.gdextension

This file was deleted.

16 changes: 0 additions & 16 deletions demo/addons/godotopenxrvendors/pico/plugin.gdextension

This file was deleted.

18 changes: 18 additions & 0 deletions demo/addons/godotopenxrvendors/plugin.gdextension
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[configuration]

entry_symbol = "plugin_library_init"
compatibility_minimum = "4.2"
android_aar_plugin = true

[libraries]

android.debug.arm64 = "res://addons/godotopenxrvendors/.bin/android/template_debug/arm64/libgodotopenxr.so"
android.release.arm64 = "res://addons/godotopenxrvendors/.bin/android/template_release/arm64/libgodotopenxr.so"
android.debug.x86_64 = "res://addons/godotopenxrvendors/.bin/android/template_debug/x86_64/libgodotopenxr.so"
android.release.x86_64 = "res://addons/godotopenxrvendors/.bin/android/template_release/x86_64/libgodotopenxr.so"
macos.debug = "res://addons/godotopenxrvendors/.bin/macos/template_debug/libgodotopenxr.macos.framework"
macos.release = "res://addons/godotopenxrvendors/.bin/macos/template_release/libgodotopenxr.macos.framework"
windows.debug.x86_64 = "res://addons/godotopenxrvendors/.bin/windows/template_debug/x86_64/libgodotopenxr.dll"
windows.release.x86_64 = "res://addons/godotopenxrvendors/.bin/windows/template_release/x86_64/libgodotopenxr.dll"
linux.debug.x86_64 = "res://addons/godotopenxrvendors/.bin/linux/template_debug/x86_64/libgodotopenxr.so"
linux.release.x86_64 = "res://addons/godotopenxrvendors/.bin/linux/template_release/x86_64/libgodotopenxr.so"
Loading

0 comments on commit 8ad906c

Please sign in to comment.