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 3, 2024
1 parent e946c3a commit 70a1f34
Show file tree
Hide file tree
Showing 57 changed files with 276 additions and 685 deletions.
52 changes: 24 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 @@ -131,31 +136,22 @@ jobs:
cp aar/CHANGES.md asset/addons/godotopenxrvendors/GodotOpenXRVendors_CHANGES.md
- name: Adding vendor licences
run: |
mkdir -p asset/addons/godotopenxrvendors/meta/
cp aar/godotopenxrmeta/LICENSE.txt asset/addons/godotopenxrvendors/meta/
mkdir -p asset/addons/godotopenxrvendors/pico/
cp aar/godotopenxrpico/libs/pico_openxr_sdk/arm64-v8a/README.md asset/addons/godotopenxrvendors/pico/LICENSE.md
mkdir -p asset/addons/godotopenxrvendors/khronos/
cp aar/godotopenxrkhronos/LICENSE asset/addons/godotopenxrvendors/khronos/LICENSE
- 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
33 changes: 15 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ devices (e.g: Meta, Pico devices) and access vendor-specific OpenXR extensions

**Note:**

Version `2.x` of this plugin requires **Godot 4.2**.
Version `2.x` and higher of this plugin requires **Godot 4.2**.
Check the [`1.x` branch](https://github.com/GodotVR/godot_openxr_vendors/tree/1.x) and releases
for support on prior versions of Godot 4.

Expand All @@ -18,39 +18,36 @@ git submodule update --init
```

### Building the Godot-CPP bindings
Build the Android C++ bindings using the following commands. To speed up compilation, add `-jN` at
the end of the SCons command line where `N` is the number of CPU threads you have on your system.
The example below uses 4 threads.
Build the Android C++ bindings using the following commands.
```
cd thirdparty/godot-cpp
scons platform=android target=template_debug arch=arm64 -j4
scons platform=android target=template_debug arch=arm32 -j4
scons platform=android target=template_debug arch=x86_64 -j4
scons platform=android target=template_debug arch=x86_32 -j4
scons platform=android target=template_release arch=arm64 -j4
scons platform=android target=template_release arch=arm32 -j4
scons platform=android target=template_release arch=x86_64 -j4
scons platform=android target=template_release arch=x86_32 -j4
scons platform=android target=template_debug arch=arm64
scons platform=android target=template_release arch=arm64
scons platform=android target=template_debug arch=x86_64
scons platform=android target=template_release arch=x86_64
```

When the command is completed, you should have static libraries stored in `thirdparty/godot-cpp/bin`
that will be used for compilation by the plugin.

### Building the Plugin
Run the following command from the root directory to generate the editor gdextension plugin:
```
scons target=template_debug
scons target=template_release
scons target=template_debug platform=android
scons target=template_release platform=android
```

#### Linux / MacOS
Run the following command from the root directory to build the plugin:
Run the following command from the root directory to build the vendors `AAR` Android binaries:
```
scons target=template_debug -j4
scons target=template_release -j4
./gradlew build
```

#### Windows
Run the following command from the root directory to build the plugin:
Run the following command from the root directory to build the vendors `AAR` Android binaries:
```
scons target=template_debug -j4
scons target=template_release -j4
gradlew.bat build
```

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 = 'godotopenxrvendors'

# 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.

Loading

0 comments on commit 70a1f34

Please sign in to comment.