-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·62 lines (55 loc) · 1.33 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
#!/bin/bash
# python build script
# Author: blix
NAME=false
TESTRUN=false
help()
{
echo ""
echo "Usage: $0 -n <name>"
echo -e "-n <name> : name of compiled application"
echo -e "-r : run application after building"
echo -e "-h : display help"
echo ""
exit 1
}
error()
{
echo -e "\nplease use -h for help\n"
exit 1
}
while getopts "n:hr" opt
do
case "$opt" in
n ) NAME="$OPTARG" ;; # set name value
r ) TESTRUN=true ;; # run executable after building
h ) help ;; # call help function
? ) error ;; # call error function
esac
done
if [ -z "$NAME" ]
then
echo -e "\nplease supply a name value\n"
fi
if [ ! -z "$NAME" ] && [ "$NAME" != false ]
then
echo -e " - starting build - "
echo -e "building: $NAME"
mkdir build # create build directory
echo -e "created directory: build"
zip -r ./build/build.zip * -x '*build*' '*temp*' # zip all files excluding build files
echo -e "created file: build.zip"
cd build # change to build directory
echo '#!/usr/bin/env python3' | cat - build.zip > $NAME # add shebang to new file
chmod +x $NAME # make file executable
echo -e "created executable: $NAME"
cd .. # change back to main directory
echo -e " - build complete - \n"
fi
if [ "$TESTRUN" = true ]
then
echo -e " - test run - \n"
cd build # change to build directory
./$NAME # run executable
echo -e "\n - test complete - "
fi