-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompile.sh
executable file
·51 lines (46 loc) · 1.11 KB
/
compile.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
#!/bin/bash
MOONC="${MOONC:-moonc}"
LUAC="${LUAC:-luac}"
is_binary=false
is_forcing=false
for arg in $*; do
case $arg in
--bytecode|-b)
is_binary=true
;;
--force-compile|-f)
is_forcing=true
;;
--help|-h)
echo "Usage: ./compile.sh [OPTIONS]"
echo "Compile MoonScript files into Lua files - binary or source"
echo ""
echo " -f, --force-compile Force recompilation of all files"
echo " -b, --bytecode Files are compiled to Lua bytecode"
echo " -h, --help Display this message"
exit 0
;;
esac
done
find_command() {
while (( "$#" )); do
which "$1" >/dev/null 2>&1 || exit $?
echo "Using $(which $1)"
shift
done
}
find_command $MOONC $LUAC
for file in $(find . -type f -name "*.moon"); do
(
luafile="${file%.*}.lua"
if [ ! -f "$luafile" ] || [ $(stat -c "%Y" "${file}" ) -gt $(stat -c "%Y" "$luafile") ] || "$is_forcing"; then
if $is_binary; then
$MOONC -p "$file" | $LUAC -o "$luafile" -
else
$MOONC -o "$luafile" "$file"
fi
fi
) &
done
wait
ldoc . 2>&1 | grep -v 'module()'