-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sh
executable file
·50 lines (41 loc) · 1.28 KB
/
build.sh
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
#!/bin/bash
set -e
project=$(\
cargo metadata \
--format-version 1 \
--no-deps \
| jq -r '.packages[0].name'
)
#
# This script is used to generate release binaries. It uses cross-rs to
# cross-compile the project to multiple architectures.
#
# If you run into any issues with linking with glibc, run `cargo clean`.
# See: https://github.com/cross-rs/cross/issues/724
#
# Install cross
cargo install cross --git https://github.com/cross-rs/cross
# Set up latest version of upx from git. The current latest release
# (v3.96-git-d7ba31cab8ce+) does not work with the binary generated by rust.
# See: https://github.com/upx/upx/issues/476
mkdir -p target
upxdir=target/.upx
upx=./$upxdir/src/upx.out
if pushd $upxdir; then git pull; popd; else git clone https://github.com/upx/upx.git $upxdir; fi
pushd $upxdir
echo '*' > .gitignore
git submodule update --init --recursive
make
popd
targets=(x86_64-unknown-linux-musl aarch64-unknown-linux-musl x86_64-pc-windows-gnu)
for target in "${targets[@]}"; do
echo "Building $project for $target"
cross build --target $target --release
ext=""
if [[ $target == *"windows"* ]]; then
ext=".exe"
fi
$upx target/$target/release/$project$ext
mv target/$target/release/$project$ext target/$project-$target$ext
done
echo "Done!"