macos: add --debug option to NetRadiant build to run with lldb
[xonotic/netradiant.git] / setup / macos / NetRadiant
1 #! /usr/bin/env bash
2
3 set -o physical
4
5 script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
6
7 bundle_dir="$(cd "${script_dir}/../Prefix"; pwd)"
8
9 echo "Starting NetRadiant in ${bundle_dir}"
10
11 cd "${bundle_dir}"
12
13 export FC_DEBUG=1024
14
15 # if bundled
16 if [ -d "${bundle_dir}/share/icons/hicolor" ]
17 then
18         export FONTCONFIG_PATH="${bundle_dir}/etc/fonts"
19
20         # export GDK_GL_LIBGL_PATH="${bundle_dir}/lib/libGL.1.dylib"
21         # export GDK_GL_LIBGLU_PATH="${bundle_dir}/lib/libGLU.1.dylib"
22
23         export GDK_PATH="${bundle_dir}"
24
25         export GDK_PIXBUF_MODULE_FILE="${bundle_dir}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
26
27         export GTK_IM_MODULE_FILE="${bundle_dir}/lib/gtk-2.0/2.10.0/immodules.cache"
28
29         export GOBJECT_PATH="${bundle_dir}"
30
31         export GTK_DATA_PREFIX="${bundle_dir}"
32         export GTK_EXE_PREFIX="${bundle_dir}"
33         export GTK_PATH="${bundle_dir}"
34 fi
35
36 if [ "$(defaults read -g AppleInterfaceStyle 2>/dev/null)" = 'Dark' ]
37 then
38         color='dark'
39 else
40         color='light'
41 fi
42
43 gtkrc_file="${bundle_dir}/share/themes/Mojave-${color}/gtk-2.0/gtkrc"
44
45 if [ -f "${gtkrc_file}" ]
46 then
47         export GTK2_RC_FILES="${gtkrc_file}"
48 fi
49
50 if [ "${1}" = '--debug' ]
51 then
52         shift
53         export PATH="/usr/bin:${PATH}"
54         exec lldb ./netradiant "${@}"
55 else
56         exec ./netradiant "${@}"
57 fi