-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·128 lines (116 loc) · 2.5 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
#!/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
}
WINDOWS=1
RELEASE=0
TEST=0
OSX=1
VALIDATION=0
VK_SDK="include/vendored/VulkanSDK"
while [[ $# -gt 0 ]]; do
case $1 in
-w|--windows)
WINDOWS=0
shift # past argument
;;
-v|--validation)
VALIDATION=1
shift
;;
--vk)
VK_SDK=$2
shift
shift
;;
-o|--osx)
OSX=0
shift
;;
-r|--release)
RELEASE=1
shift
;;
-t|--test)
TEST=1
shift
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
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
if [[ $WINDOWS -eq 0 ]];
then
cmake -E make_directory build
export VULKAN_SDK=$VK_SDK/Windows
export VULKAN_LIBRARY="$VK_SDK/Windows/Lib"
export VULKAN_INCLUDE_DIR="$VK_SDK/Windows/Include"
cmake -E chdir build cmake .. --debug-find -D WINDOWS=ON -D RELEASE=$RELEASE -D CMAKE_TOOLCHAIN_FILE=./windows.cmake && make -j 8 -C build
# 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=(
"libwinpthread-1.dll"
)
for j in "${dll[@]}"
do
findAndCopyDLL $j || echo "Could not find $j"
done
elif [[ $OSX -eq 0 ]];
then
cmake -E make_directory build
cmake -E chdir build cmake .. -D OSX=ON -D RELEASE=$RELEASE -D VALIDATION=$VALIDATION -D CMAKE_TOOLCHAIN_FILE=./osx.cmake && make -j 8 -C build
else
cmake -E make_directory build
cmake -E chdir build cmake -D RELEASE=$RELEASE -D VALIDATION=$VALIDATION .. && make -j 8 -C build
fi
echo -e "\033[1;32mCompiling Shaders\033[0m"
for i in $(ls include/Shaders)
do
name="${i%%.*}"
type="${i#*.}"
./include/vendored/VulkanSDK/Linux/bin/glslc include/Shaders/$i -o $name.spv
mv $name.spv build/$name-$type.spv
echo -e "\033[1;36mCompiled $i into $name-$type.spv\033[0m"
done