blob: 9dc4b991c4ad647560b9fbf27e665a49c09510e4 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001#!/bin/sh
2
3# build-swig-Python.sh
4
5
6debug_flag=$1
7
8if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ]
9then
10 Debug=1
11else
12 Debug=0
13fi
14
15
16HEADER_FILES="${SRCROOT}/include/lldb/lldb-types.h"\
17" ${SRCROOT}/include/lldb/API/SBAddress.h"\
18" ${SRCROOT}/include/lldb/API/SBBlock.h"\
19" ${SRCROOT}/include/lldb/API/SBBreakpoint.h"\
20" ${SRCROOT}/include/lldb/API/SBBreakpointLocation.h"\
21" ${SRCROOT}/include/lldb/API/SBBroadcaster.h"\
22" ${SRCROOT}/include/lldb/API/SBCommandContext.h"\
23" ${SRCROOT}/include/lldb/API/SBCommandInterpreter.h"\
24" ${SRCROOT}/include/lldb/API/SBCommandReturnObject.h"\
25" ${SRCROOT}/include/lldb/API/SBCompileUnit.h"\
26" ${SRCROOT}/include/lldb/API/SBDebugger.h"\
27" ${SRCROOT}/include/lldb/API/SBError.h"\
28" ${SRCROOT}/include/lldb/API/SBEvent.h"\
29" ${SRCROOT}/include/lldb/API/SBFrame.h"\
30" ${SRCROOT}/include/lldb/API/SBFunction.h"\
31" ${SRCROOT}/include/lldb/API/SBLineEntry.h"\
32" ${SRCROOT}/include/lldb/API/SBListener.h"\
33" ${SRCROOT}/include/lldb/API/SBModule.h"\
34" ${SRCROOT}/include/lldb/API/SBProcess.h"\
35" ${SRCROOT}/include/lldb/API/SBSourceManager.h"\
36" ${SRCROOT}/include/lldb/API/SBStringList.h"\
37" ${SRCROOT}/include/lldb/API/SBSymbol.h"\
38" ${SRCROOT}/include/lldb/API/SBSymbolContext.h"\
39" ${SRCROOT}/include/lldb/API/SBTarget.h"\
40" ${SRCROOT}/include/lldb/API/SBThread.h"\
41" ${SRCROOT}/include/lldb/API/SBType.h"\
42" ${SRCROOT}/include/lldb/API/SBValue.h"
43
44
45if [ $Debug == 1 ]
46then
47 echo "Header files are:"
48 echo ${HEADER_FILES}
49fi
50
51NeedToUpdate=0
52
53swig_output_file=${SCRIPT_INPUT_FILE_1}
54
55if [ ! -f $swig_output_file ]
56then
57 NeedToUpdate=1
58 if [ $Debug == 1 ]
59 then
60 echo "Failed to find LLDBWrapPython.cpp"
61 fi
62fi
63
64if [ $NeedToUpdate == 0 ]
65then
66 for hdrfile in ${HEADER_FILES}
67 do
68 if [ $hdrfile -nt $swig_output_file ]
69 then
70 NeedToUpdate=1
71 if [ $Debug == 1 ]
72 then
73 echo "${hdrfile} is newer than ${swig_output_file}"
74 echo "swig file will need to be re-built."
75 fi
76 fi
77 done
78fi
79
80framework_python_dir="${CONFIGURATION_BUILD_DIR}/LLDB.framework/Versions/A/Resources/Python"
81
82if [ ! -L "${framework_python_dir}/_lldb.so" ]
83then
84 NeedToUpdate=1
85fi
86
87if [ ! -f "${framework_python_dir}/lldb.py" ]
88then
89 NeedToUpdate=1
90fi
91
92
93if [ $NeedToUpdate == 0 ]
94then
95 echo "Everything is up-to-date."
96 exit 0
97else
98 echo "SWIG needs to be re-run."
99fi
100
101
102# Build the SWIG C++ wrapper file for Python.
103
104swig -c++ -shadow -python -I"${SRCROOT}/include" -I./. -outdir "${CONFIGURATION_BUILD_DIR}" -o "${SCRIPT_INPUT_FILE_1}" "${SCRIPT_INPUT_FILE_0}"
105
106# Edit the C++ wrapper file that SWIG generated for Python. There are two
107# global string replacements needed, which the following script file takes
108# care of. It reads in 'LLDBWrapPython.cpp' and generates
109# 'LLDBWrapPython.cpp.edited'.
110
111# The need for this has been eliminated by fixing the namespace qualifiers on return types.
112# Leaving this here for now, just in case...
113#
114#if [ -f "${SRCROOT}/scripts/Python/edit-swig-python-wrapper-file.py" ]
115#then
116# python "${SRCROOT}/scripts/Python/edit-swig-python-wrapper-file.py"
117#fi
118
119#
120# Now that we've got a C++ file we're happy with (hopefully), rename the
121# edited file and move it to the appropriate places.
122#
123
124if [ -f "${SCRIPT_INPUT_FILE_1}.edited" ]
125then
126 mv "${SCRIPT_INPUT_FILE_1}.edited" "${SCRIPT_INPUT_FILE_1}"
127fi