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 May 3, 2024
1 parent caa038d commit 67fb3e8
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ updates:
- package-ecosystem: "cargo" # See documentation for possible values
directory: "rust" # Location of package manifests
schedule:
interval: "weekly"
interval: "daily"
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
88 changes: 88 additions & 0 deletions .github/workflows/linux_export.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Linux Export

on: [push]

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

jobs:
export-linux: # For now only debug 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: |
godot --version
- name: Godot Export
run: |
just linux-debug
export-android: # Debug export for now
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rui314/setup-mold@v1
- uses: actions/setup-java@v4
with:
distribution: "oracle"
java-version: "22"
- 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
# sed -i 's#export/android/java_sdk_path = ".*"#export/android/java_sdk_path = "'$(dirname $(dirname $(which java)))'/"#' ~/.config/godot/editor_settings-4.tres
# sed -i 's#export/android/android_sdk_path = ".*"#export/android/android_sdk_path = "'$(pwd)'/dependencies/android-sdk/"#' ~/.config/godot/editor_settings-4.tres
# sed -i 's#export/android/debug_keystore = ".*"#export/android/debug_keystore = "'$(pwd)'/secrets/debug.keystore"#' ~/.config/godot/editor_settings-4.tres
# sed -i 's#export/android/debug_keystore_user = ".*"#export/android/debug_keystore_user = "androiddebugkey"#' ~/.config/godot/editor_settings-4.tres
# sed -i 's#export/android/debug_keystore_pass = ".*"#export/android/debug_keystore_pass = "android"#' ~/.config/godot/editor_settings-4.tres
- name: Godot Export
run: |
touch godot/.godot/extension_list.cfg
echo "res://rust.gdextension" >> godot/.godot/extension_list.cfg
godot --headless -q -e --quit
echo "export/android/java_sdk_path = \"$(dirname $(dirname $(which java)))\"" >> ~/.config/godot/editor_settings-4.tres
echo "export/android/android_sdk_path = \"$(pwd)/dependencies/android-sdk/\"" >> ~/.config/godot/editor_settings-4.tres
echo "export/android/debug_keystore = \"$(pwd)/secrets/debug.keystore\"" >> ~/.config/godot/editor_settings-4.tres
echo "export/android/debug_keystore_user = \"androiddebugkey\"" >> ~/.config/godot/editor_settings-4.tres
echo "export/android/debug_keystore_pass = \"android\"" >> ~/.config/godot/editor_settings-4.tres
cat ~/.config/godot/editor_settings-4.tres
just setup-android
cargo build --manifest-path=rust/Cargo.toml
just android-debug
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
20 changes: 0 additions & 20 deletions godot/RustPlugin.gdextension

This file was deleted.

2 changes: 1 addition & 1 deletion godot/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ gradle_build/use_gradle_build=false
gradle_build/export_format=0
gradle_build/min_sdk=""
gradle_build/target_sdk=""
architectures/armeabi-v7a=false
architectures/armeabi-v7a=true
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
Expand Down
14 changes: 14 additions & 0 deletions godot/rust.gdextension
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[configuration]
entry_symbol = "gdext_rust_init"
compatibility_minimum = 4.2
reloadable = false

[libraries]
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.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/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"
76 changes: 44 additions & 32 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# -------------------------------------------------
# Settings
export ANDROID_HOME := `echo "$PWD/dependencies/android-sdk"`
export ANDROID_SDK_ROOT := `echo "$PWD/dependencies/android-sdk"`

# -------------------------------------------------
# Internal Helpers
message := "echo -e \"\n==> \""
Expand All @@ -12,6 +7,7 @@ android_keystore := "secrets/debug.keystore"

# -------------------------------------------------
# Build and export binaries for different platforms
# Sometimes there are 'same' commands, but for different OS
[linux]
linux-debug:
{{rustdir}} cargo build
Expand All @@ -24,13 +20,24 @@ linux-release:

[linux]
android-debug:
{{rustdir}} cargo build --target aarch64-linux-android
{{rustdir}} cargo build --target aarch64-linux-android --config target.aarch64-linux-android.linker=\"../dependencies/android-sdk/ndk/26.3.11579264/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang\"
{{godotdir}} godot --headless --export-debug "Android" "../export/android/Godot Spike.apk"
[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.3.11579264/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang\"
ls rust/target
{{godotdir}} godot --headless --export-release "Android" "../export/android/Godot Spike.apk"
[windows]
android-debug:
{{rustdir}} cargo build --target aarch64-linux-android --config target.aarch64-linux-android.linker=\"../dependencies/android-sdk/ndk/26.3.11579264/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.3.11579264/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 +46,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,52 +68,57 @@ 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
# Execute prior to development of project - installing rust dependencies
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
setup-verify-dependencies:
_setup-verify-dependencies:
@ {{message}} "Verifying all required programs are installed...\nAll programs need to be in \$PATH!"
rustup --version
godot --version
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:
[windows]
[linux]
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..."
[windows]
setup-windows:
@ {{message}} "Installing Rust tools for Windows builds and setup for android export..."
rustup target add x86_64-pc-windows-gnu
_setup-macos:
[macos]
setup-macos:
@ {{message}} "Installing Rust tools for iOS builds..."
rustup target add aarch64-apple-ios
cargo install cargo-lipo
_setup-linux:
[linux]
setup-linux:
@ {{message}} "Setup Linux build tools..."
just _setup-android _setup-debug-keystore
_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"]
49 changes: 32 additions & 17 deletions scripts/install-android-tools.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
#!/bin/bash

# TO USE THE LATEST VERSIONS:
# Update the following strings:
set -o errexit # Abort on nonzero exitstatus
set -o nounset # Abort on unbound variable
set -o pipefail # Don't hide errors within pipes
set -x # Show all executed commands

ANDROID_CMDLINE_URL="https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip"
SDKMANAGER_PACKAGES="ndk;26.2.11394342 build-tools;33.0.0 build-tools;33.0.0 platform-tools"
echo "This script will install the Android SDK into a subdirectory of this repo."
echo

# END OF VARIABLES
# The rest of the script should not have to be touched.
# Determine the operating system
OS=$(uname)
if [[ $OS == "Darwin" ]]; then # MacOS
ANDROID_CMDLINE_URL="https://dl.google.com/android/repository/commandlinetools-mac-11076708_latest.zip"
elif [[ $OS == CYGWIN* || $OS == MINGW* || $OS == MSYS* ]]; then # Windows
ANDROID_CMDLINE_URL="https://dl.google.com/android/repository/commandlinetools-win-11076708_latest.zip"
else # Linux
ANDROID_CMDLINE_URL="https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip"
fi

set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes
set -x # show all executed commands
# To use the latest versions, update the following strings:
ANDROID_API_VERSION="34.0.0"
ANDROID_NDK_VERSION="26.3.11579264"
# Note: Do not forget to update also in justfile

echo "This script will install the Android SDK into a subdirectory of this repo."
echo
SDKMANAGER_PACKAGES="ndk;$ANDROID_NDK_VERSION build-tools;$ANDROID_API_VERSION platform-tools"

# The rest of the script should not have to be touched!

ANDROID_SDK_ROOT="dependencies/android-sdk"
ANDROID_HOME="$ANDROID_SDK_ROOT" # Deprecated: Still used by gradle, once gradle respects ANDROID_SDK_ROOT, this can be removed
_SDKMANAGER="$ANDROID_SDK_ROOT/cmdline-tools/bin/sdkmanager"

# ensure SDK folder is empty
if [[ $OS == CYGWIN* || $OS == MINGW* || $OS == MSYS* ]]; then
SDKMANAGER="$ANDROID_SDK_ROOT/cmdline-tools/bin/sdkmanager.bat"
else
SDKMANAGER="$ANDROID_SDK_ROOT/cmdline-tools/bin/sdkmanager"
fi

# Ensure SDK folder is empty
rm -rf "$ANDROID_SDK_ROOT"
mkdir -p $ANDROID_SDK_ROOT

# install CLI tools
# Install CLI tools
curl $ANDROID_CMDLINE_URL --output /tmp/android_cmd.zip
unzip -d $ANDROID_SDK_ROOT /tmp/android_cmd.zip

# install rest of the requirements using sdkmanager
yes "y" | $_SDKMANAGER --install $SDKMANAGER_PACKAGES --sdk_root="$ANDROID_SDK_ROOT" || true
# Install rest of the requirements using sdkmanager
yes "y" | $SDKMANAGER --install $SDKMANAGER_PACKAGES --sdk_root="$ANDROID_SDK_ROOT" || true

exit 0

0 comments on commit 67fb3e8

Please sign in to comment.