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 |
| 29 | debug_flag=$5 |
| 30 | |
| 31 | # |
| 32 | # Check to see if we are in debug-mode or not. |
| 33 | # |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 34 | |
| 35 | if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ] |
| 36 | then |
| 37 | Debug=1 |
| 38 | else |
| 39 | Debug=0 |
| 40 | fi |
| 41 | |
| 42 | # |
| 43 | # Verify that 'lldb.swig' exists. |
| 44 | # |
| 45 | |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 46 | if [ ! -f ${SRC_ROOT}/scripts/lldb.swig ] |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 47 | then |
| 48 | echo Error: unable to find file 'lldb.swig' >&2 |
| 49 | exit 1 |
| 50 | fi |
| 51 | |
| 52 | if [ $Debug == 1 ] |
| 53 | then |
| 54 | echo "Found lldb.swig file" |
| 55 | fi |
| 56 | |
| 57 | # |
Jim Ingham | 2396b9f | 2011-03-01 01:39:04 +0000 | [diff] [blame] | 58 | # Next look for swig |
| 59 | # |
| 60 | |
| 61 | SWIG= |
| 62 | if [ -f /usr/bin/swig ] |
| 63 | then |
| 64 | SWIG=/usr/bin/swig |
| 65 | else |
| 66 | if [ -f /usr/local/bin/swig ] |
| 67 | then |
| 68 | SWIG=/usr/local/bin/swig |
| 69 | fi |
| 70 | fi |
| 71 | |
| 72 | if [ ${SWIG}a == a ] |
| 73 | then |
| 74 | echo Error: could not find the swig binary |
| 75 | exit 1 |
| 76 | fi |
| 77 | |
| 78 | # |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 79 | # For each scripting language, make sure the build script for that language |
| 80 | # exists, and if so, call it. |
| 81 | # |
| 82 | # For now the only language we support is Python, but we expect this to |
| 83 | # change. |
| 84 | |
| 85 | languages="Python" |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame] | 86 | cwd=${SRC_ROOT}/scripts |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 87 | |
| 88 | for curlang in $languages |
| 89 | do |
| 90 | if [ $Debug == 1 ] |
| 91 | then |
| 92 | echo "Current language is $curlang" |
| 93 | fi |
| 94 | |
| 95 | if [ ! -d "$cwd/$curlang" ] |
| 96 | then |
| 97 | echo "Error: unable to find $curlang script sub-dirctory" >&2 |
| 98 | continue |
| 99 | else |
| 100 | |
| 101 | if [ $Debug == 1 ] |
| 102 | then |
| 103 | echo "Found $curlang sub-directory" |
| 104 | fi |
| 105 | |
| 106 | cd $cwd/$curlang |
| 107 | |
| 108 | filename="./build-swig-${curlang}.sh" |
| 109 | |
| 110 | if [ ! -f $filename ] |
| 111 | then |
| 112 | echo "Error: unable to find swig build script for $curlang: $filename" >&2 |
| 113 | continue |
| 114 | else |
| 115 | |
| 116 | if [ $Debug == 1 ] |
| 117 | then |
| 118 | echo "Found $curlang build script." |
| 119 | echo "Executing $curlang build script..." |
| 120 | fi |
| 121 | |
Filipe Cabecinhas | 4bb4f30 | 2012-09-14 17:09:15 +0000 | [diff] [blame] | 122 | ./build-swig-${curlang}.sh "$SRC_ROOT" "$TARGET_DIR" "$CONFIG_BUILD_DIR" "${PREFIX}" "${debug_flag}" "${SWIG}" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 123 | fi |
| 124 | fi |
| 125 | done |
| 126 | |