/
build_all.sh
executable file
·55 lines (46 loc) · 1.48 KB
/
build_all.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
51
52
53
54
55
#! /bin/bash
# support: ARM64, ARMv7, x86_64 linux, Windows x86_64
targets=("aarch64-unknown-linux-gnu" "armv7-unknown-linux-gnueabihf" "x86_64-unknown-linux-musl" "x86_64-unknown-linux-gnu" "x86_64-pc-windows-gnu")
binaries=("xelis_daemon" "xelis_miner" "xelis_wallet")
extra_files=("README.md" "API.md")
# verify that we have cross installed
if ! command -v cross &> /dev/null
then
echo "cross could not be found, please install it for cross compilation"
exit
fi
# Cross needs docker to be running
echo "Starting docker daemon"
sudo systemctl start docker
# compile all binaries for all targets
echo "Compiling binaries for all targets"
for target in "${targets[@]}"; do
cross build --target $target --profile release-with-lto
done
echo "Deleting build folder"
rm -rf build
echo "Creating archives for all targets"
for target in "${targets[@]}"; do
mkdir -p build/$target
# copy generated binaries to build directory
for binary in "${binaries[@]}"; do
# add .exe extension to windows binaries
if [[ "$target" == *"windows"* ]]; then
binary="$binary.exe"
fi
cp target/$target/release-with-lto/$binary build/$target/$binary
done
# copy extra files
for file in "${extra_files[@]}"; do
cp $file build/$target/$file
done
# create archive
cd build/
if [[ "$target" == *"windows"* ]]; then
zip -r $target.zip $target
else
tar -czf $target.tar.gz $target
fi
cd ..
done
echo "Done"