Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # build-swig-Python.sh |
| 4 | |
Caroline Tice | d6ac384 | 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. |
Filipe Cabecinhas | c281a3b | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 7 | # CONFIG_BUILD_DIR is where the build-swig-Python-LLDB.sh shell script |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 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. |
Filipe Cabecinhas | c281a3b | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 11 | # debug_flag (optional) determines whether or not this script outputs |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 12 | # additional information when running. |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 13 | |
Caroline Tice | d6ac384 | 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 |
Filipe Cabecinhas | c281a3b | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 18 | debug_flag=$5 |
Jim Ingham | 6b90ba4 | 2011-03-01 01:39:04 +0000 | [diff] [blame] | 19 | SWIG=$6 |
Filipe Cabecinhas | c281a3b | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 20 | makefile_flag=$7 |
| 21 | dependency_flag=$8 |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 22 | |
Filipe Cabecinhas | c281a3b | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 23 | if [ -n "$makefile_flag" -a "$makefile_flag" = "-m" ] |
| 24 | then |
| 25 | MakefileCalled=1 |
| 26 | if [ -n "$dependency_flag" -a "$dependency_flag" = "-M" ] |
| 27 | then |
| 28 | GenerateDependencies=1 |
| 29 | swig_depend_file="${TARGET_DIR}/LLDBWrapPython.cpp.d" |
| 30 | SWIG_DEPEND_OPTIONS="-MMD -MF \"${swig_depend_file}.tmp\"" |
| 31 | else |
| 32 | GenerateDependencies=0 |
| 33 | fi |
| 34 | else |
| 35 | MakefileCalled=0 |
| 36 | GenerateDependencies=0 |
| 37 | fi |
| 38 | |
| 39 | if [ $MakefileCalled -eq 0 ] |
Filipe Cabecinhas | 3e9e081 | 2012-09-14 17:09:15 +0000 | [diff] [blame] | 40 | then |
| 41 | swig_output_file=${SRC_ROOT}/source/LLDBWrapPython.cpp |
| 42 | else |
| 43 | swig_output_file=${TARGET_DIR}/LLDBWrapPython.cpp |
| 44 | fi |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 45 | swig_input_file=${SRC_ROOT}/scripts/lldb.swig |
Johnny Chen | 30123f1 | 2011-08-22 22:10:57 +0000 | [diff] [blame] | 46 | swig_python_extensions=${SRC_ROOT}/scripts/Python/python-extensions.swig |
| 47 | swig_python_wrapper=${SRC_ROOT}/scripts/Python/python-wrapper.swig |
Enrico Granata | 9d2063e | 2012-02-02 17:26:00 +0000 | [diff] [blame] | 48 | swig_python_typemaps=${SRC_ROOT}/scripts/Python/python-typemaps.swig |
Enrico Granata | c972c70 | 2013-06-21 18:57:30 +0000 | [diff] [blame] | 49 | swig_python_swigsafecast=${SRC_ROOT}/scripts/Python/python-swigsafecast.swig |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 50 | |
Filipe Cabecinhas | 3e9e081 | 2012-09-14 17:09:15 +0000 | [diff] [blame] | 51 | if [ "$LLDB_DISABLE_PYTHON" = "1" ] ; then |
Jim Ingham | de22182 | 2012-05-26 00:23:52 +0000 | [diff] [blame] | 52 | # We don't want Python for this build, but touch the output file so we don't have to |
| 53 | # conditionalize the build on this as well. |
| 54 | # Note, at present iOS doesn't have Python, so if you're building for iOS be sure to |
| 55 | # set LLDB_DISABLE_PYTHON to 1. |
Jim Ingham | 777e6d0 | 2012-05-24 01:16:09 +0000 | [diff] [blame] | 56 | rm -rf ${swig_output_file} |
| 57 | touch ${swig_output_file} |
| 58 | |
| 59 | else |
Greg Clayton | dce502e | 2011-11-04 03:34:56 +0000 | [diff] [blame] | 60 | |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 61 | if [ -n "$debug_flag" -a "$debug_flag" = "-debug" ] |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 62 | then |
| 63 | Debug=1 |
| 64 | else |
| 65 | Debug=0 |
| 66 | fi |
| 67 | |
Jason Molenda | cf7e2dc | 2012-02-21 05:33:55 +0000 | [diff] [blame] | 68 | # If this project is being built with LLDB_DISABLE_PYTHON defined, |
| 69 | # don't bother generating Python swig bindings -- we don't have |
| 70 | # Python available. |
| 71 | |
| 72 | if echo $GCC_PREPROCESSOR_DEFINITIONS | grep LLDB_DISABLE_PYTHON |
| 73 | then |
| 74 | echo "" > "${swig_output_file}" |
| 75 | exit 0 |
| 76 | fi |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 77 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 78 | HEADER_FILES="${SRC_ROOT}/include/lldb/lldb.h"\ |
Caroline Tice | e206be2 | 2010-10-18 23:00:51 +0000 | [diff] [blame] | 79 | " ${SRC_ROOT}/include/lldb/lldb-defines.h"\ |
| 80 | " ${SRC_ROOT}/include/lldb/lldb-enumerations.h"\ |
| 81 | " ${SRC_ROOT}/include/lldb/lldb-forward.h"\ |
| 82 | " ${SRC_ROOT}/include/lldb/lldb-forward-rtti.h"\ |
| 83 | " ${SRC_ROOT}/include/lldb/lldb-types.h"\ |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 84 | " ${SRC_ROOT}/include/lldb/API/SBAddress.h"\ |
| 85 | " ${SRC_ROOT}/include/lldb/API/SBBlock.h"\ |
| 86 | " ${SRC_ROOT}/include/lldb/API/SBBreakpoint.h"\ |
| 87 | " ${SRC_ROOT}/include/lldb/API/SBBreakpointLocation.h"\ |
| 88 | " ${SRC_ROOT}/include/lldb/API/SBBroadcaster.h"\ |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 89 | " ${SRC_ROOT}/include/lldb/API/SBCommandInterpreter.h"\ |
| 90 | " ${SRC_ROOT}/include/lldb/API/SBCommandReturnObject.h"\ |
Greg Clayton | 05faeb7 | 2010-10-07 04:19:01 +0000 | [diff] [blame] | 91 | " ${SRC_ROOT}/include/lldb/API/SBCommunication.h"\ |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 92 | " ${SRC_ROOT}/include/lldb/API/SBCompileUnit.h"\ |
Enrico Granata | 9128ee2 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 93 | " ${SRC_ROOT}/include/lldb/API/SBData.h"\ |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 94 | " ${SRC_ROOT}/include/lldb/API/SBDebugger.h"\ |
| 95 | " ${SRC_ROOT}/include/lldb/API/SBError.h"\ |
| 96 | " ${SRC_ROOT}/include/lldb/API/SBEvent.h"\ |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 97 | " ${SRC_ROOT}/include/lldb/API/SBExpressionOptions.h"\ |
Johnny Chen | 23fd10c | 2010-08-27 22:35:26 +0000 | [diff] [blame] | 98 | " ${SRC_ROOT}/include/lldb/API/SBFileSpec.h"\ |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 99 | " ${SRC_ROOT}/include/lldb/API/SBFrame.h"\ |
| 100 | " ${SRC_ROOT}/include/lldb/API/SBFunction.h"\ |
Greg Clayton | 05faeb7 | 2010-10-07 04:19:01 +0000 | [diff] [blame] | 101 | " ${SRC_ROOT}/include/lldb/API/SBHostOS.h"\ |
| 102 | " ${SRC_ROOT}/include/lldb/API/SBInputReader.h"\ |
Greg Clayton | 1d27316 | 2010-10-06 03:09:58 +0000 | [diff] [blame] | 103 | " ${SRC_ROOT}/include/lldb/API/SBInstruction.h"\ |
| 104 | " ${SRC_ROOT}/include/lldb/API/SBInstructionList.h"\ |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 105 | " ${SRC_ROOT}/include/lldb/API/SBLineEntry.h"\ |
| 106 | " ${SRC_ROOT}/include/lldb/API/SBListener.h"\ |
| 107 | " ${SRC_ROOT}/include/lldb/API/SBModule.h"\ |
Greg Clayton | 226cce2 | 2013-07-08 22:22:41 +0000 | [diff] [blame^] | 108 | " ${SRC_ROOT}/include/lldb/API/SBModuleSpec.h"\ |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 109 | " ${SRC_ROOT}/include/lldb/API/SBProcess.h"\ |
| 110 | " ${SRC_ROOT}/include/lldb/API/SBSourceManager.h"\ |
Caroline Tice | 7740412 | 2010-09-22 16:41:52 +0000 | [diff] [blame] | 111 | " ${SRC_ROOT}/include/lldb/API/SBStream.h"\ |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 112 | " ${SRC_ROOT}/include/lldb/API/SBStringList.h"\ |
| 113 | " ${SRC_ROOT}/include/lldb/API/SBSymbol.h"\ |
| 114 | " ${SRC_ROOT}/include/lldb/API/SBSymbolContext.h"\ |
Greg Clayton | 05faeb7 | 2010-10-07 04:19:01 +0000 | [diff] [blame] | 115 | " ${SRC_ROOT}/include/lldb/API/SBSymbolContextList.h"\ |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 116 | " ${SRC_ROOT}/include/lldb/API/SBTarget.h"\ |
| 117 | " ${SRC_ROOT}/include/lldb/API/SBThread.h"\ |
| 118 | " ${SRC_ROOT}/include/lldb/API/SBType.h"\ |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 119 | " ${SRC_ROOT}/include/lldb/API/SBTypeCategory.h"\ |
| 120 | " ${SRC_ROOT}/include/lldb/API/SBTypeFilter.h"\ |
| 121 | " ${SRC_ROOT}/include/lldb/API/SBTypeFormat.h"\ |
| 122 | " ${SRC_ROOT}/include/lldb/API/SBTypeNameSpecifier.h"\ |
| 123 | " ${SRC_ROOT}/include/lldb/API/SBTypeSummary.h"\ |
| 124 | " ${SRC_ROOT}/include/lldb/API/SBTypeSynthetic.h"\ |
Caroline Tice | 7740412 | 2010-09-22 16:41:52 +0000 | [diff] [blame] | 125 | " ${SRC_ROOT}/include/lldb/API/SBValue.h"\ |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 126 | " ${SRC_ROOT}/include/lldb/API/SBValueList.h"\ |
Enrico Granata | 21dfcd9 | 2012-09-28 23:57:51 +0000 | [diff] [blame] | 127 | " ${SRC_ROOT}/include/lldb/API/SBWatchpoint.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 128 | |
Johnny Chen | 8a8ce4a | 2011-09-09 17:37:06 +0000 | [diff] [blame] | 129 | INTERFACE_FILES="${SRC_ROOT}/scripts/Python/interface/SBAddress.i"\ |
| 130 | " ${SRC_ROOT}/scripts/Python/interface/SBBlock.i"\ |
| 131 | " ${SRC_ROOT}/scripts/Python/interface/SBBreakpoint.i"\ |
| 132 | " ${SRC_ROOT}/scripts/Python/interface/SBBreakpointLocation.i"\ |
| 133 | " ${SRC_ROOT}/scripts/Python/interface/SBBroadcaster.i"\ |
| 134 | " ${SRC_ROOT}/scripts/Python/interface/SBCommandInterpreter.i"\ |
| 135 | " ${SRC_ROOT}/scripts/Python/interface/SBCommandReturnObject.i"\ |
| 136 | " ${SRC_ROOT}/scripts/Python/interface/SBCommunication.i"\ |
| 137 | " ${SRC_ROOT}/scripts/Python/interface/SBCompileUnit.i"\ |
| 138 | " ${SRC_ROOT}/scripts/Python/interface/SBData.i"\ |
| 139 | " ${SRC_ROOT}/scripts/Python/interface/SBDebugger.i"\ |
Enrico Granata | 10de090 | 2012-10-10 22:54:17 +0000 | [diff] [blame] | 140 | " ${SRC_ROOT}/scripts/Python/interface/SBDeclaration.i"\ |
Johnny Chen | 8a8ce4a | 2011-09-09 17:37:06 +0000 | [diff] [blame] | 141 | " ${SRC_ROOT}/scripts/Python/interface/SBError.i"\ |
| 142 | " ${SRC_ROOT}/scripts/Python/interface/SBEvent.i"\ |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 143 | " ${SRC_ROOT}/scripts/Python/interface/SBExpressionOptions.i"\ |
Johnny Chen | 8a8ce4a | 2011-09-09 17:37:06 +0000 | [diff] [blame] | 144 | " ${SRC_ROOT}/scripts/Python/interface/SBFileSpec.i"\ |
| 145 | " ${SRC_ROOT}/scripts/Python/interface/SBFrame.i"\ |
| 146 | " ${SRC_ROOT}/scripts/Python/interface/SBFunction.i"\ |
| 147 | " ${SRC_ROOT}/scripts/Python/interface/SBHostOS.i"\ |
| 148 | " ${SRC_ROOT}/scripts/Python/interface/SBInputReader.i"\ |
| 149 | " ${SRC_ROOT}/scripts/Python/interface/SBInstruction.i"\ |
| 150 | " ${SRC_ROOT}/scripts/Python/interface/SBInstructionList.i"\ |
| 151 | " ${SRC_ROOT}/scripts/Python/interface/SBLineEntry.i"\ |
| 152 | " ${SRC_ROOT}/scripts/Python/interface/SBListener.i"\ |
| 153 | " ${SRC_ROOT}/scripts/Python/interface/SBModule.i"\ |
Greg Clayton | 226cce2 | 2013-07-08 22:22:41 +0000 | [diff] [blame^] | 154 | " ${SRC_ROOT}/scripts/Python/interface/SBModuleSpec.i"\ |
Johnny Chen | 8a8ce4a | 2011-09-09 17:37:06 +0000 | [diff] [blame] | 155 | " ${SRC_ROOT}/scripts/Python/interface/SBProcess.i"\ |
| 156 | " ${SRC_ROOT}/scripts/Python/interface/SBSourceManager.i"\ |
| 157 | " ${SRC_ROOT}/scripts/Python/interface/SBStream.i"\ |
| 158 | " ${SRC_ROOT}/scripts/Python/interface/SBStringList.i"\ |
| 159 | " ${SRC_ROOT}/scripts/Python/interface/SBSymbol.i"\ |
| 160 | " ${SRC_ROOT}/scripts/Python/interface/SBSymbolContext.i"\ |
| 161 | " ${SRC_ROOT}/scripts/Python/interface/SBTarget.i"\ |
| 162 | " ${SRC_ROOT}/scripts/Python/interface/SBThread.i"\ |
| 163 | " ${SRC_ROOT}/scripts/Python/interface/SBType.i"\ |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 164 | " ${SRC_ROOT}/scripts/Python/interface/SBTypeCategory.i"\ |
| 165 | " ${SRC_ROOT}/scripts/Python/interface/SBTypeFilter.i"\ |
| 166 | " ${SRC_ROOT}/scripts/Python/interface/SBTypeFormat.i"\ |
| 167 | " ${SRC_ROOT}/scripts/Python/interface/SBTypeNameSpecifier.i"\ |
| 168 | " ${SRC_ROOT}/scripts/Python/interface/SBTypeSummary.i"\ |
| 169 | " ${SRC_ROOT}/scripts/Python/interface/SBTypeSynthetic.i"\ |
Johnny Chen | 8a8ce4a | 2011-09-09 17:37:06 +0000 | [diff] [blame] | 170 | " ${SRC_ROOT}/scripts/Python/interface/SBValue.i"\ |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 171 | " ${SRC_ROOT}/scripts/Python/interface/SBValueList.i"\ |
Greg Clayton | 1b282f9 | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 172 | " ${SRC_ROOT}/scripts/Python/interface/SBWatchpoint.i" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 173 | |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 174 | if [ $Debug -eq 1 ] |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 175 | then |
| 176 | echo "Header files are:" |
| 177 | echo ${HEADER_FILES} |
| 178 | fi |
| 179 | |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 180 | if [ $Debug -eq 1 ] |
Enrico Granata | 9128ee2 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 181 | then |
| 182 | echo "SWIG interface files are:" |
| 183 | echo ${INTERFACE_FILES} |
| 184 | fi |
| 185 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 186 | NeedToUpdate=0 |
| 187 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 188 | |
Johnny Chen | 5fca8ca | 2010-08-26 20:04:17 +0000 | [diff] [blame] | 189 | if [ ! -f ${swig_output_file} ] |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 190 | then |
| 191 | NeedToUpdate=1 |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 192 | if [ $Debug -eq 1 ] |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 193 | then |
| 194 | echo "Failed to find LLDBWrapPython.cpp" |
| 195 | fi |
| 196 | fi |
| 197 | |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 198 | if [ $NeedToUpdate -eq 0 ] |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 199 | then |
| 200 | for hdrfile in ${HEADER_FILES} |
| 201 | do |
Johnny Chen | 5fca8ca | 2010-08-26 20:04:17 +0000 | [diff] [blame] | 202 | if [ $hdrfile -nt ${swig_output_file} ] |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 203 | then |
| 204 | NeedToUpdate=1 |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 205 | if [ $Debug -eq 1 ] |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 206 | then |
| 207 | echo "${hdrfile} is newer than ${swig_output_file}" |
| 208 | echo "swig file will need to be re-built." |
| 209 | fi |
Johnny Chen | 5fca8ca | 2010-08-26 20:04:17 +0000 | [diff] [blame] | 210 | break |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 211 | fi |
| 212 | done |
| 213 | fi |
| 214 | |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 215 | if [ $NeedToUpdate -eq 0 ] |
Johnny Chen | 5fca8ca | 2010-08-26 20:04:17 +0000 | [diff] [blame] | 216 | then |
Enrico Granata | 9128ee2 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 217 | for intffile in ${INTERFACE_FILES} |
| 218 | do |
| 219 | if [ $intffile -nt ${swig_output_file} ] |
| 220 | then |
| 221 | NeedToUpdate=1 |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 222 | if [ $Debug -eq 1 ] |
Enrico Granata | 9128ee2 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 223 | then |
| 224 | echo "${intffile} is newer than ${swig_output_file}" |
| 225 | echo "swig file will need to be re-built." |
| 226 | fi |
| 227 | break |
| 228 | fi |
| 229 | done |
| 230 | fi |
| 231 | |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 232 | if [ $NeedToUpdate -eq 0 ] |
Enrico Granata | 9128ee2 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 233 | then |
Johnny Chen | 5fca8ca | 2010-08-26 20:04:17 +0000 | [diff] [blame] | 234 | if [ ${swig_input_file} -nt ${swig_output_file} ] |
| 235 | then |
| 236 | NeedToUpdate=1 |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 237 | if [ $Debug -eq 1 ] |
Johnny Chen | 5fca8ca | 2010-08-26 20:04:17 +0000 | [diff] [blame] | 238 | then |
| 239 | echo "${swig_input_file} is newer than ${swig_output_file}" |
| 240 | echo "swig file will need to be re-built." |
| 241 | fi |
| 242 | fi |
| 243 | fi |
| 244 | |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 245 | if [ $NeedToUpdate -eq 0 ] |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 246 | then |
Johnny Chen | 30123f1 | 2011-08-22 22:10:57 +0000 | [diff] [blame] | 247 | if [ ${swig_python_extensions} -nt ${swig_output_file} ] |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 248 | then |
| 249 | NeedToUpdate=1 |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 250 | if [ $Debug -eq 1 ] |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 251 | then |
Johnny Chen | 30123f1 | 2011-08-22 22:10:57 +0000 | [diff] [blame] | 252 | echo "${swig_python_extensions} is newer than ${swig_output_file}" |
| 253 | echo "swig file will need to be re-built." |
| 254 | fi |
| 255 | fi |
| 256 | fi |
| 257 | |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 258 | if [ $NeedToUpdate -eq 0 ] |
Johnny Chen | 30123f1 | 2011-08-22 22:10:57 +0000 | [diff] [blame] | 259 | then |
| 260 | if [ ${swig_python_wrapper} -nt ${swig_output_file} ] |
| 261 | then |
| 262 | NeedToUpdate=1 |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 263 | if [ $Debug -eq 1 ] |
Johnny Chen | 30123f1 | 2011-08-22 22:10:57 +0000 | [diff] [blame] | 264 | then |
| 265 | echo "${swig_python_wrapper} is newer than ${swig_output_file}" |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 266 | echo "swig file will need to be re-built." |
| 267 | fi |
| 268 | fi |
| 269 | fi |
| 270 | |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 271 | if [ $NeedToUpdate -eq 0 ] |
Enrico Granata | 9d2063e | 2012-02-02 17:26:00 +0000 | [diff] [blame] | 272 | then |
| 273 | if [ ${swig_python_typemaps} -nt ${swig_output_file} ] |
| 274 | then |
| 275 | NeedToUpdate=1 |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 276 | if [ $Debug -eq 1 ] |
Enrico Granata | 9d2063e | 2012-02-02 17:26:00 +0000 | [diff] [blame] | 277 | then |
| 278 | echo "${swig_python_typemaps} is newer than ${swig_output_file}" |
| 279 | echo "swig file will need to be re-built." |
| 280 | fi |
| 281 | fi |
| 282 | fi |
| 283 | |
Enrico Granata | c972c70 | 2013-06-21 18:57:30 +0000 | [diff] [blame] | 284 | if [ $NeedToUpdate -eq 0 ] |
| 285 | then |
| 286 | if [ ${swig_python_swigsafecast} -nt ${swig_output_file} ] |
| 287 | then |
| 288 | NeedToUpdate=1 |
| 289 | if [ $Debug -eq 1 ] |
| 290 | then |
| 291 | echo "${swig_python_swigsafecast} is newer than ${swig_output_file}" |
| 292 | echo "swig file will need to be re-built." |
| 293 | fi |
| 294 | fi |
| 295 | fi |
| 296 | |
Filipe Cabecinhas | 3e9e081 | 2012-09-14 17:09:15 +0000 | [diff] [blame] | 297 | python_version=`/usr/bin/env python --version 2>&1 | sed -e 's,Python ,,' -e 's,[.][0-9],,2' -e 's,[a-z][a-z][0-9],,'` |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 298 | |
Filipe Cabecinhas | c281a3b | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 299 | if [ $MakefileCalled -eq 0 ] |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 300 | then |
Filipe Cabecinhas | c281a3b | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 301 | framework_python_dir="${TARGET_DIR}/LLDB.framework/Resources/Python/lldb" |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 302 | else |
Filipe Cabecinhas | c281a3b | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 303 | if [ -n "${PYTHON_INSTALL_DIR}" ] |
| 304 | then |
| 305 | framework_python_dir=`/usr/bin/env python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(True, False, \"${PYTHON_INSTALL_DIR}\");"`/lldb |
| 306 | else |
| 307 | framework_python_dir=`/usr/bin/env python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(True, False);"`/lldb |
| 308 | fi |
Caroline Tice | d6ac384 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 309 | fi |
| 310 | |
Filipe Cabecinhas | c281a3b | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 311 | [ -n "${CONFIG_BUILD_DIR}" ] || CONFIG_BUILD_DIR=${framework_python_dir} |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 312 | |
| 313 | if [ ! -L "${framework_python_dir}/_lldb.so" ] |
| 314 | then |
| 315 | NeedToUpdate=1 |
| 316 | fi |
| 317 | |
Filipe Cabecinhas | c281a3b | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 318 | if [ ! -f "${framework_python_dir}/__init__.py" ] |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 319 | then |
| 320 | NeedToUpdate=1 |
| 321 | fi |
| 322 | |
| 323 | |
Jason Molenda | 47d114a | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 324 | if [ $NeedToUpdate -eq 0 ] |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 325 | then |
| 326 | echo "Everything is up-to-date." |
| 327 | exit 0 |
| 328 | else |
| 329 | echo "SWIG needs to be re-run." |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 330 | if [ -f ${swig_output_file} ] |
| 331 | then |
| 332 | rm ${swig_output_file} |
| 333 | fi |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 334 | fi |
| 335 | |
| 336 | |
| 337 | # Build the SWIG C++ wrapper file for Python. |
| 338 | |
Filipe Cabecinhas | c281a3b | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 339 | if [ $GenerateDependencies -eq 1 ] |
| 340 | then |
| 341 | if $SWIG -c++ -shadow -python -threads -I"${SRC_ROOT}/include" -I./. -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -MMD -MF "${swig_depend_file}.tmp" -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}" |
| 342 | then |
| 343 | mv -f "${swig_depend_file}.tmp" "${swig_depend_file}" |
| 344 | else |
| 345 | rm -f "${swig_depend_file}.tmp" |
| 346 | exit 1 |
| 347 | fi |
| 348 | else |
| 349 | $SWIG -c++ -shadow -python -threads -I"${SRC_ROOT}/include" -I./. -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}" || exit $? |
| 350 | fi |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 351 | |
Johnny Chen | f1c95f8 | 2011-04-29 19:22:24 +0000 | [diff] [blame] | 352 | # Implement the iterator protocol and/or eq/ne operators for some lldb objects. |
Caroline Tice | ebc1bb2 | 2010-06-30 16:22:25 +0000 | [diff] [blame] | 353 | # Append global variable to lldb Python module. |
Johnny Chen | fbc0d27 | 2011-04-28 21:31:18 +0000 | [diff] [blame] | 354 | # And initialize the lldb debugger subsystem. |
Caroline Tice | ebc1bb2 | 2010-06-30 16:22:25 +0000 | [diff] [blame] | 355 | current_dir=`pwd` |
Johnny Chen | fbc0d27 | 2011-04-28 21:31:18 +0000 | [diff] [blame] | 356 | if [ -f "${current_dir}/modify-python-lldb.py" ] |
Caroline Tice | ebc1bb2 | 2010-06-30 16:22:25 +0000 | [diff] [blame] | 357 | then |
Johnny Chen | fbc0d27 | 2011-04-28 21:31:18 +0000 | [diff] [blame] | 358 | python ${current_dir}/modify-python-lldb.py ${CONFIG_BUILD_DIR} |
Caroline Tice | ebc1bb2 | 2010-06-30 16:22:25 +0000 | [diff] [blame] | 359 | fi |
Caroline Tice | 3cc8751 | 2010-10-28 21:51:20 +0000 | [diff] [blame] | 360 | |
| 361 | # Fix the "#include" statement in the swig output file |
| 362 | |
| 363 | if [ -f "${current_dir}/edit-swig-python-wrapper-file.py" ] |
| 364 | then |
Filipe Cabecinhas | c281a3b | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 365 | if [ $MakefileCalled -eq 1 ] |
| 366 | then |
| 367 | python ${current_dir}/edit-swig-python-wrapper-file.py "${TARGET_DIR}" |
| 368 | else |
| 369 | python ${current_dir}/edit-swig-python-wrapper-file.py |
| 370 | fi |
Caroline Tice | 3cc8751 | 2010-10-28 21:51:20 +0000 | [diff] [blame] | 371 | if [ -f "${swig_output_file}.edited" ] |
| 372 | then |
| 373 | mv "${swig_output_file}.edited" ${swig_output_file} |
| 374 | fi |
| 375 | fi |
Greg Clayton | dce502e | 2011-11-04 03:34:56 +0000 | [diff] [blame] | 376 | |
Greg Clayton | dce502e | 2011-11-04 03:34:56 +0000 | [diff] [blame] | 377 | fi |