-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·203 lines (184 loc) · 3.76 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/bash
function findAndCopyDLL()
{
for i in "${paths[@]}"
do
FILE="$i/$1"
if [ -f $FILE ]; then
echo -e "\033[1;34mFound DLL $FILE\033[0m"
cp $FILE build/
return 0
fi
done
return 1
}
function mergeLibs()
{
cd $1
for lib in *.a
do
cp $lib $lib.tmp
echo -e "\033[1;34mMerging $lib\033[0m"
if [[ $WINDOWS -eq 0 ]];
then
mkdir "$lib-o"
ar -x $lib
mv *.obj "$lib-o"
ar -r libjGLMerged.a "$lib-o/"*
rm -rf "$lib-o"
else
mkdir "$lib-o"
ar -x $lib
mv *.o "$lib-o"
ar -r libjGLMerged.a "$lib-o/"*
rm -rf "$lib-o"
fi
mv $lib.tmp $lib
done
mv libjGLMerged.a libjGL.a
cd ..
}
WINDOWS=1
RELEASE=0
TEST=0
OSX=1
VALIDATION=0
VERBOSE=0
VK_SDK="include/vendored/VulkanSDK"
BENCHMARK=0
EXAMPLES=0
CLEAN=1
NO_WARN=0
SANITISE=0
while [[ $# -gt 0 ]]; do
case $1 in
-w|--windows)
WINDOWS=0
shift # past argument
;;
-e|--examples)
EXAMPLES=1
shift
;;
-v|--validation)
VALIDATION=1
shift
;;
-vv|--verbose-validation)
VALIDATION=1
VERBOSE=1
shift
;;
--vk)
VK_SDK=$2
shift
shift
;;
-o|--osx)
OSX=0
shift
;;
-r|--release)
RELEASE=1
shift
;;
-b|--benchmark)
BENCHMARK=1
shift
;;
-t|--test)
TEST=1
shift
;;
--sanitise)
SANITISE=1
shift
;;
-d|--development)
NO_WARN=1
shift
;;
-c|--continue)
CLEAN=0
shift
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
export VULKAN_SDK=$VK_SDK
export VULKAN_LIBRARY="$VK_SDK/Linux/Lib"
export VULKAN_INCLUDE_DIR="$VK_SDK/Include"
if [[ $CLEAN -eq 1 ]];
then
for file in build CMakeFiles cmake_install.cmake CMakeCache.txt Makefile Particles
do
if [ -d $file ];
then
rm -rf $file
fi
if [ -f $file ];
then
rm $file
fi
done
cmake -E make_directory build
fi
if [[ $WINDOWS -eq 0 ]];
then
export VULKAN_SDK=$VK_SDK/Windows
export VULKAN_LIBRARY="$VK_SDK/Windows/Lib"
export VULKAN_INCLUDE_DIR="$VK_SDK/Include"
dir=$(pwd)
ln -s "$dir/$VK_SDK/Windows/Lib" "$dir/$VK_SDK/Windows/lib"
ln -s "$dir/$VK_SDK/Include" "$dir/$VK_SDK/Windows/Include"
ln -s "$dir/$VK_SDK/Windows/Include" "$dir/$VK_SDK/Windows/include"
cd build
cmake .. -D WINDOWS=ON -D SANITISE=$SANITISE -D VERBOSE=$VERBOSE -D EXAMPLES=$EXAMPLES -D VALIDATION=$VALIDATION -D RELEASE=$RELEASE -D TEST_SUITE=$TEST -D NO_WARN=$NO_WARN -D CMAKE_TOOLCHAIN_FILE=./windows.cmake
make -j 4
export STATUS=$?
cd ..
# now copy dlls
PREFIX="x86_64-w64-mingw32"
paths=("/usr/local/mingw64/bin"
"/usr/local/mingw64/bin/x64"
"/usr/$PREFIX/bin"
"/usr/$PREFIX/lib"
)
for p in /usr/lib/gcc/$PREFIX/*
do
paths+=($p)
done
echo -e "\n###############\nChecking Paths: \n"
for p in "${paths[@]}"
do
echo -e "$p\n"
done
echo -e "###############\n"
dll=()
for j in "${dll[@]}"
do
findAndCopyDLL $j || echo "Could not find $j"
done
elif [[ $OSX -eq 0 ]];
then
cd build
cmake .. -D OSX=ON -D RELEASE=$RELEASE -D SANITISE=$SANITISE -D TEST_SUITE=$TEST -D EXAMPLES=$EXAMPLES -D NO_WARN=$NO_WARN -D CMAKE_TOOLCHAIN_FILE=./osx.cmake
make -j 4
export STATUS=$?
cd ..
else
cd build
cmake -D BENCHMARK=$BENCHMARK -D SANITISE=$SANITISE -D VERBOSE=$VERBOSE -D VALIDATION=$VALIDATION -D RELEASE=$RELEASE -D TEST_SUITE=$TEST -D NO_WARN=$NO_WARN -D EXAMPLES=$EXAMPLES ..
make -j 4
export STATUS=$?
cd ..
fi
mergeLibs "build"
exit $STATUS