-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
run_build_dist.sh
executable file
·86 lines (76 loc) · 2.41 KB
/
run_build_dist.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
82
83
84
85
86
#!/bin/bash
# stop if there is an error, u complains for undefined vars
set -eu
APP_NAME=sandbox
UBUNTU=x86_64-unknown-linux-gnu
WINDOWS=x86_64-pc-windows-gnu
MACOS=x86_64-apple-darwin
BUILD_DIR=build
if [[ ! "$OSTYPE" == "linux-gnu"* ]]; then
echo "Not on Linux, build not run"
exit 1
fi
echo "Building for ubuntu"
rustup target add $UBUNTU
rustup toolchain install stable-$UBUNTU
cargo build --package sandbox --release --target $UBUNTU
BUILD_UBUNTU_SUCCESS=$?
# Ubuntu dist
if [ $BUILD_UBUNTU_SUCCESS -eq 0 ]; then
mkdir -p $BUILD_DIR/sandbox_ubuntu
mkdir -p $BUILD_DIR/sandbox_ubuntu/assets
cp -r assets/object_images $BUILD_DIR/sandbox_ubuntu/assets
cp target/$UBUNTU/release/$APP_NAME $BUILD_DIR/sandbox_ubuntu/
cd $BUILD_DIR
zip -r sandbox_ubuntu.zip sandbox_ubuntu
cd ../
rm -rf $BUILD_DIR/sandbox_ubuntu
else
echo "Ubuntu Build failed"
fi
# Assumes following has been done
rustup target add $WINDOWS
rustup toolchain install stable-$WINDOWS
sudo apt install mingw-w64
echo "Building for windows"
cargo build --package sandbox --release --target $WINDOWS
BUILD_WINDOWS_SUCCESS=$?
# Windows dist
if [ $BUILD_WINDOWS_SUCCESS -eq 0 ]; then
mkdir -p $BUILD_DIR/sandbox_windows
mkdir -p $BUILD_DIR/sandbox_windows/assets
cp -r assets/object_images $BUILD_DIR/sandbox_windows/assets
cp target/$WINDOWS/release/$APP_NAME.exe $BUILD_DIR/sandbox_windows/
cd $BUILD_DIR
zip -r sandbox_windows.zip sandbox_windows
cd ../
rm -rf $BUILD_DIR/sandbox_windows
else
echo "Windows Build failed"
fi
# If osxcross does not exist, run it ./osxcross_setup.sh
[ ! -d "$(pwd)/osxcross/target/bin" ] && ./osxcross_setup.sh
echo "Building for MacOS"
rustup target add $MACOS
rustup toolchain install stable-$MACOS
PATH="$(pwd)/osxcross/target/bin:$PATH" \
CC=o64-clang \
LIBZ_SYS_STATIC=1 \
MAC_OS_BUILD=1 \
C_INCLUDE_PATH=$(pwd)/osxcross/target/SDK/MacOSX10.15.sdk/usr/include \
RUSTFLAGS="-C linker=x86_64-apple-darwin19-clang" \
cargo build --package sandbox --release --target $MACOS
BUILD_MACOS_SUCCESS=$?
# MacOS build
if [ $BUILD_MACOS_SUCCESS -eq 0 ]; then
mkdir -p $BUILD_DIR/sandbox_macos
mkdir -p $BUILD_DIR/sandbox_macos/assets
cp -r assets/object_images $BUILD_DIR/sandbox_macos/assets
cp target/$MACOS/release/$APP_NAME $BUILD_DIR/sandbox_macos/
cd $BUILD_DIR
zip -r sandbox_macos.zip sandbox_macos
cd ../
rm -rf $BUILD_DIR/sandbox_macos
else
echo "MacOS Build failed"
fi