-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·125 lines (102 loc) · 2.94 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
124
125
# exit the script on any error
set -e
# BUILD FUNCTIONS
buildSetup() {
# download E3DBlipKit repo
echo "cloning E3DBlipKit..."
git clone https://github.com/AuzFox/E3DBlipKit.git src/third_party/blipkit/E3DBlipKit
echo "done"
# download raylib 5.0 repo
echo "cloning raylib 5.0..."
git clone --depth 1 --branch 5.0 https://github.com/raysan5/raylib.git src/third_party/raylib/raylib
echo "done"
# create ERA-3D build folders
echo "creating ERA-3D build folders..."
mkdir -p build/include/blipkit
mkdir -p build/lib
echo "done"
}
buildE3DBlipKit() {
# enter E3DBlipKit folder
cd src/third_party/blipkit/E3DBlipKit
# make E3DBlipKit build folder
echo "creating E3DBlipKit build folder..."
mkdir build
cd build
echo "done"
# build E3DBlipKit
echo "compiling E3DBlipKit..."
if [ $os = 'windows' ]; then
cmake -G "MinGW Makefiles" ..
else
cmake ..
fi
make
echo "done"
# copy files to ERA-3D build folder
echo "copying E3DBlipKit files to ERA-3D build folder..."
cp ../src/*.h ../../../../../build/include/blipkit
cp src/libblipkit.a ../../../../../build/lib
echo "done"
# exit E3DBlipKit folder
cd ../../../../../
}
buildRaylib() {
# enter raylib folder
cd src/third_party/raylib/raylib/src
# build raylib
echo "compiling raylib..."
make
echo "done"
# copy files to ERA-3D build folder
echo "copying raylib files to ERA-3D build folder..."
cp raylib.h ../../../../../build/include/
cp raymath.h ../../../../../build/include/
cp rlgl.h ../../../../../build/include/
cp libraylib.a ../../../../../build/lib
echo "done"
# exit raylib folder
cd ../../../../../
}
buildERA3D() {
nelua -C -V --cflags="-Ibuild/include -Lbuild/lib" --release src/main.nelua -o era-3d
}
cleanBuildDirs() {
if [ -e build/ ]; then
rm -r -f build/
fi
if [ -e src/third_party/blipkit/E3DBlipKit ]; then
rm -r -f src/third_party/blipkit/E3DBlipKit
fi
if [ -e src/third_party/raylib/raylib ]; then
rm -r -f src/third_party/raylib/raylib
fi
}
# MAIN SCRIPT
# check arguments
if [ $# -eq 0 ]; then
echo "USAGE: ./build.sh linux/windows/clean"
else
os=$1
if [ $os = 'linux' ] || [ $os = 'windows' ]; then
echo "starting build..."
buildSetup
echo "done starting build"
echo "building E3DBlipKit..."
buildE3DBlipKit
echo "done building E3DBlipKit"
echo "building raylib..."
buildRaylib
echo "done building raylib"
echo "building ERA-3D..."
buildERA3D
echo "done building ERA-3D"
echo "ERA-3D built successfully"
elif [ $os = 'clean' ]; then
echo "cleaning build folders..."
cleanBuildDirs
echo "done cleaning build folders"
else
echo "invalid OS '$os', must be 'linux' or 'windows'"
fi
fi