-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·115 lines (91 loc) · 2.51 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
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
#!/bin/bash
set -u
shopt -s globstar
NAME='bevy-jam-simulator'
EXE='run'
BUILD_DIR='build'
function usage() {
echo "Usage: $0 [web|windows|linux|mac]..."
}
# Web
function web() {
PLATFORM='web'
TARGET='wasm32-unknown-unknown'
OUT_DIR="${BUILD_DIR}/${PLATFORM}"
OUT_ZIP="${BUILD_DIR}/${NAME}-${PLATFORM}.zip"
# Clear output location
mkdir -p "${OUT_DIR}"
rm -rf "${OUT_DIR:?}/"* "${OUT_ZIP}"
# Build
cargo build --profile=wasm-release --target="${TARGET}" --features=web
wasm-bindgen --no-typescript --out-name "${EXE}" --out-dir "${OUT_DIR}" --target web "target/${TARGET}/wasm-release/${EXE}.wasm"
wasm-opt -O -ol 100 -s 100 -o "${OUT_DIR}/${EXE}_bg.wasm" "${OUT_DIR}/${EXE}_bg.wasm"
# Prepare zip
cp -r assets web/* "${OUT_DIR}"
rm "${OUT_DIR:?}"/**/*.aseprite
zip -r "${OUT_ZIP}" "${OUT_DIR}"
}
# Windows
function windows() {
PLATFORM='windows'
TARGET='x86_64-pc-windows-gnu'
OUT_DIR="${BUILD_DIR}/${PLATFORM}"
OUT_ZIP="${BUILD_DIR}/${NAME}-${PLATFORM}.zip"
# Clear output location
mkdir -p "${OUT_DIR}"
rm -rf "${OUT_DIR:?}"/* "${OUT_ZIP}"
# Build
cargo build --release --target="${TARGET}" --features=native
# Prepare zip
cp -r assets "target/${TARGET}/release/${EXE}.exe" "${OUT_DIR}"
rm "${OUT_DIR:?}"/**/*.aseprite
zip -r "${OUT_ZIP}" "${OUT_DIR}"
}
# Linux
function linux() {
PLATFORM='linux'
TARGET='x86_64-unknown-linux-gnu'
OUT_DIR="${BUILD_DIR}/${PLATFORM}"
OUT_ZIP="${BUILD_DIR}/${NAME}-${PLATFORM}.zip"
# Clear output location
mkdir -p "${OUT_DIR}"
rm -rf "${OUT_DIR:?}"/* "${OUT_ZIP}"
# Build
cargo build --release --target="${TARGET}" --features=native,bevy/wayland
# Prepare zip
cp -r assets "target/${TARGET}/release/${EXE}" "${OUT_DIR}"
rm "${OUT_DIR:?}"/**/*.aseprite
zip -r "${OUT_ZIP}" "${OUT_DIR}"
}
# FIXME: Requires a cross-compiler?
# Mac
function mac() {
PLATFORM='mac'
TARGET='x86_64-apple-darwin'
OUT_DIR="${BUILD_DIR}/${PLATFORM}"
OUT_ZIP="${BUILD_DIR}/${NAME}-${PLATFORM}.zip"
# Clear output location
mkdir -p "${OUT_DIR}"
rm -rf "${OUT_DIR:?}"/* "${OUT_ZIP}"
# Build
cargo build --release --target="${TARGET}" --features=native
# Prepare zip
cp -r assets "target/${TARGET}/release/${EXE}.exe" "${OUT_DIR}"
rm "${OUT_DIR:?}"/**/*.aseprite
zip -r "${OUT_ZIP}" "${OUT_DIR}"
}
function main() {
[ "$#" -eq 0 ] && usage
while [ "$#" -ge 1 ]; do
case "$1" in
web) web ;;
windows) windows ;;
linux) linux ;;
mac) mac ;;
*) usage ;;
esac
shift 1
done
}
main "$@"
exit 0