diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 318e6d8..1a9fe0b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,4 +8,4 @@ updates: - package-ecosystem: "cargo" # See documentation for possible values directory: "rust" # Location of package manifests schedule: - interval: "weekly" + interval: "daily" diff --git a/.github/workflows/gut.yml b/.github/workflows/gut.yml index c62201f..660b4e3 100644 --- a/.github/workflows/gut.yml +++ b/.github/workflows/gut.yml @@ -1,5 +1,6 @@ name: "Godot" -on: push + +on: [push] jobs: execute-gut: @@ -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 \ No newline at end of file diff --git a/.github/workflows/linux_build.yml b/.github/workflows/linux_build.yml index a0b5ba0..85a79e8 100644 --- a/.github/workflows/linux_build.yml +++ b/.github/workflows/linux_build.yml @@ -1,4 +1,4 @@ -name: Linux Build Test +name: Linux Build on: [push] diff --git a/.github/workflows/linux_export.yml b/.github/workflows/linux_export.yml new file mode 100644 index 0000000..97f9788 --- /dev/null +++ b/.github/workflows/linux_export.yml @@ -0,0 +1,83 @@ +name: Linux Export + +on: [push] + +env: + CARGO_TERM_COLOR: always + RUSTFLAGS: -Dwarnings + CARGO_INCREMENTAL: 0 + +jobs: + export-linux: + 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: | + cargo build --manifest-path=rust/Cargo.toml + just linux-release + + export-android: + 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 + + - name: Godot Export + run: | + set -x + 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 + export GODOT_ANDROID_KEYSTORE_RELEASE_PATH="$PWD/secrets/debug.keystore" + export GODOT_ANDROID_KEYSTORE_RELEASE_USER="androiddebugkey" + export GODOT_ANDROID_KEYSTORE_RELEASE_PASSWORD="android" + just setup-android + cargo build --manifest-path=rust/Cargo.toml + just android-release diff --git a/.github/workflows/windows_build.yml b/.github/workflows/windows_build.yml index 8293c4c..0d2dc8b 100644 --- a/.github/workflows/windows_build.yml +++ b/.github/workflows/windows_build.yml @@ -1,4 +1,4 @@ -name: Windows Build Test +name: Windows Build on: [push] diff --git a/godot/RustPlugin.gdextension b/godot/RustPlugin.gdextension deleted file mode 100644 index d08c21d..0000000 --- a/godot/RustPlugin.gdextension +++ /dev/null @@ -1,20 +0,0 @@ -[configuration] -entry_symbol = "gdext_rust_init" -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" - -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" - -windows.debug.x86_64 = "res://../rust/target/debug/godot_plugin.dll" -windows.release.x86_64 = "res://../rust/target/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" diff --git a/godot/export_presets.cfg b/godot/export_presets.cfg index c8917d3..cbe21de 100644 --- a/godot/export_presets.cfg +++ b/godot/export_presets.cfg @@ -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 diff --git a/godot/rust.gdextension b/godot/rust.gdextension new file mode 100644 index 0000000..bc7aa54 --- /dev/null +++ b/godot/rust.gdextension @@ -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" diff --git a/justfile b/justfile index 146ee1e..5db835e 100644 --- a/justfile +++ b/justfile @@ -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==> \"" @@ -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 @@ -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: @@ -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] @@ -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 diff --git a/rust/.cargo/config.toml b/rust/.cargo/config.toml index c917ac3..d29d6c3 100644 --- a/rust/.cargo/config.toml +++ b/rust/.cargo/config.toml @@ -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"] diff --git a/scripts/install-android-tools.sh b/scripts/install-android-tools.sh index 20a84bd..54aca94 100755 --- a/scripts/install-android-tools.sh +++ b/scripts/install-android-tools.sh @@ -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