Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # build-swig-Python.sh |
| 4 | |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 5 | # 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 Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 13 | |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 14 | SRC_ROOT=$1 |
| 15 | TARGET_DIR=$2 |
| 16 | CONFIG_BUILD_DIR=$3 |
| 17 | PYTHON_INSTALL_DIR=$4 |
| 18 | debug_flag=$5 |
| 19 | |
| 20 | swig_output_file=${SRC_ROOT}/source/LLDBWrapPython.cpp |
| 21 | swig_input_file=${SRC_ROOT}/scripts/lldb.swig |
| 22 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 23 | |
| 24 | if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ] |
| 25 | then |
| 26 | Debug=1 |
| 27 | else |
| 28 | Debug=0 |
| 29 | fi |
| 30 | |
| 31 | |
Greg Clayton | d8c6253 | 2010-10-07 04:19:01 +0000 | [diff] [blame^] | 32 | HEADER_FILES="${SRC_ROOT}/include/lldb/lldb-include.h"\ |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 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"\ |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 38 | " ${SRC_ROOT}/include/lldb/API/SBCommandInterpreter.h"\ |
| 39 | " ${SRC_ROOT}/include/lldb/API/SBCommandReturnObject.h"\ |
Greg Clayton | d8c6253 | 2010-10-07 04:19:01 +0000 | [diff] [blame^] | 40 | " ${SRC_ROOT}/include/lldb/API/SBCommunication.h"\ |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 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"\ |
Johnny Chen | 4ead2e9 | 2010-08-27 22:35:26 +0000 | [diff] [blame] | 45 | " ${SRC_ROOT}/include/lldb/API/SBFileSpec.h"\ |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 46 | " ${SRC_ROOT}/include/lldb/API/SBFrame.h"\ |
| 47 | " ${SRC_ROOT}/include/lldb/API/SBFunction.h"\ |
Greg Clayton | d8c6253 | 2010-10-07 04:19:01 +0000 | [diff] [blame^] | 48 | " ${SRC_ROOT}/include/lldb/API/SBHostOS.h"\ |
| 49 | " ${SRC_ROOT}/include/lldb/API/SBInputReader.h"\ |
Greg Clayton | 5c4c746 | 2010-10-06 03:09:58 +0000 | [diff] [blame] | 50 | " ${SRC_ROOT}/include/lldb/API/SBInstruction.h"\ |
| 51 | " ${SRC_ROOT}/include/lldb/API/SBInstructionList.h"\ |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 52 | " ${SRC_ROOT}/include/lldb/API/SBLineEntry.h"\ |
| 53 | " ${SRC_ROOT}/include/lldb/API/SBListener.h"\ |
| 54 | " ${SRC_ROOT}/include/lldb/API/SBModule.h"\ |
| 55 | " ${SRC_ROOT}/include/lldb/API/SBProcess.h"\ |
| 56 | " ${SRC_ROOT}/include/lldb/API/SBSourceManager.h"\ |
Caroline Tice | 1ca48b0 | 2010-09-22 16:41:52 +0000 | [diff] [blame] | 57 | " ${SRC_ROOT}/include/lldb/API/SBStream.h"\ |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 58 | " ${SRC_ROOT}/include/lldb/API/SBStringList.h"\ |
| 59 | " ${SRC_ROOT}/include/lldb/API/SBSymbol.h"\ |
| 60 | " ${SRC_ROOT}/include/lldb/API/SBSymbolContext.h"\ |
Greg Clayton | d8c6253 | 2010-10-07 04:19:01 +0000 | [diff] [blame^] | 61 | " ${SRC_ROOT}/include/lldb/API/SBSymbolContextList.h"\ |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 62 | " ${SRC_ROOT}/include/lldb/API/SBTarget.h"\ |
| 63 | " ${SRC_ROOT}/include/lldb/API/SBThread.h"\ |
| 64 | " ${SRC_ROOT}/include/lldb/API/SBType.h"\ |
Caroline Tice | 1ca48b0 | 2010-09-22 16:41:52 +0000 | [diff] [blame] | 65 | " ${SRC_ROOT}/include/lldb/API/SBValue.h"\ |
| 66 | " ${SRC_ROOT}/include/lldb/API/SBValueList.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 67 | |
| 68 | |
| 69 | if [ $Debug == 1 ] |
| 70 | then |
| 71 | echo "Header files are:" |
| 72 | echo ${HEADER_FILES} |
| 73 | fi |
| 74 | |
| 75 | NeedToUpdate=0 |
| 76 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 77 | |
Johnny Chen | b4d1fff | 2010-08-26 20:04:17 +0000 | [diff] [blame] | 78 | if [ ! -f ${swig_output_file} ] |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 79 | then |
| 80 | NeedToUpdate=1 |
| 81 | if [ $Debug == 1 ] |
| 82 | then |
| 83 | echo "Failed to find LLDBWrapPython.cpp" |
| 84 | fi |
| 85 | fi |
| 86 | |
| 87 | if [ $NeedToUpdate == 0 ] |
| 88 | then |
| 89 | for hdrfile in ${HEADER_FILES} |
| 90 | do |
Johnny Chen | b4d1fff | 2010-08-26 20:04:17 +0000 | [diff] [blame] | 91 | if [ $hdrfile -nt ${swig_output_file} ] |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 92 | then |
| 93 | NeedToUpdate=1 |
| 94 | if [ $Debug == 1 ] |
| 95 | then |
| 96 | echo "${hdrfile} is newer than ${swig_output_file}" |
| 97 | echo "swig file will need to be re-built." |
| 98 | fi |
Johnny Chen | b4d1fff | 2010-08-26 20:04:17 +0000 | [diff] [blame] | 99 | break |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 100 | fi |
| 101 | done |
| 102 | fi |
| 103 | |
Johnny Chen | b4d1fff | 2010-08-26 20:04:17 +0000 | [diff] [blame] | 104 | if [ $NeedToUpdate == 0 ] |
| 105 | then |
| 106 | if [ ${swig_input_file} -nt ${swig_output_file} ] |
| 107 | then |
| 108 | NeedToUpdate=1 |
| 109 | if [ $Debug == 1 ] |
| 110 | then |
| 111 | echo "${swig_input_file} is newer than ${swig_output_file}" |
| 112 | echo "swig file will need to be re-built." |
| 113 | fi |
| 114 | fi |
| 115 | fi |
| 116 | |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 117 | os_name=`uname -s` |
| 118 | python_version=`/usr/bin/python --version 2>&1 | sed -e 's,Python ,,' -e 's,[.][0-9],,2' -e 's,[a-z][a-z][0-9],,'` |
| 119 | |
| 120 | if [ "$os_name" == "Darwin" ] |
| 121 | then |
| 122 | framework_python_dir="${TARGET_DIR}/LLDB.framework/Resources/Python" |
| 123 | else |
| 124 | framework_python_dir="${PYTHON_INSTALL_DIR}/python${python_version}" |
| 125 | fi |
| 126 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 127 | |
| 128 | if [ ! -L "${framework_python_dir}/_lldb.so" ] |
| 129 | then |
| 130 | NeedToUpdate=1 |
| 131 | fi |
| 132 | |
| 133 | if [ ! -f "${framework_python_dir}/lldb.py" ] |
| 134 | then |
| 135 | NeedToUpdate=1 |
| 136 | fi |
| 137 | |
| 138 | |
| 139 | if [ $NeedToUpdate == 0 ] |
| 140 | then |
| 141 | echo "Everything is up-to-date." |
| 142 | exit 0 |
| 143 | else |
| 144 | echo "SWIG needs to be re-run." |
| 145 | fi |
| 146 | |
| 147 | |
| 148 | # Build the SWIG C++ wrapper file for Python. |
| 149 | |
Greg Clayton | d8c6253 | 2010-10-07 04:19:01 +0000 | [diff] [blame^] | 150 | swig -c++ -shadow -python -I"/usr/include" -I"${SRC_ROOT}/include" -I./. -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 151 | |
Caroline Tice | 558be58 | 2010-06-30 16:22:25 +0000 | [diff] [blame] | 152 | # Append global variable to lldb Python module. |
| 153 | |
| 154 | current_dir=`pwd` |
| 155 | if [ -f "${current_dir}/append-debugger-id.py" ] |
| 156 | then |
| 157 | python ${current_dir}/append-debugger-id.py ${CONFIG_BUILD_DIR} |
| 158 | fi |