Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # build-swig-Python.sh |
| 4 | |
| 5 | |
| 6 | debug_flag=$1 |
| 7 | |
| 8 | if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ] |
| 9 | then |
| 10 | Debug=1 |
| 11 | else |
| 12 | Debug=0 |
| 13 | fi |
| 14 | |
| 15 | |
| 16 | HEADER_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 | |
| 45 | if [ $Debug == 1 ] |
| 46 | then |
| 47 | echo "Header files are:" |
| 48 | echo ${HEADER_FILES} |
| 49 | fi |
| 50 | |
| 51 | NeedToUpdate=0 |
| 52 | |
| 53 | swig_output_file=${SCRIPT_INPUT_FILE_1} |
| 54 | |
| 55 | if [ ! -f $swig_output_file ] |
| 56 | then |
| 57 | NeedToUpdate=1 |
| 58 | if [ $Debug == 1 ] |
| 59 | then |
| 60 | echo "Failed to find LLDBWrapPython.cpp" |
| 61 | fi |
| 62 | fi |
| 63 | |
| 64 | if [ $NeedToUpdate == 0 ] |
| 65 | then |
| 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 |
| 78 | fi |
| 79 | |
| 80 | framework_python_dir="${CONFIGURATION_BUILD_DIR}/LLDB.framework/Versions/A/Resources/Python" |
| 81 | |
| 82 | if [ ! -L "${framework_python_dir}/_lldb.so" ] |
| 83 | then |
| 84 | NeedToUpdate=1 |
| 85 | fi |
| 86 | |
| 87 | if [ ! -f "${framework_python_dir}/lldb.py" ] |
| 88 | then |
| 89 | NeedToUpdate=1 |
| 90 | fi |
| 91 | |
| 92 | |
| 93 | if [ $NeedToUpdate == 0 ] |
| 94 | then |
| 95 | echo "Everything is up-to-date." |
| 96 | exit 0 |
| 97 | else |
| 98 | echo "SWIG needs to be re-run." |
| 99 | fi |
| 100 | |
| 101 | |
| 102 | # Build the SWIG C++ wrapper file for Python. |
| 103 | |
| 104 | swig -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 | |
| 124 | if [ -f "${SCRIPT_INPUT_FILE_1}.edited" ] |
| 125 | then |
| 126 | mv "${SCRIPT_INPUT_FILE_1}.edited" "${SCRIPT_INPUT_FILE_1}" |
| 127 | fi |