forked from DFHack/dfhack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-osx.sh
123 lines (110 loc) · 2.56 KB
/
build-osx.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
#!/bin/bash
# This implements steps 7 and 8 of the OSX compilation procedure described in Compile.rst
# If build-osx does not exist in the parent directory, it will be created.
LUA_PATCH=1
ME=$PWD/`basename $0`
usage() {
echo "Usage: $0 [options] {DF_OSX_PATH}"
echo -e "\told\t- use on pre-Snow Leopard OSX installations"
echo -e "\tbrew\t- if GCC 4.5 was installed with homebrew"
echo -e "\tport\t- if GCC 4.5 was insalled with macports"
echo -e "\tclean\t- delete ../build-osx before compiling"
echo "Example:"
echo -e "\t$0 old brew ../../../personal/df_osx"
echo -e "\t$0 port clean /Users/dfplayer/df_osx"
exit $1
}
options() {
case $1 in
brew)
echo "Using homebrew gcc."
export CC=/usr/local/bin/gcc-4.5
export CXX=/usr/local/bin/g++-4.5
targetted=1
;;
port)
echo "Using macports gcc."
export CC=/opt/local/bin/gcc-mp-4.5
export CXX=/opt/local/bin/g++-mp-4.5
targetted=1
;;
old)
LUA_PATCH=0
;;
clean)
echo "Deleting ../build-osx"
rm -rf ../build-osx
;;
*)
;;
esac
}
# sanity checks
if [[ $# -lt 1 ]]
then
echo "Not enough arguments."
usage 0
fi
if [[ $# -gt 4 ]]
then
echo "Too many arguments."
usage 1
fi
# run through the arguments
for last
do
options $last
done
# last keeps the last argument
if [[ $targetted -eq 0 ]]
then
echo "You did not specify whether you intalled GCC 4.5 from brew or ports."
echo "If you continue, your default compiler will be used."
read -p "Are you sure you want to continue? [y/N] " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 0
fi
fi
# check for build folder and start working there
if [[ ! -d ../build-osx ]]
then
mkdir ../build-osx
fi
cd ../build-osx
# patch if necessary
if [[ $LUA_PATCH -ne 0 ]]
then
cd ..
echo "$PWD"
sed -e '1,/'"PATCH""CODE"'/d' "$ME" | patch -p0
cd -
fi
echo "Generate"
cmake .. -DCMAKE_BUILD_TYPE:string=Release -DCMAKE_INSTALL_PREFIX="$last"
echo "Build"
make
echo "Install"
make install
# unpatch if /libarary/luaTypes.cpp was patched
if [[ $LUA_PATCH -ne 0 ]]
then
cd ..
echo -n "un"
sed -e '1,/'"PATCH""CODE"'/d' "$ME" | patch -p0 -R
cd -
fi
exit 0
# PATCHCODE - everything below this line is fed into patch
--- library/LuaTypes.cpp 2014-08-20 00:13:17.000000000 -0700
+++ library/LuaTypes.cpp 2014-08-31 23:31:00.000000000 -0700
@@ -464,7 +464,7 @@
{
case struct_field_info::STATIC_STRING:
{
- int len = strnlen((char*)ptr, field->count);
+ int len = strlen((char*)ptr);
lua_pushlstring(state, (char*)ptr, len);
return;
}