forked from XayahSuSuSu/Android-DataBackup
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRustic Android Native Build.yaml
More file actions
164 lines (147 loc) · 5.11 KB
/
Copy pathRustic Android Native Build.yaml
File metadata and controls
164 lines (147 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Build Rustic-Sql
on:
workflow_dispatch:
inputs:
rustic_version:
description: 'Rustic 版本号 (例如: 0.10.3)'
required: true
default: '0.10.3'
build_android:
description: '是否构建 Android'
required: true
type: boolean
default: true
build_linux:
description: '是否构建 Linux'
required: true
type: boolean
default: false
build_windows:
description: '是否构建 Windows'
required: true
type: boolean
default: false
jobs:
build-android:
if: github.event.inputs.build_android == 'true'
name: build-android (${{ matrix.arch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: arm64
rust_target: aarch64-linux-android
ndk_target: aarch64-linux-android
- arch: armv7
rust_target: armv7-linux-androideabi
ndk_target: armv7a-linux-androideabi
steps:
- name: Checkout Rustic
uses: actions/checkout@v4
with:
repository: 543069760/rustic
ref: main
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_target }}
- name: Build Binary
env:
ANDROID_API: 24
run: |
set -euo pipefail
NDK_DIR="${ANDROID_NDK_LATEST_HOME}"
TOOLCHAIN="$NDK_DIR/toolchains/llvm/prebuilt/linux-x86_64"
TARGET_UPPER=$(echo ${{ matrix.rust_target }} | tr '[:lower:]' '[:upper:]' | tr '-' '_')
CLANG_BIN="$TOOLCHAIN/bin/${{ matrix.ndk_target }}${ANDROID_API}-clang"
AR_BIN="$TOOLCHAIN/bin/llvm-ar"
export "CC_$TARGET_UPPER=$CLANG_BIN"
export "AR_$TARGET_UPPER=$AR_BIN"
export "CARGO_TARGET_${TARGET_UPPER}_LINKER=$CLANG_BIN"
export CC="$CLANG_BIN"
export AR="$AR_BIN"
if [[ "${{ matrix.rust_target }}" == *"armv7"* ]]; then
cargo fetch --target ${{ matrix.rust_target }}
find /home/runner/.cargo/registry/src -name local_destination.rs -exec \
sed -i 's/Mode::empty(), device)/Mode::empty(), device as u32)/g' {} +
fi
cargo build --release --target ${{ matrix.rust_target }} --bin rustic
"$TOOLCHAIN/bin/llvm-strip" target/${{ matrix.rust_target }}/release/rustic
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: rustic-v${{ github.event.inputs.rustic_version }}-${{ matrix.arch }}-android
path: target/${{ matrix.rust_target }}/release/rustic
build-linux:
if: github.event.inputs.build_linux == 'true'
name: build-linux (${{ matrix.target_name }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# --- x86_64 (64-bit) ---
- rust_target: x86_64-unknown-linux-gnu
target_name: x64-gnu
- rust_target: x86_64-unknown-linux-musl
target_name: x64-musl
# --- i686 (32-bit) ---
- rust_target: i686-unknown-linux-gnu
target_name: x86-gnu
- rust_target: i686-unknown-linux-musl
target_name: x86-musl
steps:
- name: Checkout Rustic
uses: actions/checkout@v4
with:
repository: 543069760/rustic
ref: main
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_target }}
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc-multilib musl-tools
- name: Build Binary
run: |
set -euo pipefail
cargo build --release --target ${{ matrix.rust_target }} --bin rustic
strip target/${{ matrix.rust_target }}/release/rustic
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: rustic-v${{ github.event.inputs.rustic_version }}-${{ matrix.target_name }}-linux
path: target/${{ matrix.rust_target }}/release/rustic
build-windows:
if: github.event.inputs.build_windows == 'true'
name: build-windows (${{ matrix.arch }})
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- arch: x86
rust_target: i686-pc-windows-msvc
- arch: x64
rust_target: x86_64-pc-windows-msvc
steps:
- name: Checkout Rustic
uses: actions/checkout@v4
with:
repository: 543069760/rustic
ref: main
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_target }}
- name: Build Binary
run: |
cargo build --release --target ${{ matrix.rust_target }} --bin rustic
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: rustic-v${{ github.event.inputs.rustic_version }}-${{ matrix.arch }}-windows
path: target/${{ matrix.rust_target }}/release/rustic.exe