-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·60 lines (51 loc) · 1.63 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
#!/bin/sh
if [ ! -e /bin/zip ]; then
echo "zip utility is not installed in your system!"
echo "install it using package manager available in your system!"
echo "Example for Ubuntu/Debian based systems :"
echo " \$ sudo apt install zip"
echo "Example for Redhat/Fedora/CentOS based systems :"
echo " \$ sudo dnf install zip"
echo "Example for Archlinux based systems :"
echo " \$ sudo pacman -S zip"
echo "Example for OpenSUSE based systems :"
echo " \$ sudo zypper install zip"
exit -1
fi
if [ ! -e /bin/luajit ]; then
echo "liajit is not installed in your system!"
echo "install it using package manager available in your system!"
echo "Example for Ubuntu/Debian based systems :"
echo " \$ sudo apt install luajit"
echo "Example for Redhat/Fedora/CentOS based systems :"
echo " \$ sudo dnf install luajit"
echo "Example for Archlinux based systems :"
echo " \$ sudo pacman -S luajit"
echo "Example for OpenSUSE based systems :"
echo " \$ sudo zypper install luajit"
exit -1
fi
echo "Cleaning up and make it ready..."
# remove builded game
rm -f ./game.love
# cleanup build directory and make it again
rm -rf ./build
mkdir -p ./build
# copy game into build folder
cd ./game
cp -r ./ ../build
cd ..
echo "Compiling sources into bytecode..."
# enter build directory
cd ./build
# function to run on any lua file
compile(){
echo "Compiling $1..."
luajit -b $1 $1
return $?
}
export -f compile # make function available in subshells
# find all lus files and compile it
find . -name '*.lua' -print0 | xargs -0 -I {} bash -c 'compile "$@"' _ {}
echo "Packing your game into archive..."
zip -9 -r ../game.love ./ # and pack into zip archive