From 2c455caaca36512468c551e4f4336183d8fe89ba Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Thu, 1 Feb 2024 11:09:55 -0800 Subject: [PATCH] Merge GDExtension into a single implementation 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. --- .github/workflows/build-addon-on-push.yml | 55 +++++++------- CHANGES.md | 4 ++ README.md | 33 ++++----- SConstruct | 43 ++++++++--- common/src/main/cpp/export/export_plugin.cpp | 2 +- .../main/cpp/export/khronos_export_plugin.cpp | 0 .../main/cpp/export/khronos_export_plugin.h | 0 .../main/cpp/export/lynx_export_plugin.cpp | 0 .../src/main/cpp/export/lynx_export_plugin.h | 0 .../main/cpp/export/meta_export_plugin.cpp | 0 .../src/main/cpp/export/meta_export_plugin.h | 0 .../main/cpp/export/pico_export_plugin.cpp | 0 .../src/main/cpp/export/pico_export_plugin.h | 0 ...penxr_fb_face_tracking_extension_wrapper.h | 0 ...penxr_fb_scene_capture_extension_wrapper.h | 1 - .../openxr_fb_scene_extension_wrapper.h | 1 - ...atial_entity_container_extension_wrapper.h | 1 - ...enxr_fb_spatial_entity_extension_wrapper.h | 1 - ...b_spatial_entity_query_extension_wrapper.h | 2 - ...nxr_fb_face_tracking_extension_wrapper.cpp | 0 ...nxr_fb_scene_capture_extension_wrapper.cpp | 0 .../openxr_fb_scene_extension_wrapper.cpp | 11 ++- ...ial_entity_container_extension_wrapper.cpp | 0 ...xr_fb_spatial_entity_extension_wrapper.cpp | 0 ...spatial_entity_query_extension_wrapper.cpp | 0 .../src/main/cpp/register_types.cpp | 29 +++++--- .../src/main/cpp/register_types.h | 0 config.gradle | 13 ++-- demo/.gitignore | 2 +- .../khronos/plugin.gdextension | 18 ----- .../lynx/plugin.gdextension | 16 ----- .../meta/plugin.gdextension | 16 ----- .../pico/plugin.gdextension | 16 ----- .../godotopenxrvendors/plugin.gdextension | 18 +++++ godotopenxrkhronos/CMakeLists.txt | 4 +- godotopenxrkhronos/SConstruct | 48 ------------- godotopenxrkhronos/build.gradle | 26 ++++++- godotopenxrkhronos/src/main/assets/.gitignore | 2 + .../src/main/cpp/register_types.cpp | 72 ------------------- .../vendors/khronos/GodotOpenXRKhronos.kt | 16 +++++ godotopenxrlynx/CMakeLists.txt | 4 +- godotopenxrlynx/SConstruct | 48 ------------- godotopenxrlynx/build.gradle | 25 ++++++- godotopenxrlynx/src/main/assets/.gitignore | 2 + .../src/main/cpp/register_types.cpp | 71 ------------------ godotopenxrlynx/src/main/cpp/register_types.h | 37 ---------- .../openxr/vendors/lynx/GodotOpenXRLynx.kt | 16 +++++ godotopenxrmeta/CMakeLists.txt | 4 +- godotopenxrmeta/SConstruct | 50 ------------- godotopenxrmeta/build.gradle | 13 ++-- godotopenxrmeta/src/main/cpp/register_types.h | 37 ---------- .../openxr/vendors/meta/GodotOpenXRMeta.kt | 8 +-- godotopenxrpico/CMakeLists.txt | 4 +- godotopenxrpico/SConstruct | 48 ------------- godotopenxrpico/build.gradle | 25 ++++++- godotopenxrpico/src/main/assets/.gitignore | 2 + .../src/main/cpp/register_types.cpp | 71 ------------------ godotopenxrpico/src/main/cpp/register_types.h | 37 ---------- .../openxr/vendors/pico/GodotOpenXRPico.kt | 16 +++++ gradle/wrapper/gradle-wrapper.properties | 2 +- 60 files changed, 286 insertions(+), 684 deletions(-) rename {godotopenxrkhronos => common}/src/main/cpp/export/khronos_export_plugin.cpp (100%) rename {godotopenxrkhronos => common}/src/main/cpp/export/khronos_export_plugin.h (100%) rename {godotopenxrlynx => common}/src/main/cpp/export/lynx_export_plugin.cpp (100%) rename {godotopenxrlynx => common}/src/main/cpp/export/lynx_export_plugin.h (100%) rename {godotopenxrmeta => common}/src/main/cpp/export/meta_export_plugin.cpp (100%) rename {godotopenxrmeta => common}/src/main/cpp/export/meta_export_plugin.h (100%) rename {godotopenxrpico => common}/src/main/cpp/export/pico_export_plugin.cpp (100%) rename {godotopenxrpico => common}/src/main/cpp/export/pico_export_plugin.h (100%) rename {godotopenxrmeta/src/main/cpp => common/src/main/cpp/extensions}/include/openxr_fb_face_tracking_extension_wrapper.h (100%) rename {godotopenxrmeta/src/main/cpp => common/src/main/cpp/extensions}/include/openxr_fb_scene_capture_extension_wrapper.h (99%) rename {godotopenxrmeta/src/main/cpp => common/src/main/cpp/extensions}/include/openxr_fb_scene_extension_wrapper.h (99%) rename {godotopenxrmeta/src/main/cpp => common/src/main/cpp/extensions}/include/openxr_fb_spatial_entity_container_extension_wrapper.h (98%) rename {godotopenxrmeta/src/main/cpp => common/src/main/cpp/extensions}/include/openxr_fb_spatial_entity_extension_wrapper.h (99%) rename {godotopenxrmeta/src/main/cpp => common/src/main/cpp/extensions}/include/openxr_fb_spatial_entity_query_extension_wrapper.h (98%) rename {godotopenxrmeta/src/main/cpp => common/src/main/cpp/extensions}/openxr_fb_face_tracking_extension_wrapper.cpp (100%) rename {godotopenxrmeta/src/main/cpp => common/src/main/cpp/extensions}/openxr_fb_scene_capture_extension_wrapper.cpp (100%) rename {godotopenxrmeta/src/main/cpp => common/src/main/cpp/extensions}/openxr_fb_scene_extension_wrapper.cpp (95%) rename {godotopenxrmeta/src/main/cpp => common/src/main/cpp/extensions}/openxr_fb_spatial_entity_container_extension_wrapper.cpp (100%) rename {godotopenxrmeta/src/main/cpp => common/src/main/cpp/extensions}/openxr_fb_spatial_entity_extension_wrapper.cpp (100%) rename {godotopenxrmeta/src/main/cpp => common/src/main/cpp/extensions}/openxr_fb_spatial_entity_query_extension_wrapper.cpp (100%) rename {godotopenxrmeta => common}/src/main/cpp/register_types.cpp (85%) rename {godotopenxrkhronos => common}/src/main/cpp/register_types.h (100%) delete mode 100644 demo/addons/godotopenxrvendors/khronos/plugin.gdextension delete mode 100644 demo/addons/godotopenxrvendors/lynx/plugin.gdextension delete mode 100644 demo/addons/godotopenxrvendors/meta/plugin.gdextension delete mode 100644 demo/addons/godotopenxrvendors/pico/plugin.gdextension create mode 100644 demo/addons/godotopenxrvendors/plugin.gdextension delete mode 100644 godotopenxrkhronos/SConstruct create mode 100644 godotopenxrkhronos/src/main/assets/.gitignore delete mode 100644 godotopenxrkhronos/src/main/cpp/register_types.cpp delete mode 100644 godotopenxrlynx/SConstruct create mode 100644 godotopenxrlynx/src/main/assets/.gitignore delete mode 100644 godotopenxrlynx/src/main/cpp/register_types.cpp delete mode 100644 godotopenxrlynx/src/main/cpp/register_types.h delete mode 100644 godotopenxrmeta/SConstruct delete mode 100644 godotopenxrmeta/src/main/cpp/register_types.h delete mode 100644 godotopenxrpico/SConstruct create mode 100644 godotopenxrpico/src/main/assets/.gitignore delete mode 100644 godotopenxrpico/src/main/cpp/register_types.cpp delete mode 100644 godotopenxrpico/src/main/cpp/register_types.h diff --git a/.github/workflows/build-addon-on-push.yml b/.github/workflows/build-addon-on-push.yml index 105359b1..727195e1 100644 --- a/.github/workflows/build-addon-on-push.yml +++ b/.github/workflows/build-addon-on-push.yml @@ -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 @@ -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 @@ -131,31 +136,29 @@ 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/ + mkdir -p asset/addons/godotopenxrvendors/.bin/android/ + cp -r build-files-android-aar/* asset/addons/godotopenxrvendors/.bin/android/ + cp -r build-files-android-so/* asset/addons/godotopenxrvendors/.bin/android/ + + mkdir -p asset/addons/godotopenxrvendors/.bin/linux/ + cp -r build-files-linux-x86_64/* asset/addons/godotopenxrvendors/.bin/linux/ - 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/ + mkdir -p asset/addons/godotopenxrvendors/.bin/windows/ + cp -r build-files-windows/* asset/addons/godotopenxrvendors/.bin/windows/ - 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/ + mkdir -p asset/addons/godotopenxrvendors/.bin/macos/ + cp -r build-files-macos/* asset/addons/godotopenxrvendors/.bin/macos/ - name: Create Godot OpenXR Vendor addon artifact uses: actions/upload-artifact@v3 diff --git a/CHANGES.md b/CHANGES.md index 10157ff6..1f3b0410 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Change history for the Godot OpenXR loaders asset +## 3.0.0 +- Merge GDExtension into a single implementation +- Upgrade Android, Gradle, Godot and Kotlin dependencies + ## 2.0.3 - Migrate the export scripts from gdscript to C++ via gdextension - Manually request eye tracking permission if it's included in the app manifest diff --git a/README.md b/README.md index 6d397ca0..ea0c1b6f 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 ``` diff --git a/SConstruct b/SConstruct index 9bf5d365..bb1d8ff5 100644 --- a/SConstruct +++ b/SConstruct @@ -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) + diff --git a/common/src/main/cpp/export/export_plugin.cpp b/common/src/main/cpp/export/export_plugin.cpp index b8d92ee1..1d620d98 100644 --- a/common/src/main/cpp/export/export_plugin.cpp +++ b/common/src/main/cpp/export/export_plugin.cpp @@ -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 { diff --git a/godotopenxrkhronos/src/main/cpp/export/khronos_export_plugin.cpp b/common/src/main/cpp/export/khronos_export_plugin.cpp similarity index 100% rename from godotopenxrkhronos/src/main/cpp/export/khronos_export_plugin.cpp rename to common/src/main/cpp/export/khronos_export_plugin.cpp diff --git a/godotopenxrkhronos/src/main/cpp/export/khronos_export_plugin.h b/common/src/main/cpp/export/khronos_export_plugin.h similarity index 100% rename from godotopenxrkhronos/src/main/cpp/export/khronos_export_plugin.h rename to common/src/main/cpp/export/khronos_export_plugin.h diff --git a/godotopenxrlynx/src/main/cpp/export/lynx_export_plugin.cpp b/common/src/main/cpp/export/lynx_export_plugin.cpp similarity index 100% rename from godotopenxrlynx/src/main/cpp/export/lynx_export_plugin.cpp rename to common/src/main/cpp/export/lynx_export_plugin.cpp diff --git a/godotopenxrlynx/src/main/cpp/export/lynx_export_plugin.h b/common/src/main/cpp/export/lynx_export_plugin.h similarity index 100% rename from godotopenxrlynx/src/main/cpp/export/lynx_export_plugin.h rename to common/src/main/cpp/export/lynx_export_plugin.h diff --git a/godotopenxrmeta/src/main/cpp/export/meta_export_plugin.cpp b/common/src/main/cpp/export/meta_export_plugin.cpp similarity index 100% rename from godotopenxrmeta/src/main/cpp/export/meta_export_plugin.cpp rename to common/src/main/cpp/export/meta_export_plugin.cpp diff --git a/godotopenxrmeta/src/main/cpp/export/meta_export_plugin.h b/common/src/main/cpp/export/meta_export_plugin.h similarity index 100% rename from godotopenxrmeta/src/main/cpp/export/meta_export_plugin.h rename to common/src/main/cpp/export/meta_export_plugin.h diff --git a/godotopenxrpico/src/main/cpp/export/pico_export_plugin.cpp b/common/src/main/cpp/export/pico_export_plugin.cpp similarity index 100% rename from godotopenxrpico/src/main/cpp/export/pico_export_plugin.cpp rename to common/src/main/cpp/export/pico_export_plugin.cpp diff --git a/godotopenxrpico/src/main/cpp/export/pico_export_plugin.h b/common/src/main/cpp/export/pico_export_plugin.h similarity index 100% rename from godotopenxrpico/src/main/cpp/export/pico_export_plugin.h rename to common/src/main/cpp/export/pico_export_plugin.h diff --git a/godotopenxrmeta/src/main/cpp/include/openxr_fb_face_tracking_extension_wrapper.h b/common/src/main/cpp/extensions/include/openxr_fb_face_tracking_extension_wrapper.h similarity index 100% rename from godotopenxrmeta/src/main/cpp/include/openxr_fb_face_tracking_extension_wrapper.h rename to common/src/main/cpp/extensions/include/openxr_fb_face_tracking_extension_wrapper.h diff --git a/godotopenxrmeta/src/main/cpp/include/openxr_fb_scene_capture_extension_wrapper.h b/common/src/main/cpp/extensions/include/openxr_fb_scene_capture_extension_wrapper.h similarity index 99% rename from godotopenxrmeta/src/main/cpp/include/openxr_fb_scene_capture_extension_wrapper.h rename to common/src/main/cpp/extensions/include/openxr_fb_scene_capture_extension_wrapper.h index 5bb07558..a7c1f34c 100644 --- a/godotopenxrmeta/src/main/cpp/include/openxr_fb_scene_capture_extension_wrapper.h +++ b/common/src/main/cpp/extensions/include/openxr_fb_scene_capture_extension_wrapper.h @@ -35,7 +35,6 @@ #include #include -#include #include #include "util.h" diff --git a/godotopenxrmeta/src/main/cpp/include/openxr_fb_scene_extension_wrapper.h b/common/src/main/cpp/extensions/include/openxr_fb_scene_extension_wrapper.h similarity index 99% rename from godotopenxrmeta/src/main/cpp/include/openxr_fb_scene_extension_wrapper.h rename to common/src/main/cpp/extensions/include/openxr_fb_scene_extension_wrapper.h index 1a08360d..48372860 100644 --- a/godotopenxrmeta/src/main/cpp/include/openxr_fb_scene_extension_wrapper.h +++ b/common/src/main/cpp/extensions/include/openxr_fb_scene_extension_wrapper.h @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/godotopenxrmeta/src/main/cpp/include/openxr_fb_spatial_entity_container_extension_wrapper.h b/common/src/main/cpp/extensions/include/openxr_fb_spatial_entity_container_extension_wrapper.h similarity index 98% rename from godotopenxrmeta/src/main/cpp/include/openxr_fb_spatial_entity_container_extension_wrapper.h rename to common/src/main/cpp/extensions/include/openxr_fb_spatial_entity_container_extension_wrapper.h index 1748babf..da1f5678 100644 --- a/godotopenxrmeta/src/main/cpp/include/openxr_fb_spatial_entity_container_extension_wrapper.h +++ b/common/src/main/cpp/extensions/include/openxr_fb_spatial_entity_container_extension_wrapper.h @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/godotopenxrmeta/src/main/cpp/include/openxr_fb_spatial_entity_extension_wrapper.h b/common/src/main/cpp/extensions/include/openxr_fb_spatial_entity_extension_wrapper.h similarity index 99% rename from godotopenxrmeta/src/main/cpp/include/openxr_fb_spatial_entity_extension_wrapper.h rename to common/src/main/cpp/extensions/include/openxr_fb_spatial_entity_extension_wrapper.h index d50aa100..fd6791e9 100644 --- a/godotopenxrmeta/src/main/cpp/include/openxr_fb_spatial_entity_extension_wrapper.h +++ b/common/src/main/cpp/extensions/include/openxr_fb_spatial_entity_extension_wrapper.h @@ -31,7 +31,6 @@ #include #include -#include #include #include diff --git a/godotopenxrmeta/src/main/cpp/include/openxr_fb_spatial_entity_query_extension_wrapper.h b/common/src/main/cpp/extensions/include/openxr_fb_spatial_entity_query_extension_wrapper.h similarity index 98% rename from godotopenxrmeta/src/main/cpp/include/openxr_fb_spatial_entity_query_extension_wrapper.h rename to common/src/main/cpp/extensions/include/openxr_fb_spatial_entity_query_extension_wrapper.h index f0b08ec6..8cfe7250 100644 --- a/godotopenxrmeta/src/main/cpp/include/openxr_fb_spatial_entity_query_extension_wrapper.h +++ b/common/src/main/cpp/extensions/include/openxr_fb_spatial_entity_query_extension_wrapper.h @@ -31,8 +31,6 @@ #include #include -#include -#include #include #include #include diff --git a/godotopenxrmeta/src/main/cpp/openxr_fb_face_tracking_extension_wrapper.cpp b/common/src/main/cpp/extensions/openxr_fb_face_tracking_extension_wrapper.cpp similarity index 100% rename from godotopenxrmeta/src/main/cpp/openxr_fb_face_tracking_extension_wrapper.cpp rename to common/src/main/cpp/extensions/openxr_fb_face_tracking_extension_wrapper.cpp diff --git a/godotopenxrmeta/src/main/cpp/openxr_fb_scene_capture_extension_wrapper.cpp b/common/src/main/cpp/extensions/openxr_fb_scene_capture_extension_wrapper.cpp similarity index 100% rename from godotopenxrmeta/src/main/cpp/openxr_fb_scene_capture_extension_wrapper.cpp rename to common/src/main/cpp/extensions/openxr_fb_scene_capture_extension_wrapper.cpp diff --git a/godotopenxrmeta/src/main/cpp/openxr_fb_scene_extension_wrapper.cpp b/common/src/main/cpp/extensions/openxr_fb_scene_extension_wrapper.cpp similarity index 95% rename from godotopenxrmeta/src/main/cpp/openxr_fb_scene_extension_wrapper.cpp rename to common/src/main/cpp/extensions/openxr_fb_scene_extension_wrapper.cpp index 7e28cda5..3aaa66f1 100644 --- a/godotopenxrmeta/src/main/cpp/openxr_fb_scene_extension_wrapper.cpp +++ b/common/src/main/cpp/extensions/openxr_fb_scene_extension_wrapper.cpp @@ -33,6 +33,10 @@ #include #include +#ifdef META_VENDOR_ENABLED +#include +#endif + #include "include/openxr_fb_spatial_entity_extension_wrapper.h" using namespace godot; @@ -97,11 +101,14 @@ std::optional 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(), }; diff --git a/godotopenxrmeta/src/main/cpp/openxr_fb_spatial_entity_container_extension_wrapper.cpp b/common/src/main/cpp/extensions/openxr_fb_spatial_entity_container_extension_wrapper.cpp similarity index 100% rename from godotopenxrmeta/src/main/cpp/openxr_fb_spatial_entity_container_extension_wrapper.cpp rename to common/src/main/cpp/extensions/openxr_fb_spatial_entity_container_extension_wrapper.cpp diff --git a/godotopenxrmeta/src/main/cpp/openxr_fb_spatial_entity_extension_wrapper.cpp b/common/src/main/cpp/extensions/openxr_fb_spatial_entity_extension_wrapper.cpp similarity index 100% rename from godotopenxrmeta/src/main/cpp/openxr_fb_spatial_entity_extension_wrapper.cpp rename to common/src/main/cpp/extensions/openxr_fb_spatial_entity_extension_wrapper.cpp diff --git a/godotopenxrmeta/src/main/cpp/openxr_fb_spatial_entity_query_extension_wrapper.cpp b/common/src/main/cpp/extensions/openxr_fb_spatial_entity_query_extension_wrapper.cpp similarity index 100% rename from godotopenxrmeta/src/main/cpp/openxr_fb_spatial_entity_query_extension_wrapper.cpp rename to common/src/main/cpp/extensions/openxr_fb_spatial_entity_query_extension_wrapper.cpp diff --git a/godotopenxrmeta/src/main/cpp/register_types.cpp b/common/src/main/cpp/register_types.cpp similarity index 85% rename from godotopenxrmeta/src/main/cpp/register_types.cpp rename to common/src/main/cpp/register_types.cpp index 288d7ddd..2e695c61 100644 --- a/godotopenxrmeta/src/main/cpp/register_types.cpp +++ b/common/src/main/cpp/register_types.cpp @@ -37,15 +37,18 @@ #include #include -#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 "include/openxr_fb_face_tracking_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_face_tracking_extension_wrapper.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; @@ -86,10 +89,20 @@ void initialize_plugin_module(ModuleInitializationLevel p_level) case MODULE_INITIALIZATION_LEVEL_EDITOR: { ClassDB::register_class(); + + ClassDB::register_class(); + ClassDB::register_class(); + EditorPlugins::add_by_type(); + + ClassDB::register_class(); + EditorPlugins::add_by_type(); + ClassDB::register_class(); ClassDB::register_class(); - EditorPlugins::add_by_type(); + + ClassDB::register_class(); + EditorPlugins::add_by_type(); } break; case MODULE_INITIALIZATION_LEVEL_MAX: diff --git a/godotopenxrkhronos/src/main/cpp/register_types.h b/common/src/main/cpp/register_types.h similarity index 100% rename from godotopenxrkhronos/src/main/cpp/register_types.h rename to common/src/main/cpp/register_types.h diff --git a/config.gradle b/config.gradle index 3a6e524c..66b2183a 100644 --- a/config.gradle +++ b/config.gradle @@ -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=) 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()) { diff --git a/demo/.gitignore b/demo/.gitignore index 443378c0..2eb102db 100644 --- a/demo/.gitignore +++ b/demo/.gitignore @@ -1,4 +1,4 @@ # Godot 4+ specific ignores .godot/ -/addons/godotopenxrvendors/*/.bin +/addons/godotopenxrvendors/.bin /android/ diff --git a/demo/addons/godotopenxrvendors/khronos/plugin.gdextension b/demo/addons/godotopenxrvendors/khronos/plugin.gdextension deleted file mode 100644 index e5a424d3..00000000 --- a/demo/addons/godotopenxrvendors/khronos/plugin.gdextension +++ /dev/null @@ -1,18 +0,0 @@ -[configuration] - -entry_symbol = "plugin_library_init" -compatibility_minimum = "4.2" -android_aar_plugin = true - -[libraries] - -android.debug.arm64 = "res://addons/godotopenxrvendors/khronos/.bin/debug/arm64-v8a/libgodotopenxrkhronos.so" -android.release.arm64 = "res://addons/godotopenxrvendors/khronos/.bin/release/arm64-v8a/libgodotopenxrkhronos.so" -android.debug.x86_64 = "res://addons/godotopenxrvendors/khronos/.bin/debug/x86_64/libgodotopenxrkhronos.so" -android.release.x86_64 = "res://addons/godotopenxrvendors/khronos/.bin/release/x86_64/libgodotopenxrkhronos.so" -macos.debug = "res://addons/godotopenxrvendors/khronos/.bin/libgodotopenxrkhronos.macos.template_debug.framework" -macos.release = "res://addons/godotopenxrvendors/khronos/.bin/libgodotopenxrkhronos.macos.template_release.framework" -windows.debug.x86_64 = "res://addons/godotopenxrvendors/khronos/.bin/libgodotopenxrkhronos.windows.template_debug.x86_64.dll" -windows.release.x86_64 = "res://addons/godotopenxrvendors/khronos/.bin/libgodotopenxrkhronos.windows.template_release.x86_64.dll" -linux.debug.x86_64 = "res://addons/godotopenxrvendors/khronos/.bin/libgodotopenxrkhronos.linux.template_debug.x86_64.so" -linux.release.x86_64 = "res://addons/godotopenxrvendors/khronos/.bin/libgodotopenxrkhronos.linux.template_release.x86_64.so" diff --git a/demo/addons/godotopenxrvendors/lynx/plugin.gdextension b/demo/addons/godotopenxrvendors/lynx/plugin.gdextension deleted file mode 100644 index 6bb83da9..00000000 --- a/demo/addons/godotopenxrvendors/lynx/plugin.gdextension +++ /dev/null @@ -1,16 +0,0 @@ -[configuration] - -entry_symbol = "plugin_library_init" -compatibility_minimum = "4.2" -android_aar_plugin = true - -[libraries] - -android.debug.arm64 = "res://addons/godotopenxrvendors/lynx/.bin/debug/arm64-v8a/libgodotopenxrlynx.so" -android.release.arm64 = "res://addons/godotopenxrvendors/lynx/.bin/release/arm64-v8a/libgodotopenxrlynx.so" -macos.debug = "res://addons/godotopenxrvendors/lynx/.bin/libgodotopenxrlynx.macos.template_debug.framework" -macos.release = "res://addons/godotopenxrvendors/lynx/.bin/libgodotopenxrlynx.macos.template_release.framework" -windows.debug.x86_64 = "res://addons/godotopenxrvendors/lynx/.bin/libgodotopenxrlynx.windows.template_debug.x86_64.dll" -windows.release.x86_64 = "res://addons/godotopenxrvendors/lynx/.bin/libgodotopenxrlynx.windows.template_release.x86_64.dll" -linux.debug.x86_64 = "res://addons/godotopenxrvendors/lynx/.bin/libgodotopenxrlynx.linux.template_debug.x86_64.so" -linux.release.x86_64 = "res://addons/godotopenxrvendors/lynx/.bin/libgodotopenxrlynx.linux.template_release.x86_64.so" diff --git a/demo/addons/godotopenxrvendors/meta/plugin.gdextension b/demo/addons/godotopenxrvendors/meta/plugin.gdextension deleted file mode 100644 index 8055b2fc..00000000 --- a/demo/addons/godotopenxrvendors/meta/plugin.gdextension +++ /dev/null @@ -1,16 +0,0 @@ -[configuration] - -entry_symbol = "plugin_library_init" -compatibility_minimum = "4.2" -android_aar_plugin = true - -[libraries] - -android.debug.arm64 = "res://addons/godotopenxrvendors/meta/.bin/debug/arm64-v8a/libgodotopenxrmeta.so" -android.release.arm64 = "res://addons/godotopenxrvendors/meta/.bin/release/arm64-v8a/libgodotopenxrmeta.so" -macos.debug = "res://addons/godotopenxrvendors/meta/.bin/libgodotopenxrmeta.macos.template_debug.framework" -macos.release = "res://addons/godotopenxrvendors/meta/.bin/libgodotopenxrmeta.macos.template_release.framework" -windows.debug.x86_64 = "res://addons/godotopenxrvendors/meta/.bin/libgodotopenxrmeta.windows.template_debug.x86_64.dll" -windows.release.x86_64 = "res://addons/godotopenxrvendors/meta/.bin/libgodotopenxrmeta.windows.template_release.x86_64.dll" -linux.debug.x86_64 = "res://addons/godotopenxrvendors/meta/.bin/libgodotopenxrmeta.linux.template_debug.x86_64.so" -linux.release.x86_64 = "res://addons/godotopenxrvendors/meta/.bin/libgodotopenxrmeta.linux.template_release.x86_64.so" diff --git a/demo/addons/godotopenxrvendors/pico/plugin.gdextension b/demo/addons/godotopenxrvendors/pico/plugin.gdextension deleted file mode 100644 index 4d5117b0..00000000 --- a/demo/addons/godotopenxrvendors/pico/plugin.gdextension +++ /dev/null @@ -1,16 +0,0 @@ -[configuration] - -entry_symbol = "plugin_library_init" -compatibility_minimum = "4.2" -android_aar_plugin = true - -[libraries] - -android.debug.arm64 = "res://addons/godotopenxrvendors/pico/.bin/debug/arm64-v8a/libgodotopenxrpico.so" -android.release.arm64 = "res://addons/godotopenxrvendors/pico/.bin/release/arm64-v8a/libgodotopenxrpico.so" -macos.debug = "res://addons/godotopenxrvendors/pico/.bin/libgodotopenxrpico.macos.template_debug.framework" -macos.release = "res://addons/godotopenxrvendors/pico/.bin/libgodotopenxrpico.macos.template_release.framework" -windows.debug.x86_64 = "res://addons/godotopenxrvendors/pico/.bin/libgodotopenxrpico.windows.template_debug.x86_64.dll" -windows.release.x86_64 = "res://addons/godotopenxrvendors/pico/.bin/libgodotopenxrpico.windows.template_release.x86_64.dll" -linux.debug.x86_64 = "res://addons/godotopenxrvendors/pico/.bin/libgodotopenxrpico.linux.template_debug.x86_64.so" -linux.release.x86_64 = "res://addons/godotopenxrvendors/pico/.bin/libgodotopenxrpico.linux.template_release.x86_64.so" diff --git a/demo/addons/godotopenxrvendors/plugin.gdextension b/demo/addons/godotopenxrvendors/plugin.gdextension new file mode 100644 index 00000000..12a5b8da --- /dev/null +++ b/demo/addons/godotopenxrvendors/plugin.gdextension @@ -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/libgodotopenxrvendors.so" +android.release.arm64 = "res://addons/godotopenxrvendors/.bin/android/template_release/arm64/libgodotopenxrvendors.so" +android.debug.x86_64 = "res://addons/godotopenxrvendors/.bin/android/template_debug/x86_64/libgodotopenxrvendors.so" +android.release.x86_64 = "res://addons/godotopenxrvendors/.bin/android/template_release/x86_64/libgodotopenxrvendors.so" +macos.debug = "res://addons/godotopenxrvendors/.bin/macos/template_debug/libgodotopenxrvendors.macos.framework" +macos.release = "res://addons/godotopenxrvendors/.bin/macos/template_release/libgodotopenxrvendors.macos.framework" +windows.debug.x86_64 = "res://addons/godotopenxrvendors/.bin/windows/template_debug/x86_64/libgodotopenxrvendors.dll" +windows.release.x86_64 = "res://addons/godotopenxrvendors/.bin/windows/template_release/x86_64/libgodotopenxrvendors.dll" +linux.debug.x86_64 = "res://addons/godotopenxrvendors/.bin/linux/template_debug/x86_64/libgodotopenxrvendors.so" +linux.release.x86_64 = "res://addons/godotopenxrvendors/.bin/linux/template_release/x86_64/libgodotopenxrvendors.so" diff --git a/godotopenxrkhronos/CMakeLists.txt b/godotopenxrkhronos/CMakeLists.txt index b8fb8525..94d26d1f 100644 --- a/godotopenxrkhronos/CMakeLists.txt +++ b/godotopenxrkhronos/CMakeLists.txt @@ -5,7 +5,7 @@ include(${CMAKE_SOURCE_DIR}/../common/CMakeLists.txt) ## Project definition -project(godotopenxrkhronos LANGUAGES CXX) +project(godotopenxrvendors LANGUAGES CXX) ## khronos OpenXR loader library set(KHRONOS_OPENXR_LIB_PATH "${CMAKE_SOURCE_DIR}/libs/khronos_openxr_sdk/${ANDROID_ABI}/libopenxr_loader.so") @@ -44,3 +44,5 @@ target_link_libraries(${CMAKE_PROJECT_NAME} # Add the compile flags set_property(TARGET ${CMAKE_PROJECT_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${GODOT_COMPILE_FLAGS}) set_property(TARGET ${CMAKE_PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS ${GODOT_LINKER_FLAGS}) + +add_definitions(-DKHRONOS_VENDOR_ENABLED) diff --git a/godotopenxrkhronos/SConstruct b/godotopenxrkhronos/SConstruct deleted file mode 100644 index c77ab709..00000000 --- a/godotopenxrkhronos/SConstruct +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -from glob import glob -from pathlib import Path - -Import("env", "common_objects") - -env_khronos = env.Clone() - -env_khronos.Append(CPPPATH=[ - "src/main/cpp", - ]) - -# Source files -sources = common_objects.copy() -sources += Glob("src/main/cpp/*.cpp") -sources += Glob("src/main/cpp/export/*.cpp") - -binary_path = '#demo/addons/godotopenxrvendors/khronos/.bin' -project_name = 'godotopenxrkhronos' - -# Create the library target -if env_khronos["platform"] == "android": - print("Use gradle to generate the Android binaries") - Exit(255) -elif env_khronos["platform"] == "macos": - library = env_khronos.SharedLibrary( - "{0}/lib{1}.{2}.{3}.framework/{1}.{2}.{3}".format( - binary_path, - project_name, - env_khronos["platform"], - env_khronos["target"], - ), - source=sources, - ) -else: - library = env_khronos.SharedLibrary( - "{}/lib{}.{}.{}.{}{}".format( - binary_path, - project_name, - env_khronos["platform"], - env_khronos["target"], - env_khronos["arch"], - env_khronos["SHLIBSUFFIX"], - ), - source=sources, - ) - -Default(library) diff --git a/godotopenxrkhronos/build.gradle b/godotopenxrkhronos/build.gradle index af62b419..b4247013 100644 --- a/godotopenxrkhronos/build.gradle +++ b/godotopenxrkhronos/build.gradle @@ -3,7 +3,6 @@ plugins { id 'org.jetbrains.kotlin.android' } - ext { PUBLISH_ARTIFACT_ID = 'godot-openxr-vendors-khronos' } @@ -12,6 +11,7 @@ apply from: "../scripts/publish-module.gradle" android { compileSdk versions.compileSdk + ndkVersion versions.ndkVersion defaultConfig { minSdk versions.minSdk @@ -51,6 +51,16 @@ android { withJavadocJar() } } + + buildFeatures { + prefabPublishing true + } + + prefab { + godotopenxrvendors { + headers "../common/src/main/cpp/extensions/include" + } + } } dependencies { @@ -60,14 +70,24 @@ dependencies { task copyDebugAARToAddons(type: Copy) { from 'build/outputs/aar' include 'godotopenxrkhronos-debug.aar' - into '../demo/addons/godotopenxrvendors/khronos/.bin/debug' + into '../demo/addons/godotopenxrvendors/.bin/android/debug' } task copyReleaseAARToAddons(type: Copy) { from 'build/outputs/aar' include 'godotopenxrkhronos-release.aar' - into '../demo/addons/godotopenxrvendors/khronos/.bin/release' + into '../demo/addons/godotopenxrvendors/.bin/android/release' +} + +task copyGdExtensionConfigToAssets(type: Copy) { + description 'Copy plugin.gdextension from the addons directory to the assets directory' + + from '../demo/addons/godotopenxrvendors/' + include 'plugin.gdextension' + into 'src/main/assets/addons/godotopenxrvendors/' } +preBuild.dependsOn(copyGdExtensionConfigToAssets) +assemble.dependsOn(copyGdExtensionConfigToAssets) assemble.finalizedBy(copyDebugAARToAddons) assemble.finalizedBy(copyReleaseAARToAddons) diff --git a/godotopenxrkhronos/src/main/assets/.gitignore b/godotopenxrkhronos/src/main/assets/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/godotopenxrkhronos/src/main/assets/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/godotopenxrkhronos/src/main/cpp/register_types.cpp b/godotopenxrkhronos/src/main/cpp/register_types.cpp deleted file mode 100644 index 50fd8ac6..00000000 --- a/godotopenxrkhronos/src/main/cpp/register_types.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************/ -/* register_types.cpp */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT XR */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2022-present Godot XR contributors (see CONTRIBUTORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#include "register_types.h" - -#include - -#include -#include -#include -#include - -#include "export/export_plugin.h" -#include "export/khronos_export_plugin.h" - -using namespace godot; - -void initialize_plugin_module(ModuleInitializationLevel p_level) { - switch (p_level) { - case MODULE_INITIALIZATION_LEVEL_EDITOR: { - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - - EditorPlugins::add_by_type(); - } break; - } -} - -void terminate_plugin_module(ModuleInitializationLevel p_level) -{ -} - -extern "C" -{ -GDExtensionBool GDE_EXPORT plugin_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) -{ - godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); - - init_obj.register_initializer(initialize_plugin_module); - init_obj.register_terminator(terminate_plugin_module); - init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_EDITOR); - - return init_obj.init(); -} -} diff --git a/godotopenxrkhronos/src/main/java/org/godotengine/openxr/vendors/khronos/GodotOpenXRKhronos.kt b/godotopenxrkhronos/src/main/java/org/godotengine/openxr/vendors/khronos/GodotOpenXRKhronos.kt index a965f948..60749ad8 100644 --- a/godotopenxrkhronos/src/main/java/org/godotengine/openxr/vendors/khronos/GodotOpenXRKhronos.kt +++ b/godotopenxrkhronos/src/main/java/org/godotengine/openxr/vendors/khronos/GodotOpenXRKhronos.kt @@ -29,6 +29,7 @@ package org.godotengine.openxr.vendors.khronos +import android.util.Log import org.godotengine.godot.Godot import org.godotengine.godot.plugin.GodotPlugin @@ -49,6 +50,21 @@ import org.godotengine.godot.plugin.GodotPlugin * */ class GodotOpenXRKhronos(godot: Godot?) : GodotPlugin(godot) { + companion object { + private val TAG = GodotOpenXRKhronos::class.java.simpleName + + init { + try { + Log.v(TAG, "Loading godotopenxrvendors library") + System.loadLibrary("godotopenxrvendors") + } catch (e: UnsatisfiedLinkError) { + Log.e(TAG, "Unable to load godotopenxrvendors shared library") + } + } + } + + override fun getPluginGDExtensionLibrariesPaths() = setOf("res://addons/godotopenxrvendors/plugin.gdextension") + override fun getPluginName(): String { return "GodotOpenXRKhronos" } diff --git a/godotopenxrlynx/CMakeLists.txt b/godotopenxrlynx/CMakeLists.txt index e86578dd..d35dd8b2 100644 --- a/godotopenxrlynx/CMakeLists.txt +++ b/godotopenxrlynx/CMakeLists.txt @@ -5,7 +5,7 @@ include(${CMAKE_SOURCE_DIR}/../common/CMakeLists.txt) ## Project definition -project(godotopenxrlynx LANGUAGES CXX) +project(godotopenxrvendors LANGUAGES CXX) ## lynx OpenXR loader library set(LYNX_OPENXR_LIB_PATH "${CMAKE_SOURCE_DIR}/libs/lynx_openxr_sdk/${ANDROID_ABI}/libopenxr_loader.so") @@ -44,3 +44,5 @@ target_link_libraries(${CMAKE_PROJECT_NAME} # Add the compile flags set_property(TARGET ${CMAKE_PROJECT_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${GODOT_COMPILE_FLAGS}) set_property(TARGET ${CMAKE_PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS ${GODOT_LINKER_FLAGS}) + +add_definitions(-DLYNX_VENDOR_ENABLED) diff --git a/godotopenxrlynx/SConstruct b/godotopenxrlynx/SConstruct deleted file mode 100644 index 917f9bef..00000000 --- a/godotopenxrlynx/SConstruct +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -from glob import glob -from pathlib import Path - -Import("env", "common_objects") - -env_lynx = env.Clone() - -env_lynx.Append(CPPPATH=[ - "src/main/cpp", - ]) - -# Source files -sources = common_objects.copy() -sources += Glob("src/main/cpp/*.cpp") -sources += Glob("src/main/cpp/export/*.cpp") - -binary_path = '#demo/addons/godotopenxrvendors/lynx/.bin' -project_name = 'godotopenxrlynx' - -# Create the library target -if env_lynx["platform"] == "android": - print("Use gradle to generate the Android binaries") - Exit(255) -elif env_lynx["platform"] == "macos": - library = env_lynx.SharedLibrary( - "{0}/lib{1}.{2}.{3}.framework/{1}.{2}.{3}".format( - binary_path, - project_name, - env_lynx["platform"], - env_lynx["target"], - ), - source=sources, - ) -else: - library = env_lynx.SharedLibrary( - "{}/lib{}.{}.{}.{}{}".format( - binary_path, - project_name, - env_lynx["platform"], - env_lynx["target"], - env_lynx["arch"], - env_lynx["SHLIBSUFFIX"], - ), - source=sources, - ) - -Default(library) diff --git a/godotopenxrlynx/build.gradle b/godotopenxrlynx/build.gradle index 32ca7405..d8e2a55f 100644 --- a/godotopenxrlynx/build.gradle +++ b/godotopenxrlynx/build.gradle @@ -11,6 +11,7 @@ apply from: "../scripts/publish-module.gradle" android { compileSdk versions.compileSdk + ndkVersion versions.ndkVersion defaultConfig { minSdk versions.minSdk @@ -50,6 +51,16 @@ android { withJavadocJar() } } + + buildFeatures { + prefabPublishing true + } + + prefab { + godotopenxrvendors { + headers "../common/src/main/cpp/extensions/include" + } + } } dependencies { @@ -59,14 +70,24 @@ dependencies { task copyDebugAARToAddons(type: Copy) { from 'build/outputs/aar' include 'godotopenxrlynx-debug.aar' - into '../demo/addons/godotopenxrvendors/lynx/.bin/debug' + into '../demo/addons/godotopenxrvendors/.bin/android/debug' } task copyReleaseAARToAddons(type: Copy) { from 'build/outputs/aar' include 'godotopenxrlynx-release.aar' - into '../demo/addons/godotopenxrvendors/lynx/.bin/release' + into '../demo/addons/godotopenxrvendors/.bin/android/release' +} + +task copyGdExtensionConfigToAssets(type: Copy) { + description 'Copy plugin.gdextension from the addons directory to the assets directory' + + from '../demo/addons/godotopenxrvendors/' + include 'plugin.gdextension' + into 'src/main/assets/addons/godotopenxrvendors/' } +preBuild.dependsOn(copyGdExtensionConfigToAssets) +assemble.dependsOn(copyGdExtensionConfigToAssets) assemble.finalizedBy(copyDebugAARToAddons) assemble.finalizedBy(copyReleaseAARToAddons) diff --git a/godotopenxrlynx/src/main/assets/.gitignore b/godotopenxrlynx/src/main/assets/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/godotopenxrlynx/src/main/assets/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/godotopenxrlynx/src/main/cpp/register_types.cpp b/godotopenxrlynx/src/main/cpp/register_types.cpp deleted file mode 100644 index ba3491c7..00000000 --- a/godotopenxrlynx/src/main/cpp/register_types.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************/ -/* register_types.cpp */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT XR */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2022-present Godot XR contributors (see CONTRIBUTORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#include "register_types.h" - -#include - -#include -#include -#include -#include - -#include "export/export_plugin.h" -#include "export/lynx_export_plugin.h" - -using namespace godot; - -void initialize_plugin_module(ModuleInitializationLevel p_level) { - switch (p_level) { - case MODULE_INITIALIZATION_LEVEL_EDITOR: { - ClassDB::register_class(); - ClassDB::register_class(); - - EditorPlugins::add_by_type(); - } break; - } -} - -void terminate_plugin_module(ModuleInitializationLevel p_level) -{ -} - -extern "C" -{ -GDExtensionBool GDE_EXPORT plugin_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) -{ - godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); - - init_obj.register_initializer(initialize_plugin_module); - init_obj.register_terminator(terminate_plugin_module); - init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_EDITOR); - - return init_obj.init(); -} -} diff --git a/godotopenxrlynx/src/main/cpp/register_types.h b/godotopenxrlynx/src/main/cpp/register_types.h deleted file mode 100644 index cdf62ca1..00000000 --- a/godotopenxrlynx/src/main/cpp/register_types.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************/ -/* register_types.h */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT XR */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2022-present Godot XR contributors (see CONTRIBUTORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#pragma once - -#include - -using namespace godot; - -void initialize_plugin_module(ModuleInitializationLevel p_level); -void terminate_plugin_module(ModuleInitializationLevel p_level); diff --git a/godotopenxrlynx/src/main/java/org/godotengine/openxr/vendors/lynx/GodotOpenXRLynx.kt b/godotopenxrlynx/src/main/java/org/godotengine/openxr/vendors/lynx/GodotOpenXRLynx.kt index dbb15d31..4406dd04 100644 --- a/godotopenxrlynx/src/main/java/org/godotengine/openxr/vendors/lynx/GodotOpenXRLynx.kt +++ b/godotopenxrlynx/src/main/java/org/godotengine/openxr/vendors/lynx/GodotOpenXRLynx.kt @@ -29,6 +29,7 @@ package org.godotengine.openxr.vendors.lynx +import android.util.Log import org.godotengine.godot.Godot import org.godotengine.godot.plugin.GodotPlugin @@ -36,6 +37,21 @@ import org.godotengine.godot.plugin.GodotPlugin * \brief GodotOpenXRLynx is the OpenXR Lynx plugin for Godot. */ class GodotOpenXRLynx(godot: Godot?) : GodotPlugin(godot) { + companion object { + private val TAG = GodotOpenXRLynx::class.java.simpleName + + init { + try { + Log.v(TAG, "Loading godotopenxrvendors library") + System.loadLibrary("godotopenxrvendors") + } catch (e: UnsatisfiedLinkError) { + Log.e(TAG, "Unable to load godotopenxrvendors shared library") + } + } + } + + override fun getPluginGDExtensionLibrariesPaths() = setOf("res://addons/godotopenxrvendors/plugin.gdextension") + override fun getPluginName(): String { return "GodotOpenXRLynx" } diff --git a/godotopenxrmeta/CMakeLists.txt b/godotopenxrmeta/CMakeLists.txt index 55d30c3b..85a553df 100644 --- a/godotopenxrmeta/CMakeLists.txt +++ b/godotopenxrmeta/CMakeLists.txt @@ -5,7 +5,7 @@ include(${CMAKE_SOURCE_DIR}/../common/CMakeLists.txt) ## Project definition -project(godotopenxrmeta LANGUAGES CXX) +project(godotopenxrvendors LANGUAGES CXX) ## OpenXR Mobile loader library # Sets the path to the OpenXR mobile library directory. @@ -50,3 +50,5 @@ target_link_libraries(${CMAKE_PROJECT_NAME} # Add the compile flags set_property(TARGET ${CMAKE_PROJECT_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${GODOT_COMPILE_FLAGS}) set_property(TARGET ${CMAKE_PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS ${GODOT_LINKER_FLAGS}) + +add_definitions(-DMETA_VENDOR_ENABLED) diff --git a/godotopenxrmeta/SConstruct b/godotopenxrmeta/SConstruct deleted file mode 100644 index abc71a9e..00000000 --- a/godotopenxrmeta/SConstruct +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -from glob import glob -from pathlib import Path - -Import("env", "common_objects") - -env_meta = env.Clone() - -env_meta.Append(CPPPATH=[ - "src/main/cpp", - "src/main/cpp/include", - "libs/ovr_openxr_mobile_sdk/OpenXR/Include", - ]) - -# Source files -sources = common_objects.copy() -sources += Glob("src/main/cpp/*.cpp") -sources += Glob("src/main/cpp/export/*.cpp") - -binary_path = '#demo/addons/godotopenxrvendors/meta/.bin' -project_name = 'godotopenxrmeta' - -# Create the library target -if env_meta["platform"] == "android": - print("Use gradle to generate the Android binaries") - Exit(255) -elif env_meta["platform"] == "macos": - library = env_meta.SharedLibrary( - "{0}/lib{1}.{2}.{3}.framework/{1}.{2}.{3}".format( - binary_path, - project_name, - env_meta["platform"], - env_meta["target"], - ), - source=sources, - ) -else: - library = env_meta.SharedLibrary( - "{}/lib{}.{}.{}.{}{}".format( - binary_path, - project_name, - env_meta["platform"], - env_meta["target"], - env_meta["arch"], - env_meta["SHLIBSUFFIX"], - ), - source=sources, - ) - -Default(library) diff --git a/godotopenxrmeta/build.gradle b/godotopenxrmeta/build.gradle index 2233bce4..0b5f960b 100644 --- a/godotopenxrmeta/build.gradle +++ b/godotopenxrmeta/build.gradle @@ -11,6 +11,7 @@ apply from: "../scripts/publish-module.gradle" android { compileSdk versions.compileSdk + ndkVersion versions.ndkVersion defaultConfig { minSdk versions.minSdk @@ -56,8 +57,8 @@ android { } prefab { - godotopenxrmeta { - headers "src/main/cpp/include" + godotopenxrvendors { + headers "../common/src/main/cpp/extensions/include" } } } @@ -69,21 +70,21 @@ dependencies { task copyDebugAARToAddons(type: Copy) { from 'build/outputs/aar' include 'godotopenxrmeta-debug.aar' - into '../demo/addons/godotopenxrvendors/meta/.bin/debug' + into '../demo/addons/godotopenxrvendors/.bin/android/debug' } task copyReleaseAARToAddons(type: Copy) { from 'build/outputs/aar' include 'godotopenxrmeta-release.aar' - into '../demo/addons/godotopenxrvendors/meta/.bin/release' + into '../demo/addons/godotopenxrvendors/.bin/android/release' } task copyGdExtensionConfigToAssets(type: Copy) { description 'Copy plugin.gdextension from the addons directory to the assets directory' - from '../demo/addons/godotopenxrvendors/meta/' + from '../demo/addons/godotopenxrvendors/' include 'plugin.gdextension' - into 'src/main/assets/addons/godotopenxrvendors/meta' + into 'src/main/assets/addons/godotopenxrvendors/' } preBuild.dependsOn(copyGdExtensionConfigToAssets) diff --git a/godotopenxrmeta/src/main/cpp/register_types.h b/godotopenxrmeta/src/main/cpp/register_types.h deleted file mode 100644 index cdf62ca1..00000000 --- a/godotopenxrmeta/src/main/cpp/register_types.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************/ -/* register_types.h */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT XR */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2022-present Godot XR contributors (see CONTRIBUTORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#pragma once - -#include - -using namespace godot; - -void initialize_plugin_module(ModuleInitializationLevel p_level); -void terminate_plugin_module(ModuleInitializationLevel p_level); diff --git a/godotopenxrmeta/src/main/java/org/godotengine/openxr/vendors/meta/GodotOpenXRMeta.kt b/godotopenxrmeta/src/main/java/org/godotengine/openxr/vendors/meta/GodotOpenXRMeta.kt index 5af0b124..5f6dcb7f 100644 --- a/godotopenxrmeta/src/main/java/org/godotengine/openxr/vendors/meta/GodotOpenXRMeta.kt +++ b/godotopenxrmeta/src/main/java/org/godotengine/openxr/vendors/meta/GodotOpenXRMeta.kt @@ -49,10 +49,10 @@ class GodotOpenXRMeta(godot: Godot?) : GodotPlugin(godot) { init { try { - Log.v(TAG, "Loading godotopenxrmeta library") - System.loadLibrary("godotopenxrmeta") + Log.v(TAG, "Loading godotopenxrvendors library") + System.loadLibrary("godotopenxrvendors") } catch (e: UnsatisfiedLinkError) { - Log.e(TAG, "Unable to load godotopenxrmeta shared library") + Log.e(TAG, "Unable to load godotopenxrvendors shared library") } } } @@ -61,7 +61,7 @@ class GodotOpenXRMeta(godot: Godot?) : GodotPlugin(godot) { return "GodotOpenXRMeta" } - override fun getPluginGDExtensionLibrariesPaths() = setOf("res://addons/godotopenxrvendors/meta/plugin.gdextension") + override fun getPluginGDExtensionLibrariesPaths() = setOf("res://addons/godotopenxrvendors/plugin.gdextension") override fun onMainCreate(activity: Activity): View? { // Request the eye tracking permission if it's included in the manifest diff --git a/godotopenxrpico/CMakeLists.txt b/godotopenxrpico/CMakeLists.txt index b8dcabc6..ba6b2130 100644 --- a/godotopenxrpico/CMakeLists.txt +++ b/godotopenxrpico/CMakeLists.txt @@ -5,7 +5,7 @@ include(${CMAKE_SOURCE_DIR}/../common/CMakeLists.txt) ## Project definition -project(godotopenxrpico LANGUAGES CXX) +project(godotopenxrvendors LANGUAGES CXX) ## Pico OpenXR loader library set(PICO_OPENXR_LIB_PATH "${CMAKE_SOURCE_DIR}/libs/pico_openxr_sdk/${ANDROID_ABI}/libopenxr_loader.so") @@ -44,3 +44,5 @@ target_link_libraries(${CMAKE_PROJECT_NAME} # Add the compile flags set_property(TARGET ${CMAKE_PROJECT_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${GODOT_COMPILE_FLAGS}) set_property(TARGET ${CMAKE_PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS ${GODOT_LINKER_FLAGS}) + +add_definitions(-DPICO_VENDOR_ENABLED) diff --git a/godotopenxrpico/SConstruct b/godotopenxrpico/SConstruct deleted file mode 100644 index 11014347..00000000 --- a/godotopenxrpico/SConstruct +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -from glob import glob -from pathlib import Path - -Import("env", "common_objects") - -env_pico = env.Clone() - -env_pico.Append(CPPPATH=[ - "src/main/cpp", - ]) - -# Source files -sources = common_objects.copy() -sources += Glob("src/main/cpp/*.cpp") -sources += Glob("src/main/cpp/export/*.cpp") - -binary_path = '#demo/addons/godotopenxrvendors/pico/.bin' -project_name = 'godotopenxrpico' - -# Create the library target -if env_pico["platform"] == "android": - print("Use gradle to generate the Android binaries") - Exit(255) -elif env_pico["platform"] == "macos": - library = env_pico.SharedLibrary( - "{0}/lib{1}.{2}.{3}.framework/{1}.{2}.{3}".format( - binary_path, - project_name, - env_pico["platform"], - env_pico["target"], - ), - source=sources, - ) -else: - library = env_pico.SharedLibrary( - "{}/lib{}.{}.{}.{}{}".format( - binary_path, - project_name, - env_pico["platform"], - env_pico["target"], - env_pico["arch"], - env_pico["SHLIBSUFFIX"], - ), - source=sources, - ) - -Default(library) diff --git a/godotopenxrpico/build.gradle b/godotopenxrpico/build.gradle index d502501f..b6ceb1f9 100644 --- a/godotopenxrpico/build.gradle +++ b/godotopenxrpico/build.gradle @@ -11,6 +11,7 @@ apply from: "../scripts/publish-module.gradle" android { compileSdk versions.compileSdk + ndkVersion versions.ndkVersion defaultConfig { minSdk versions.minSdk @@ -50,6 +51,16 @@ android { withJavadocJar() } } + + buildFeatures { + prefabPublishing true + } + + prefab { + godotopenxrvendors { + headers "../common/src/main/cpp/extensions/include" + } + } } dependencies { @@ -59,14 +70,24 @@ dependencies { task copyDebugAARToAddons(type: Copy) { from 'build/outputs/aar' include 'godotopenxrpico-debug.aar' - into '../demo/addons/godotopenxrvendors/pico/.bin/debug' + into '../demo/addons/godotopenxrvendors/.bin/android/debug' } task copyReleaseAARToAddons(type: Copy) { from 'build/outputs/aar' include 'godotopenxrpico-release.aar' - into '../demo/addons/godotopenxrvendors/pico/.bin/release' + into '../demo/addons/godotopenxrvendors/.bin/android/release' +} + +task copyGdExtensionConfigToAssets(type: Copy) { + description 'Copy plugin.gdextension from the addons directory to the assets directory' + + from '../demo/addons/godotopenxrvendors/' + include 'plugin.gdextension' + into 'src/main/assets/addons/godotopenxrvendors/' } +preBuild.dependsOn(copyGdExtensionConfigToAssets) +assemble.dependsOn(copyGdExtensionConfigToAssets) assemble.finalizedBy(copyDebugAARToAddons) assemble.finalizedBy(copyReleaseAARToAddons) diff --git a/godotopenxrpico/src/main/assets/.gitignore b/godotopenxrpico/src/main/assets/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/godotopenxrpico/src/main/assets/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/godotopenxrpico/src/main/cpp/register_types.cpp b/godotopenxrpico/src/main/cpp/register_types.cpp deleted file mode 100644 index d6eceefc..00000000 --- a/godotopenxrpico/src/main/cpp/register_types.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************/ -/* register_types.cpp */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT XR */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2022-present Godot XR contributors (see CONTRIBUTORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#include "register_types.h" - -#include - -#include -#include -#include -#include - -#include "export/export_plugin.h" -#include "export/pico_export_plugin.h" - -using namespace godot; - -void initialize_plugin_module(ModuleInitializationLevel p_level) { - switch (p_level) { - case MODULE_INITIALIZATION_LEVEL_EDITOR: { - ClassDB::register_class(); - ClassDB::register_class(); - - EditorPlugins::add_by_type(); - } break; - } -} - -void terminate_plugin_module(ModuleInitializationLevel p_level) -{ -} - -extern "C" -{ -GDExtensionBool GDE_EXPORT plugin_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) -{ - godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); - - init_obj.register_initializer(initialize_plugin_module); - init_obj.register_terminator(terminate_plugin_module); - init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_EDITOR); - - return init_obj.init(); -} -} diff --git a/godotopenxrpico/src/main/cpp/register_types.h b/godotopenxrpico/src/main/cpp/register_types.h deleted file mode 100644 index cdf62ca1..00000000 --- a/godotopenxrpico/src/main/cpp/register_types.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************/ -/* register_types.h */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT XR */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2022-present Godot XR contributors (see CONTRIBUTORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#pragma once - -#include - -using namespace godot; - -void initialize_plugin_module(ModuleInitializationLevel p_level); -void terminate_plugin_module(ModuleInitializationLevel p_level); diff --git a/godotopenxrpico/src/main/java/org/godotengine/openxr/vendors/pico/GodotOpenXRPico.kt b/godotopenxrpico/src/main/java/org/godotengine/openxr/vendors/pico/GodotOpenXRPico.kt index fab7147d..247e7766 100644 --- a/godotopenxrpico/src/main/java/org/godotengine/openxr/vendors/pico/GodotOpenXRPico.kt +++ b/godotopenxrpico/src/main/java/org/godotengine/openxr/vendors/pico/GodotOpenXRPico.kt @@ -29,6 +29,7 @@ package org.godotengine.openxr.vendors.pico +import android.util.Log import org.godotengine.godot.Godot import org.godotengine.godot.plugin.GodotPlugin @@ -36,6 +37,21 @@ import org.godotengine.godot.plugin.GodotPlugin * Godot plugin for the Pico OpenXR loader. */ class GodotOpenXRPico(godot: Godot?) : GodotPlugin(godot) { + companion object { + private val TAG = GodotOpenXRPico::class.java.simpleName + + init { + try { + Log.v(TAG, "Loading godotopenxrvendors library") + System.loadLibrary("godotopenxrvendors") + } catch (e: UnsatisfiedLinkError) { + Log.e(TAG, "Unable to load godotopenxrvendors shared library") + } + } + } + + override fun getPluginGDExtensionLibrariesPaths() = setOf("res://addons/godotopenxrvendors/plugin.gdextension") + override fun getPluginName(): String { return "GodotOpenXRPico" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ca1301ea..66f61ac7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri Mar 11 11:10:12 NZDT 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME