-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathBuildAndCopyLibsUnix.sh
More file actions
executable file
·82 lines (62 loc) · 2.28 KB
/
BuildAndCopyLibsUnix.sh
File metadata and controls
executable file
·82 lines (62 loc) · 2.28 KB
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
#!/bin/bash
# Release or Debug?
choice=""
while [[ "$choice" != "1" && "$choice" != "2" ]]; do
echo "Choose your build"
echo "1. Release (default)"
echo "2. Debug"
read -p "Option: " choice
if [[ "$choice" == "" ]]; then
choice="1"
fi
done
if [[ "$choice" == "1" ]]; then
mode="Release"
elif [[ "$choice" == "2" ]]; then
mode="Debug"
fi
# Number of Threads?
numThreads=""
re='^[0-9]+$'
while [[ ! $numThreads =~ $re || $numThreads < 1 ]]; do
read -p "How many threads should be used for compilation? (default: 4): " numThreads
if [[ "$numThreads" == "" ]]; then
numThreads=4
fi
done
# Paths
repopath=$(pwd)
src_dir="${repopath}/LibSWBF2/LibSWBF2"
build_dir="${src_dir}/build/${mode}"
unity_lib_dir="${repopath}/UnityProject/Assets/Lib/"
# Build LibSWBF2 cpp lib
rm -rf ${build_dir}
cmake -S "${src_dir}" -B "${build_dir}" -D CMAKE_BUILD_TYPE=${mode}
cmake --build "${build_dir}" --target all --parallel -- -j $numThreads
# Build LibSWBF2 .NET wrapper
msbuild "${repopath}/LibSWBF2/LibSWBF2.NET/LibSWBF2.NET.csproj" -verbosity:minimal /t:Rebuild /p:Platform="x64" /p:DefineConstants=UNIX /p:configuration=${mode}
# OS specific lua build and lib copy
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Building lua for Linux"
make -C "${repopath}/lua5.0-swbf2-x64/src" -f lua50_dll.make -j $numThreads --always-make
echo "Copy Linux libs"
cp "${build_dir}/libSWBF2.so" "${unity_lib_dir}"
cp "${repopath}/lua5.0-swbf2-x64/bin/liblua50-swbf2-x64.so" "${unity_lib_dir}"
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "Building lua for Mac"
make -C "${repopath}/lua5.0-swbf2-x64/mak.macosx" -f lua50_dll.make -j $numThreads --always-make
echo "Copying Mac libs"
cp "${build_dir}/libSWBF2.dylib" "${unity_lib_dir}"
cp "${repopath}/lua5.0-swbf2-x64/bin/liblua50-swbf2-x64.dylib" "${unity_lib_dir}"
else
echo "ERROR: Unknown platform: $OSTYPE"
exit
fi
# Copy LibSWBF2 .NET wrapper
cp "${repopath}/LibSWBF2/LibSWBF2.NET/bin/x64/Debug/LibSWBF2.NET.dll" "${repopath}/UnityProject/Assets/Lib/"
# Copy debug database when in Debug mode, delete it otherwise
if [[ ${mode} == "Debug" ]]; then
cp "${repopath}/LibSWBF2/LibSWBF2.NET/bin/x64/Debug/LibSWBF2.NET.pdb" "${repopath}/UnityProject/Assets/Lib/"
elif [[ ${mode} == "Release" ]]; then
rm -f "${repopath}/UnityProject/Assets/Lib/LibSWBF2.NET.pdb"
fi