-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·123 lines (98 loc) · 3.3 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
116
117
118
119
120
121
122
123
#!/bin/sh
set -e
DIST_DIR="./dist"
compile_all() {
if [ "$ONYX_RUNTIME_LIBRARY" = "ovmwasm" ]; then
cd interpreter
./build.sh $1
cd ..
fi
cd compiler
./build.sh $1
cd ..
if [ ! -z ${ONYX_RUNTIME_LIBRARY+x} ]; then
cd runtime
./build.sh $1
cd ..
fi
}
package_all() {
rm -rf "$DIST_DIR"
mkdir -p "$DIST_DIR"
echo "Installing on '$(uname -a)'"
echo "Installing core libs"
[ -d "$DIST_DIR/core" ] && rm -r "$DIST_DIR/core"
cp -r ./core "$DIST_DIR/core"
echo "Installing core tools"
mkdir -p "$DIST_DIR/bin"
cp compiler/onyx "$DIST_DIR/bin/"
mkdir -p "$DIST_DIR/tools"
mkdir -p "$DIST_DIR/tools/pkg_templates"
cp ./scripts/onyx-pkg.onyx "$DIST_DIR/tools"
cp ./scripts/default.json "$DIST_DIR/tools/pkg_templates"
if [ ! -z ${ONYX_RUNTIME_LIBRARY+x} ]; then
echo "Installing runtime library"
mkdir -p "$DIST_DIR/lib"
mkdir -p "$DIST_DIR/include"
case "$(uname)" in
Linux) suffix='so' ;;
*BSD) suffix='so' ;;
Darwin) suffix='dylib' ;;
*) suffix='dll' ;;
esac
[ -f runtime/onyx_runtime.$suffix ] && cp runtime/onyx_runtime.$suffix "$DIST_DIR/lib/"
cp "shared/include/onyx_library.h" "$DIST_DIR/include/onyx_library.h"
cp "shared/include/wasm.h" "$DIST_DIR/include/wasm.h"
fi
cp -r "examples" "$DIST_DIR/"
mkdir -p "$DIST_DIR/misc"
cp misc/onyx-linux.sublime-build "$DIST_DIR/misc"
cp misc/onyx-windows.sublime-build "$DIST_DIR/misc"
cp misc/onyx-mode.el "$DIST_DIR/misc"
cp misc/onyx.sublime-syntax "$DIST_DIR/misc"
cp misc/onyx.tmPreferences "$DIST_DIR/misc"
cp misc/vscode/onyxlang-0.1.9.vsix "$DIST_DIR/misc"
cp LICENSE "$DIST_DIR/LICENSE"
}
compress_all() {
package_all
# Sign the binaries on MacOS
[ "$(uname)" = 'Darwin' ] && \
codesign -s - "$DIST_DIR/bin/onyx" && \
[ -f "$DIST_DIR/lib/onyx_runtime.dylib" ] && \
codesign -s - "$DIST_DIR/lib/onyx_runtime.dylib"
if [ ! -z ${ONYX_RUNTIME_LIBRARY+x} ]; then
# When including a runtime library, include the lib and include folders
tar -C "$DIST_DIR" -zcvf onyx.tar.gz bin core examples include lib misc tools LICENSE
else
tar -C "$DIST_DIR" -zcvf onyx.tar.gz bin core examples misc tools LICENSE
fi
mv onyx.tar.gz dist/
}
install_all() {
[ -z ${ONYX_INSTALL_DIR+x} ] && echo "Please set ONYX_INSTALL_DIR to install Onyx." && exit 1
package_all
echo "Installing to $ONYX_INSTALL_DIR"
mkdir -p "$ONYX_INSTALL_DIR"
cp -r "$DIST_DIR/." "$ONYX_INSTALL_DIR"
# Sign the binaries on MacOS
[ "$(uname)" = 'Darwin' ] && \
codesign -s - "$ONYX_INSTALL_DIR/bin/onyx" && \
[ -f "$ONYX_INSTALL_DIR/lib/onyx_runtime.dylib" ] && \
codesign -s - "$ONYX_INSTALL_DIR/lib/onyx_runtime.dylib"
}
for arg in $@; do
case "$arg" in
compile) compile_all ;;
debug) compile_all debug ;;
package) package_all ;;
compress) compress_all ;;
install) install_all ;;
clean)
rm -f compiler/onyx 2>/dev/null
rm -f runtime/onyx_runtime.so 2>/dev/null
;;
esac
done
# Otherwise the prompt ends on the same line
printf "\n"