Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CMake from the build process #227

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 38 additions & 34 deletions .github/workflows/build-addon-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,19 @@ jobs:
os: ubuntu-20.04
platform: android
flags: arch=arm64
artifact_name: build-files-android
artifact_name: build-files-android-arm64
artifact_path: |
aar/demo/addons/godotopenxrvendors/.bin/android/*/*.aar
aar/demo/addons/godotopenxrvendors/.bin/android/*/*/*.so
aar/plugin/src/main/libs/*/*/*/*.so
cache-name: android-arm64
- name: 🤖 Android (x86_64)
os: ubuntu-20.04
platform: android
flags: arch=x86_64
artifact_name: build-files-android-x86_64
artifact_path: |
aar/plugin/src/main/libs/*/*/*/*.so
cache-name: android-x86_64


# 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 All @@ -83,6 +91,7 @@ jobs:
with:
ndk-version: r23c
link-to-sdk: true
if: matrix.platform == 'android'
- name: Install scons
run: |
python -m pip install scons==4.0.0
Expand All @@ -97,54 +106,42 @@ jobs:
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true

# On Android we build our loaders and build our extension with gradlew
- name: Setup java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "adopt"
if: matrix.platform == 'android'
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
if: matrix.platform == 'android'
- name: Create Godot-CPP library
run: |
cd aar/thirdparty/godot-cpp
scons platform=${{ matrix.platform }} target=template_debug arch=arm64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json build_profile=../godot_cpp_build_profile/build_profile.json
scons platform=${{ matrix.platform }} target=template_release arch=arm64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json build_profile=../godot_cpp_build_profile/build_profile.json
scons platform=${{ matrix.platform }} target=template_debug arch=x86_64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json build_profile=../godot_cpp_build_profile/build_profile.json
scons platform=${{ matrix.platform }} target=template_release arch=x86_64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json build_profile=../godot_cpp_build_profile/build_profile.json
cd ../../..
if: matrix.platform == 'android'
- name: Create Godot OpenXR Vendors AARs
uses: burrunan/gradle-cache-action@v1
with:
build-root-directory: aar
arguments: build
if: matrix.platform == 'android'

- name: Upload build files (artifacts)
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: |
${{ matrix.artifact_path }}

# GODOT 4.2 ADDON GENERATION SECTION
asset:
name: Assembling the asset
runs-on: ubuntu-20.04
needs: build

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: aar
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
- name: Setup java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
- name: Copy Android binaries
run: |
mkdir aar/plugin/src/main/libs
cp -r build-files-android-arm64/* aar/plugin/src/main/libs/
cp -r build-files-android-x86_64/* aar/plugin/src/main/libs/
- name: Create Godot OpenXR Vendors AARs
run: |
cd aar
./gradlew build
cd ..
- name: Create Godot OpenXR Vendors Addon
run: |
mkdir asset
Expand All @@ -166,8 +163,15 @@ jobs:

- name: Copying artifacts
run: |
mkdir -p asset/addons/godotopenxrvendors/.bin/android/
cp -r build-files-android/* asset/addons/godotopenxrvendors/.bin/android/
mkdir -p asset/addons/godotopenxrvendors/.bin/android/template_debug/arm64
mkdir -p asset/addons/godotopenxrvendors/.bin/android/template_release/arm64
cp -r build-files-android-arm64/debug/*/*/*.so asset/addons/godotopenxrvendors/.bin/android/template_debug/arm64/
cp -r build-files-android-arm64/release/*/*/*.so asset/addons/godotopenxrvendors/.bin/android/template_release/arm64/

mkdir -p asset/addons/godotopenxrvendors/.bin/android/template_debug/x86_64
mkdir -p asset/addons/godotopenxrvendors/.bin/android/template_release/x86_64
cp -r build-files-android-x86_64/debug/*/*/*.so asset/addons/godotopenxrvendors/.bin/android/template_debug/x86_64/
cp -r build-files-android-x86_64/release/*/*/*.so asset/addons/godotopenxrvendors/.bin/android/template_release/x86_64/

mkdir -p asset/addons/godotopenxrvendors/.bin/linux/
cp -r build-files-linux-x86_64/* asset/addons/godotopenxrvendors/.bin/linux/
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/mavencentral-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ jobs:
# Builds the release artifacts of the library
- name: Release build
run: |
cd thirdparty/godot-cpp
scons platform=android target=template_debug arch=arm64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json
scons platform=android target=template_release arch=arm64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json
scons platform=android target=template_debug arch=x86_64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json
scons platform=android target=template_release arch=x86_64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json
cd ../..
scons platform=android target=template_debug arch=arm64 custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json build_profile=thirdparty/godot_cpp_build_profile/build_profile.json
scons platform=android target=template_release arch=arm64 custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json build_profile=thirdparty/godot_cpp_build_profile/build_profile.json
scons platform=android target=template_debug arch=x86_64 custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json build_profile=thirdparty/godot_cpp_build_profile/build_profile.json
scons platform=android target=template_release arch=x86_64 custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json build_profile=thirdparty/godot_cpp_build_profile/build_profile.json
./gradlew -Prelease_version=${{ github.ref_name }} build

# Runs upload, and then closes & releases the repository
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ local.properties
# Misc
.DS_Store
/plugin/src/gen/
/plugin/src/main/libs
/zippedSamples
22 changes: 22 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if env["target"] in ["editor", "template_debug"]:
sources.append(doc_data)

binary_path = '#demo/addons/godotopenxrvendors/.bin'
android_src_path = '#plugin/src'
project_name = 'godotopenxrvendors'

# Statically link with libgcc and libstdc++ for more Linux compatibility.
Expand Down Expand Up @@ -62,3 +63,24 @@ else:

Default(library)

if env["platform"] == "android":
android_target = "release" if env["target"] == "template_release" else "debug"
android_arch = ""
if env["arch"] == "arm64":
android_arch = "arm64-v8a"
elif env["arch"] == "x86_64":
android_arch = "x86_64"
else:
raise Exception("Unable to map %s to Android architecture name" % env["arch"])

library_copy_path = "{}/main/libs/{}/{}/{}/lib{}{}".format(
android_src_path,
android_target,
android_arch,
android_arch,
project_name,
env["SHLIBSUFFIX"])

library_copy = env.Command(library_copy_path, library, Copy('$TARGET', '$SOURCE'))

Default(library_copy)
78 changes: 42 additions & 36 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,47 +80,53 @@ task buildSconsArtifacts {
break
}
}
if (sconsExecutableFile == null) {
throw new GradleException("Unable to find executable path for the '$sconsName' command.")
} else {
logger.debug("Found executable path for $sconsName: ${sconsExecutableFile.absolutePath}")
}

// Build the Godot-CPP bindings
tasks.create(name: "buildGodotCPPArm64Debug", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=thirdparty/godot-cpp", "platform=android", "target=template_debug", "arch=arm64", "custom_api_file=../godot_cpp_gdextension_api/extension_api.json"
}
tasks.create(name: "buildGodotCPPArm64Release", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=thirdparty/godot-cpp", "platform=android", "target=template_release", "arch=arm64", "custom_api_file=../godot_cpp_gdextension_api/extension_api.json"
}
tasks.create(name: "buildGodotCPPX86_64Debug", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=thirdparty/godot-cpp", "platform=android", "target=template_debug", "arch=x86_64", "custom_api_file=../godot_cpp_gdextension_api/extension_api.json"
}
tasks.create(name: "buildGodotCPPX86_64Release", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=thirdparty/godot-cpp", "platform=android", "target=template_release", "arch=x86_64", "custom_api_file=../godot_cpp_gdextension_api/extension_api.json"
// Using `doFirst` so the exception doesn't happen until this task actually runs.
doFirst {
if (sconsExecutableFile == null) {
throw new GradleException("Unable to find executable path for the '$sconsName' command.")
} else {
logger.debug("Found executable path for $sconsName: ${sconsExecutableFile.absolutePath}")
}
}

dependsOn 'buildGodotCPPArm64Debug'
dependsOn 'buildGodotCPPArm64Release'
dependsOn 'buildGodotCPPX86_64Debug'
dependsOn 'buildGodotCPPX86_64Release'
if (sconsExecutableFile != null) {
// Build the GDExtension library for Android.
tasks.create(name: "buildGodotOpenXRVendorsAndroidArm64Debug", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=.", "platform=android", "target=template_debug", "arch=arm64", "custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json", "build_profile=thirdparty/godot_cpp_build_profile/build_profile.json"
}
tasks.create(name: "buildGodotOpenXRVendorsAndroidArm64Release", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=.", "platform=android", "target=template_release", "arch=arm64", "custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json", "build_profile=thirdparty/godot_cpp_build_profile/build_profile.json"
}
tasks.create(name: "buildGodotOpenXRVendorsAndroidX86_64Debug", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=.", "platform=android", "target=template_debug", "arch=x86_64", "custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json", "build_profile=thirdparty/godot_cpp_build_profile/build_profile.json"
}
tasks.create(name: "buildGodotOpenXRVendorsAndroidX86_64Release", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=.", "platform=android", "target=template_release", "arch=x86_64", "custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json", "build_profile=thirdparty/godot_cpp_build_profile/build_profile.json"
}

// Creating gradle task to generate the editor gdextension binaries
tasks.create(name: "buildGodotOpenXRVendorsDebugGDExtension", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=.", "target=template_debug", "custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json"
}
tasks.create(name: "buildGodotOpenXRVendorsReleaseGDExtension", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=.", "target=template_release", "custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json"
}
dependsOn 'buildGodotOpenXRVendorsAndroidArm64Debug'
dependsOn 'buildGodotOpenXRVendorsAndroidArm64Release'
dependsOn 'buildGodotOpenXRVendorsAndroidX86_64Debug'
dependsOn 'buildGodotOpenXRVendorsAndroidX86_64Release'

dependsOn 'buildGodotOpenXRVendorsDebugGDExtension'
dependsOn 'buildGodotOpenXRVendorsReleaseGDExtension'
// Build the GDExtension library for desktop.
tasks.create(name: "buildGodotOpenXRVendorsDesktopDebug", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=.", "target=template_debug", "custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json", "build_profile=thirdparty/godot_cpp_build_profile/build_profile.json"
}
tasks.create(name: "buildGodotOpenXRVendorsDesktopRelease", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=.", "target=template_release", "custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json", "build_profile=thirdparty/godot_cpp_build_profile/build_profile.json"
}

dependsOn 'buildGodotOpenXRVendorsDesktopDebug'
dependsOn 'buildGodotOpenXRVendorsDesktopRelease'
}
}

task copyBuildToSamples {
Expand Down
1 change: 0 additions & 1 deletion config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ext {
javaVersion : JavaVersion.VERSION_17,
nexusPublishVersion : '1.3.0',
kotlinVersion : '1.9.20',
cmakeVersion : '3.22.1',
ndkVersion : '23.2.8568313',
openxrVersion : '1.0.34',
fragmentVersion : '1.7.1',
Expand Down
39 changes: 17 additions & 22 deletions plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
# Non functional cmake build file used to provide Android Studio editor support to the project.
cmake_minimum_required(VERSION 3.22.1)

## Project definition
project(godotopenxrvendors LANGUAGES CXX)

## Common dependencies
include(${PROJECT_SOURCE_DIR}/src/main/common.cmake)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(GODOT_CPP_DIR "${CMAKE_CURRENT_LIST_DIR}/../thirdparty/godot-cpp")
set(OPENXR_HEADERS_DIR "${CMAKE_CURRENT_LIST_DIR}/../thirdparty/openxr/include")
set(COMMON_LIB_HEADERS_DIR "${CMAKE_CURRENT_LIST_DIR}/src/main/cpp/include")

## Flavor dependencies
include(src/${FLAVOR}/${FLAVOR}.cmake)
# Get sources
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_LIST_DIR}/src/main/cpp/*.c**)
file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_LIST_DIR}/src/main/cpp/*.h**)

add_library(${PROJECT_NAME}
SHARED
${ANDROID_SOURCES}
${ANDROID_HEADERS}
${COMMON_LIB_SOURCES}
${COMMON_LIB_HEADERS}
${SOURCES}
${HEADERS}
)

target_include_directories(${PROJECT_NAME}
SYSTEM PUBLIC
${GODOT_CPP_INCLUDE_DIRECTORIES}
"${GODOT_CPP_DIR}/include"
"${GODOT_CPP_DIR}/gen/include"
"${GODOT_CPP_DIR}/gdextension"
${OPENXR_HEADERS_DIR}
${VENDOR_HEADERS_DIR}
${COMMON_LIB_HEADERS_DIR}
)

target_link_libraries(${PROJECT_NAME}
android
log
${GODOT-CPP}
${OPENXR_LOADER}
)

# Add the compile flags
set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${GODOT_COMPILE_FLAGS})
set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS ${GODOT_LINKER_FLAGS})
add_definitions(-DDEBUG_ENABLED)
Loading
Loading