1 #!/bin/sh 2 3 # build-swig-wrapper-classes.sh 4 # 5 # For each scripting language liblldb supports, we need to create the 6 # appropriate Script Bridge wrapper classes for that language so that 7 # users can call Script Bridge functions from within the script interpreter. 8 # 9 # We use SWIG to help create the appropriate wrapper classes/functions for 10 # the scripting language. In some cases the file generated by SWIG may 11 # need some tweaking before it is completely ready to use. 12 13 # Below are the arguments/parameters that this script takes (and passes along 14 # to all the language-specific build scripts that it calls): 15 # 16 # SRC_ROOT is the root of the lldb source tree. 17 # TARGET_DIR is where the lldb framework/shared library gets put. 18 # CONFIG_BUILD_DIR is where the build-swig-Python-LLDB.sh shell script 19 # put the lldb.py file it was generated from running SWIG. 20 # PREFIX is where non-Darwin systems want to put the .py and .so 21 # files so that Python can find them automatically. 22 # debug_flag (optional) determines whether or not this script outputs 23 # additional information when running. 24 25 SRC_ROOT=$1 26 TARGET_DIR=$2 27 CONFIG_BUILD_DIR=$3 28 PREFIX=$4 29 30 shift 4 31 32 # 33 # Check to see if we are in debug-mode or not. 34 # 35 36 if [ -n "$1" -a "$1" = "-debug" ] 37 then 38 debug_flag="$1" 39 Debug=1 40 shift 41 else 42 debug_flag="" 43 Debug=0 44 fi 45 46 # 47 # Check to see if we were called from the Makefile system. If we were, check 48 # if the caller wants swig to generate a dependency file. 49 # 50 51 if [ -n "$1" -a "$1" = "-m" ] 52 then 53 makefile_flag="$1" 54 shift 55 if [ -n "$1" -a "$1" = "-M" ] 56 then 57 dependency_flag="$1" 58 shift 59 else 60 dependency_flag="" 61 fi 62 else 63 makefile_flag="" 64 dependency_flag="" 65 fi 66 67 # 68 # Verify that 'lldb.swig' exists. 69 # 70 71 if [ ! -f ${SRC_ROOT}/scripts/lldb.swig ] 72 then 73 echo Error: unable to find file 'lldb.swig' >&2 74 exit 1 75 fi 76 77 if [ $Debug -eq 1 ] 78 then 79 echo "Found lldb.swig file" 80 fi 81 82 # 83 # Next look for swig 84 # 85 86 SWIG=`which swig` 87 if [ ! -x "$SWIG" -a -f /usr/bin/swig ] 88 then 89 SWIG=/usr/bin/swig 90 else 91 if [ -f /usr/local/bin/swig ] 92 then 93 SWIG=/usr/local/bin/swig 94 fi 95 fi 96 97 if [ ${SWIG}a = a ] 98 then 99 echo Error: could not find the swig binary 100 exit 1 101 fi 102 103 # 104 # For each scripting language, make sure the build script for that language 105 # exists, and if so, call it. 106 # 107 # For now the only language we support is Python, but we expect this to 108 # change. 109 110 languages="Python" 111 cwd=${SRC_ROOT}/scripts 112 113 for curlang in $languages 114 do 115 if [ $Debug -eq 1 ] 116 then 117 echo "Current language is $curlang" 118 fi 119 120 if [ ! -d "$cwd/$curlang" ] 121 then 122 echo "Error: unable to find $curlang script sub-dirctory" >&2 123 continue 124 else 125 126 if [ $Debug -eq 1 ] 127 then 128 echo "Found $curlang sub-directory" 129 fi 130 131 cd $cwd/$curlang 132 133 filename="./build-swig-${curlang}.sh" 134 135 if [ ! -f $filename ] 136 then 137 echo "Error: unable to find swig build script for $curlang: $filename" >&2 138 continue 139 else 140 141 if [ $Debug -eq 1 ] 142 then 143 echo "Found $curlang build script." 144 echo "Executing $curlang build script..." 145 fi 146 147 ./build-swig-${curlang}.sh "$SRC_ROOT" "$TARGET_DIR" "$CONFIG_BUILD_DIR" "${PREFIX}" "${debug_flag}" "${SWIG}" "${makefile_flag}" "${dependency_flag}" || exit $? 148 fi 149 fi 150 done 151 152