-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·58 lines (46 loc) · 1.07 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
#!/bin/bash
# Default values
projectName="Steditor"
config="Release"
# Parse command line arguments
while getopts "p:c:" opt; do
case $opt in
p)
projectName=$OPTARG
;;
c)
config=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
# Check if required arguments are provided
if [ -z "$projectName" ] || [ -z "$config" ]; then
echo "Usage: $0 -p {projectName} -c {config (release|debug|dist)}"
exit 1
fi
# Config in lower case
config=$(echo "$config" | tr "[:upper:]" "[:lower:]")
# Config with the first letter capitalized
configDir="$(tr '[:lower:]' '[:upper:]' <<< ${config:0:1})${config:1}"
# Run premake5 to generate makefiles
premake5 gmake &&
# Build the project
make -j10 config=$config &&
# Navigate to the project directory
cd bin/$configDir-linux-x86_64/$projectName &&
# Run the executable
if [ "$config" = "debug" ]; then
gf2 -ex r $projectName
else
./$projectName
fi
# Return to the original directory
cd -