-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathbuild_all.sh
executable file
·81 lines (70 loc) · 2.15 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
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
#! /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" "CHANGELOG.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
# generate checksums
echo "Generating checksums for $target"
cd build/$target
> checksums.txt
for binary in "${binaries[@]}"; do
# add .exe extension to windows binaries
if [[ "$target" == *"windows"* ]]; then
binary="$binary.exe"
fi
sha256sum $binary >> checksums.txt
done
cd ../..
# create archive
cd build/
if [[ "$target" == *"windows"* ]]; then
zip -r $target.zip $target
else
tar -czf $target.tar.gz $target
fi
cd ..
done
# Generate final checksums.txt in build/
echo "Generating final checksums.txt in build/"
cd build/
> checksums.txt
for target in "${targets[@]}"; do
if [[ "$target" == *"windows"* ]]; then
sha256sum $target.zip >> checksums.txt
else
sha256sum $target.tar.gz >> checksums.txt
fi
done
cd ..
echo "Done"