blob: 69c40a76b12eb0ddab953438b60c0be7169792cc [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001#!/bin/sh
2
3# build-swig-Python.sh
4
Caroline Tice9dbe7172010-06-16 19:26:52 +00005# SRC_ROOT is the root of the lldb source tree.
6# TARGET_DIR is where the lldb framework/shared library gets put.
7# CONFIG_BUILD_DIR is where the build-swig-Python-LLDB.sh shell script
8# put the lldb.py file it was generated from running SWIG.
9# PREFIX is the root directory used to determine where third-party modules
10# for scripting languages should be installed.
11# debug_flag (optional) determines whether or not this script outputs
12# additional information when running.
Chris Lattner24943d22010-06-08 16:52:24 +000013
Caroline Tice9dbe7172010-06-16 19:26:52 +000014SRC_ROOT=$1
15TARGET_DIR=$2
16CONFIG_BUILD_DIR=$3
17PYTHON_INSTALL_DIR=$4
18debug_flag=$5
19
20swig_output_file=${SRC_ROOT}/source/LLDBWrapPython.cpp
21swig_input_file=${SRC_ROOT}/scripts/lldb.swig
22
Chris Lattner24943d22010-06-08 16:52:24 +000023
24if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ]
25then
26 Debug=1
27else
28 Debug=0
29fi
30
31
Caroline Tice9dbe7172010-06-16 19:26:52 +000032HEADER_FILES="${SRC_ROOT}/include/lldb/lldb-types.h"\
33" ${SRC_ROOT}/include/lldb/API/SBAddress.h"\
34" ${SRC_ROOT}/include/lldb/API/SBBlock.h"\
35" ${SRC_ROOT}/include/lldb/API/SBBreakpoint.h"\
36" ${SRC_ROOT}/include/lldb/API/SBBreakpointLocation.h"\
37" ${SRC_ROOT}/include/lldb/API/SBBroadcaster.h"\
38" ${SRC_ROOT}/include/lldb/API/SBCommandContext.h"\
39" ${SRC_ROOT}/include/lldb/API/SBCommandInterpreter.h"\
40" ${SRC_ROOT}/include/lldb/API/SBCommandReturnObject.h"\
41" ${SRC_ROOT}/include/lldb/API/SBCompileUnit.h"\
42" ${SRC_ROOT}/include/lldb/API/SBDebugger.h"\
43" ${SRC_ROOT}/include/lldb/API/SBError.h"\
44" ${SRC_ROOT}/include/lldb/API/SBEvent.h"\
45" ${SRC_ROOT}/include/lldb/API/SBFrame.h"\
46" ${SRC_ROOT}/include/lldb/API/SBFunction.h"\
47" ${SRC_ROOT}/include/lldb/API/SBLineEntry.h"\
48" ${SRC_ROOT}/include/lldb/API/SBListener.h"\
49" ${SRC_ROOT}/include/lldb/API/SBModule.h"\
50" ${SRC_ROOT}/include/lldb/API/SBProcess.h"\
51" ${SRC_ROOT}/include/lldb/API/SBSourceManager.h"\
52" ${SRC_ROOT}/include/lldb/API/SBStringList.h"\
53" ${SRC_ROOT}/include/lldb/API/SBSymbol.h"\
54" ${SRC_ROOT}/include/lldb/API/SBSymbolContext.h"\
55" ${SRC_ROOT}/include/lldb/API/SBTarget.h"\
56" ${SRC_ROOT}/include/lldb/API/SBThread.h"\
57" ${SRC_ROOT}/include/lldb/API/SBType.h"\
58" ${SRC_ROOT}/include/lldb/API/SBValue.h"
Chris Lattner24943d22010-06-08 16:52:24 +000059
60
61if [ $Debug == 1 ]
62then
63 echo "Header files are:"
64 echo ${HEADER_FILES}
65fi
66
67NeedToUpdate=0
68
Chris Lattner24943d22010-06-08 16:52:24 +000069
70if [ ! -f $swig_output_file ]
71then
72 NeedToUpdate=1
73 if [ $Debug == 1 ]
74 then
75 echo "Failed to find LLDBWrapPython.cpp"
76 fi
77fi
78
79if [ $NeedToUpdate == 0 ]
80then
81 for hdrfile in ${HEADER_FILES}
82 do
83 if [ $hdrfile -nt $swig_output_file ]
84 then
85 NeedToUpdate=1
86 if [ $Debug == 1 ]
87 then
88 echo "${hdrfile} is newer than ${swig_output_file}"
89 echo "swig file will need to be re-built."
90 fi
91 fi
92 done
93fi
94
Caroline Tice9dbe7172010-06-16 19:26:52 +000095os_name=`uname -s`
96python_version=`/usr/bin/python --version 2>&1 | sed -e 's,Python ,,' -e 's,[.][0-9],,2' -e 's,[a-z][a-z][0-9],,'`
97
98if [ "$os_name" == "Darwin" ]
99then
100 framework_python_dir="${TARGET_DIR}/LLDB.framework/Resources/Python"
101else
102 framework_python_dir="${PYTHON_INSTALL_DIR}/python${python_version}"
103fi
104
Chris Lattner24943d22010-06-08 16:52:24 +0000105
106if [ ! -L "${framework_python_dir}/_lldb.so" ]
107then
108 NeedToUpdate=1
109fi
110
111if [ ! -f "${framework_python_dir}/lldb.py" ]
112then
113 NeedToUpdate=1
114fi
115
116
117if [ $NeedToUpdate == 0 ]
118then
119 echo "Everything is up-to-date."
120 exit 0
121else
122 echo "SWIG needs to be re-run."
123fi
124
125
126# Build the SWIG C++ wrapper file for Python.
127
Caroline Tice9dbe7172010-06-16 19:26:52 +0000128swig -c++ -shadow -python -I"${SRC_ROOT}/include" -I./. -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}"
Chris Lattner24943d22010-06-08 16:52:24 +0000129