-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·99 lines (81 loc) · 1.81 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
#!/bin/bash
path=$(dirname "$0")
LIBRARY_NAME="s3-lite"
LIBRARY_TYPE="plugin"
# Verify arguments
usage() {
echo "$0 [daily_build_number [dst_dir]]"
echo ""
echo " daily_build_number: The daily build number, e.g. 2015.2560"
echo " dst_dir: If not provided, will be '$path/build'"
exit -1
}
# Checks exit value for error
checkError() {
if [ $? -ne 0 ]; then
echo "Exiting due to errors (above)"
exit -1
fi
}
# Canonicalize relative paths to absolute paths
pushd "$path" > /dev/null
dir=$(pwd)
path=$dir
popd > /dev/null
# Default target version.
BUILD_TARGET="$1"
if [ -z "$BUILD_TARGET" ]; then
BUILD_TARGET="2017.3032"
fi
# Default build directory.
BUILD_DIR="$2"
if [ ! -e "$BUILD_DIR" ]; then
BUILD_DIR="$path/build"
fi
# Set lua compiler.
LUAC="$path/bin/luac"
BUILD_TARGET_VM="lua_51"
if [ ! -z "$3" ]; then
LUAC="$path/bin/luac-$3"
BUILD_TARGET_VM="$3"
# Verify that this VM is supported.
if [ ! -f "$LUAC" ]; then
echo "Error: Lua VM '$3' is not supported."
exit -1
fi
fi
# Clean build directory.
if [ -e "$BUILD_DIR" ]; then
rm -rf "$BUILD_DIR"
fi
# Get our Lua directory.
BUILD_DIR_LUA="$BUILD_DIR/plugins/$BUILD_TARGET/lua/$BUILD_TARGET_VM"
mkdir -p "$BUILD_DIR_LUA"
# Copy
echo "[copy]"
cp -vrf "$path/lua/$LIBRARY_TYPE" "$BUILD_DIR_LUA"
checkError
cp -vrf "$path"/metadata.json "$BUILD_DIR"
checkError
# Compile lua files.
echo ""
echo "[compile]"
"$LUAC" -v
checkError
find "$BUILD_DIR_LUA" -type f -name "*.lua" | while read luaFile; do
echo "compiling: $luaFile"
"$LUAC" -s -o "$luaFile" -- "$luaFile"
checkError
done
checkError
echo ""
echo "[zip]"
ZIP_FILE="$path/plugin-$LIBRARY_NAME.zip"
cd "$BUILD_DIR" > /dev/null
rm -f "$ZIP_FILE"
zip -r -x '*.DS_Store' @ "$ZIP_FILE" ./*
cd - > /dev/null
echo ""
echo "[complete]"
echo "Plugin build succeeded."
echo "Zip file located at: '$ZIP_FILE'"