mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew
synced 2026-01-12 08:12:36 +08:00
Add more targets when build
This commit is contained in:
@@ -2,7 +2,8 @@ name: Build release binaries
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags: 'v*'
|
branches: '**'
|
||||||
|
tags: '*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -20,6 +21,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: '18'
|
node-version: '18'
|
||||||
|
|
||||||
|
- name: Install android NDK
|
||||||
|
id: setup-ndk
|
||||||
|
uses: https://github.com/nttld/setup-ndk@v1
|
||||||
|
with:
|
||||||
|
ndk-version: r29
|
||||||
|
|
||||||
- name: Create out directory
|
- name: Create out directory
|
||||||
run: |
|
run: |
|
||||||
mkdir out
|
mkdir out
|
||||||
@@ -30,21 +37,75 @@ jobs:
|
|||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
- name: Build x86_64-unknown-linux-gnu
|
- name: Install cargo ndk
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
. "$HOME/.cargo/env"
|
. "$HOME/.cargo/env"
|
||||||
cargo build --target x86_64-unknown-linux-gnu --release || echo "Failed to build"
|
cargo install cargo-ndk
|
||||||
mv target/x86_64-unknown-linux-gnu/release/ew out/ew-x86_64-unknown-linux-gnu
|
rustup target add aarch64-linux-android
|
||||||
|
|
||||||
- name: Build x86_64-pc-windows-gnu
|
- name: Write cargo linker config
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||||
|
run: |
|
||||||
|
mkdir -p .cargo
|
||||||
|
echo "[target.aarch64-linux-android]" > .cargo/config.toml
|
||||||
|
echo "linker = \"$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang\"" >> .cargo/config.toml
|
||||||
|
echo "ar = \"$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar\"" >> .cargo/config.toml
|
||||||
|
echo "" >> .cargo/config.toml
|
||||||
|
echo "[target.aarch64-unknown-linux-gnu]" >> .cargo/config.toml
|
||||||
|
echo "linker = \"aarch64-linux-gnu-gcc\"" >> .cargo/config.toml
|
||||||
|
echo "ar = \"aarch64-linux-gnu-ar\"" >> .cargo/config.toml
|
||||||
|
echo "" >> .cargo/config.toml
|
||||||
|
echo "[target.x86_64-linux-android]" >> .cargo/config.toml
|
||||||
|
echo "linker = \"$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang\"" >> .cargo/config.toml
|
||||||
|
echo "ar = \"$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar\"" >> .cargo/config.toml
|
||||||
|
|
||||||
|
- name: Build Stuff
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||||
run: |
|
run: |
|
||||||
. "$HOME/.cargo/env"
|
. "$HOME/.cargo/env"
|
||||||
sudo apt update && sudo apt install gcc-mingw-w64 -y
|
export PATH=$PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/
|
||||||
rustup target add x86_64-pc-windows-gnu
|
sudo apt update && sudo apt install gcc-mingw-w64 gcc-aarch64-linux-gnu -y
|
||||||
cargo build --target x86_64-pc-windows-gnu --release || echo "Failed to build"
|
|
||||||
mv target/x86_64-pc-windows-gnu/release/ew.exe out/ew-x86_64-pc-windows-gnu.exe
|
arr=("aarch64-linux-android" "aarch64-unknown-linux-gnu" "x86_64-linux-android" "x86_64-pc-windows-gnu" "x86_64-unknown-linux-gnu")
|
||||||
|
for target in "${arr[@]}"; do
|
||||||
|
rustup target add $target
|
||||||
|
cargo build --target $target --release || echo "Failed to build"
|
||||||
|
if [[ "$target" == *"windows"* ]]; then
|
||||||
|
mv target/$target/release/ew.exe out/ew-$target.exe
|
||||||
|
else
|
||||||
|
mv target/$target/release/ew out/ew-$target
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Patch for library build
|
||||||
|
run: |
|
||||||
|
sed -i 's|#\[lib\]|\[lib\]|g' Cargo.toml
|
||||||
|
sed -i 's|#crate-type|crate-type|g' Cargo.toml
|
||||||
|
sed -i 's|#required-features|required-features|g' Cargo.toml
|
||||||
|
|
||||||
|
- name: Build jnilibs
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||||
|
run: |
|
||||||
|
. "$HOME/.cargo/env"
|
||||||
|
cargo ndk -t arm64-v8a build --release --features library
|
||||||
|
mv target/aarch64-linux-android/release/libew.so out/libew-aarch64-linux-android.so
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
if: startsWith(github.ref, 'refs/heads/')
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: output
|
||||||
|
path: ./out/
|
||||||
|
|
||||||
- name: Publish release
|
- name: Publish release
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
uses: actions/forgejo-release@v2
|
uses: actions/forgejo-release@v2
|
||||||
with:
|
with:
|
||||||
direction: upload
|
direction: upload
|
||||||
|
|||||||
Reference in New Issue
Block a user