Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Implement linux export test as CI GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
dorianpercic committed Apr 26, 2024
1 parent 7e356b4 commit 81aa0a4
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 45 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/gut.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Godot"
on: push

on: [push]

jobs:
execute-gut:
Expand All @@ -11,6 +12,6 @@ jobs:
- name: Execute GUT Unit Test
uses: ceceppa/godot-gut-ci@main
with:
godot_version: 4.2.1
godot_version: 4.2.2
gut_params: -gdir=res://src/test/unit -gprefix=test_ -gsuffix=.gd
project_path: godot
2 changes: 1 addition & 1 deletion .github/workflows/linux_build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Linux Build Test
name: Linux Build

on: [push]

Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/linux_export.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Linux Export

on: [push]

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Dwarnings
CARGO_INCREMENTAL: 0

jobs:
export-linux: # For now only debug export, as the release export has a bug on the Godot side
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rui314/setup-mold@v1
- uses: chickensoft-games/setup-godot@v1
name: Setup Godot
with:
version: 4.2.2
include-templates: true
use-dotnet: false
- uses: Swatinem/rust-cache@v2
with:
workspaces: "rust -> target"
cache-all-crates: "true"

- name: Install just
run: cargo install just

- name: just Check
run: just --version

- name: Godot Check
run: |
godot --version
- name: Godot Export
run: |
just linux-debug
export-android: # Release export
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rui314/setup-mold@v1
- uses: chickensoft-games/setup-godot@v1
name: Setup Godot
with:
version: 4.2.2
include-templates: true
use-dotnet: false
- uses: Swatinem/rust-cache@v2
with:
workspaces: "rust -> target"
cache-all-crates: "true"

- name: Install just
run: cargo install just

- name: just Check
run: just --version

- name: Godot Check
run: |
java --version
godot --version
- name: Godot Export
run: |
just setup-android
just android-release
2 changes: 1 addition & 1 deletion .github/workflows/windows_build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Windows Build Test
name: Windows Build

on: [push]

Expand Down
17 changes: 10 additions & 7 deletions godot/RustPlugin.gdextension
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ compatibility_minimum = 4.2
reloadable = false

[libraries]
linux.release.x86_64 = "res://../rust/target/release/libgodot_plugin.so"
linux.debug.x86_64 = "res://../rust/target/debug/libgodot_plugin.so"
linux.release.x86_64 = "res://../rust/target/release/libgodot_plugin.so"

android.debug.x86_64 = "res://../rust/target/x86_64-linux-android/debug/libgodot_plugin.so"
android.release.x86_64 = "res://../rust/target/x86_64-linux-android/release/libgodot_plugin.so"

android.release.arm64 = "res://../rust/target/aarch64-linux-android/debug/libgodot_plugin.so"
android.debug.arm64 = "res://../rust/target/aarch64-linux-android/release/libgodot_plugin.so"
android.debug.arm64 = "res://../rust/target/aarch64-linux-android/debug/libgodot_plugin.so"
android.release.arm64 = "res://../rust/target/aarch64-linux-android/release/libgodot_plugin.so"

windows.debug.x86_64 = "res://../rust/target/debug/godot_plugin.dll"
windows.release.x86_64 = "res://../rust/target/release/godot_plugin.dll"
windows.debug.x86_64 = "res://../rust/target/x86_64-pc-windows-msvc/debug/godot_plugin.dll"
windows.release.x86_64 = "res://../rust/target/x86_64-pc-windows-msvc/release/godot_plugin.dll"

macos.debug = "res://../rust/target/debug/libgodot_plugin.dylib"
macos.release = "res://../rust/target/release/libgodot_plugin.dylib"

#macos.debug.arm64 = "res://../rust/target/debug/lib{YourCrate}.dylib"
#macos.release.arm64 = "res://../rust/target/release/lib{YourCrate}.dylib"
#macos.debug.arm64 = "res://../rust/target/debug/lib{YourCrate}.dylib"
#macos.release.arm64 = "res://../rust/target/release/lib{YourCrate}.dylib"
2 changes: 1 addition & 1 deletion godot/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ gradle_build/target_sdk=""
architectures/armeabi-v7a=false
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
architectures/x86_64=true
version/code=1
version/name=""
package/unique_name="org.catroid.godotspike"
Expand Down
70 changes: 40 additions & 30 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -------------------------------------------------
# Settings
export ANDROID_HOME := `echo "$PWD/dependencies/android-sdk"`
export ANDROID_SDK_ROOT := `echo "$PWD/dependencies/android-sdk"`
test:
# will print a stack trace if it crashes
cargo test

# -------------------------------------------------
# Internal Helpers
Expand All @@ -24,13 +24,23 @@ linux-release:

[linux]
android-debug:
{{rustdir}} cargo build --target aarch64-linux-android
{{godotdir}} godot --headless --export-debug "Android" "../export/android/Godot Spike.apk"
{{rustdir}} cargo build --target aarch64-linux-android --config target.aarch64-linux-android.linker=\"../dependencies/android-sdk/ndk/26.2.11394342/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang\"
{{godotdir}} godot --headless --export-debug "Android"
[linux]
android-release:
{{rustdir}} cargo build --target aarch64-linux-android --release
{{godotdir}} godot --headless --export-release "Android" "../export/android/Godot Spike.apk"
{{rustdir}} cargo build --release --target aarch64-linux-android --config target.aarch64-linux-android.linker=\"../dependencies/android-sdk/ndk/26.2.11394342/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang\"
{{godotdir}} godot --headless --export-release "Android"
[windows]
android-debug:
{{rustdir}} cargo build --target aarch64-linux-android --config target.aarch64-linux-android.linker=\"../dependencies/android-sdk/ndk/26.2.11394342/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android34-clang.cmd\"
{{godotdir}} godot --headless --export-debug "Android" "../export/android/Godot Spike.apk"
[windows]
android-release:
{{rustdir}} cargo build --release --target aarch64-linux-android --config target.aarch64-linux-android.linker=\"../dependencies/android-sdk/ndk/26.2.11394342/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android34-clang.cmd\"
{{godotdir}} godot --headless --export-release "Android" "../export/android/Godot Spike.apk"
[windows]
windows-debug:
Expand All @@ -39,7 +49,7 @@ windows-debug:
[windows]
windows-release:
{{rustdir}} cargo build --target x86_64-pc-windows-gnu --release
{{rustdir}} cargo build --release --target x86_64-pc-windows-msvc
{{godotdir}} godot --headless --export-release "Windows Desktop" "../export/windows/Godot Spike.exe"
[macos]
Expand All @@ -61,13 +71,13 @@ ios-debug:
[macos]
ios-release:
# NOTE: can only work on MacOS with xcode
{{rustdir}} cargo build --target aarch64-apple-ios --release
{{rustdir}} cargo build --release --target aarch64-apple-ios
{{godotdir}} godot --headless --export-release "iOS" "../export/ios/Godot Spike.ipa"
# -------------------------------------------------
# Execute prior to development of project
setup:
just setup-verify-dependencies _setup-precommit _setup-rust _setup-{{os()}}
just setup-verify-dependencies _setup-precommit _setup-rust setup-{{os()}}
# -------------------------------------------------
# Execute to verify if all dependencies are installed
Expand All @@ -78,35 +88,35 @@ setup-verify-dependencies:
gdformat --version
pre-commit --version
_setup-precommit:
@ {{message}} "Setting up pre-commit hooks..."
pre-commit install

_setup-rust:
rustup toolchain install stable
rustup default stable

_setup-debug-keystore:
@ {{message}} "Generating debug keypair for Android..."
test -f {{android_keystore}} \
|| keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore {{android_keystore}} -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999 -deststoretype pkcs12

_setup-android:
setup-android:
@ {{message}} "Installing Rust tools for Android builds..."
rustup target add aarch64-linux-android
cargo install cargo-ndk
@ {{message}} "Installing Android NDK & SDK in the dependencies folder..."
scripts/install-android-tools.sh
just _setup-debug-keystore
_setup-windows:
@ {{message}} "Installing Rust tools for Windows builds..."
setup-windows:
@ {{message}} "Installing Rust tools for Windows builds and setup for android export..."
rustup target add x86_64-pc-windows-gnu
_setup-macos:
setup-macos:
@ {{message}} "Installing Rust tools for iOS builds..."
rustup target add aarch64-apple-ios
cargo install cargo-lipo
_setup-linux:
@ {{message}} "Setup Linux build tools..."
just _setup-android _setup-debug-keystore
setup-linux:
@ {{message}} "Setup Linux for android export..."
_setup-precommit:
@ {{message}} "Setting up pre-commit hooks..."
pre-commit install
_setup-rust:
rustup toolchain install stable
rustup default stable
_setup-debug-keystore:
@ {{message}} "Generating debug keypair for Android..."
test -f {{android_keystore}} \
|| keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore {{android_keystore}} -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999 -deststoretype pkcs12
3 changes: 0 additions & 3 deletions rust/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[target.aarch64-linux-android]
linker = "../dependencies/android-sdk/ndk/26.2.11394342/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang"

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=mold"]

0 comments on commit 81aa0a4

Please sign in to comment.