Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 | |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 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 |
Filipe Cabecinhas | f2b0fef | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 29 | |
| 30 | shift 4 |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 31 | |
| 32 | # |
| 33 | # Check to see if we are in debug-mode or not. |
| 34 | # |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 35 | |
Filipe Cabecinhas | f2b0fef | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 36 | if [ -n "$1" -a "$1" = "-debug" ] |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 37 | then |
Filipe Cabecinhas | f2b0fef | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 38 | debug_flag="$1" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 39 | Debug=1 |
Filipe Cabecinhas | f2b0fef | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 40 | shift |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 41 | else |
Filipe Cabecinhas | f2b0fef | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 42 | debug_flag="" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 43 | Debug=0 |
| 44 | fi |
| 45 | |
| 46 | # |
Filipe Cabecinhas | f2b0fef | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 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 | # |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 68 | # Verify that 'lldb.swig' exists. |
| 69 | # |
| 70 | |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 71 | if [ ! -f ${SRC_ROOT}/scripts/lldb.swig ] |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 72 | then |
| 73 | echo Error: unable to find file 'lldb.swig' >&2 |
| 74 | exit 1 |
| 75 | fi |
| 76 | |
Jason Molenda | e2801e1 | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 77 | if [ $Debug -eq 1 ] |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 78 | then |
| 79 | echo "Found lldb.swig file" |
| 80 | fi |
| 81 | |
| 82 | # |
Jim Ingham | 2396b9f | 2011-03-01 01:39:04 +0000 | [diff] [blame] | 83 | # Next look for swig |
| 84 | # |
| 85 | |
Daniel Malea | 0194553 | 2012-11-28 23:49:11 +0000 | [diff] [blame] | 86 | SWIG=`which swig` |
| 87 | if [ ! -x "$SWIG" -a -f /usr/bin/swig ] |
Jim Ingham | 2396b9f | 2011-03-01 01:39:04 +0000 | [diff] [blame] | 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 | |
Jason Molenda | e2801e1 | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 97 | if [ ${SWIG}a = a ] |
Jim Ingham | 2396b9f | 2011-03-01 01:39:04 +0000 | [diff] [blame] | 98 | then |
| 99 | echo Error: could not find the swig binary |
| 100 | exit 1 |
| 101 | fi |
| 102 | |
| 103 | # |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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" |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 111 | cwd=${SRC_ROOT}/scripts |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 112 | |
| 113 | for curlang in $languages |
| 114 | do |
Jason Molenda | e2801e1 | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 115 | if [ $Debug -eq 1 ] |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 | |
Jason Molenda | e2801e1 | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 126 | if [ $Debug -eq 1 ] |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 | |
Jason Molenda | e2801e1 | 2012-09-27 21:26:57 +0000 | [diff] [blame] | 141 | if [ $Debug -eq 1 ] |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 142 | then |
| 143 | echo "Found $curlang build script." |
| 144 | echo "Executing $curlang build script..." |
| 145 | fi |
| 146 | |
Filipe Cabecinhas | f2b0fef | 2012-11-01 18:55:16 +0000 | [diff] [blame] | 147 | ./build-swig-${curlang}.sh "$SRC_ROOT" "$TARGET_DIR" "$CONFIG_BUILD_DIR" "${PREFIX}" "${debug_flag}" "${SWIG}" "${makefile_flag}" "${dependency_flag}" || exit $? |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 148 | fi |
| 149 | fi |
| 150 | done |
| 151 | |