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 | # |
| 58 | # For each scripting language, make sure the build script for that language |
| 59 | # exists, and if so, call it. |
| 60 | # |
| 61 | # For now the only language we support is Python, but we expect this to |
| 62 | # change. |
| 63 | |
| 64 | languages="Python" |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame^] | 65 | cwd=${SRC_ROOT}/scripts |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 66 | |
| 67 | for curlang in $languages |
| 68 | do |
| 69 | if [ $Debug == 1 ] |
| 70 | then |
| 71 | echo "Current language is $curlang" |
| 72 | fi |
| 73 | |
| 74 | if [ ! -d "$cwd/$curlang" ] |
| 75 | then |
| 76 | echo "Error: unable to find $curlang script sub-dirctory" >&2 |
| 77 | continue |
| 78 | else |
| 79 | |
| 80 | if [ $Debug == 1 ] |
| 81 | then |
| 82 | echo "Found $curlang sub-directory" |
| 83 | fi |
| 84 | |
| 85 | cd $cwd/$curlang |
| 86 | |
| 87 | filename="./build-swig-${curlang}.sh" |
| 88 | |
| 89 | if [ ! -f $filename ] |
| 90 | then |
| 91 | echo "Error: unable to find swig build script for $curlang: $filename" >&2 |
| 92 | continue |
| 93 | else |
| 94 | |
| 95 | if [ $Debug == 1 ] |
| 96 | then |
| 97 | echo "Found $curlang build script." |
| 98 | echo "Executing $curlang build script..." |
| 99 | fi |
| 100 | |
Caroline Tice | 9dbe717 | 2010-06-16 19:26:52 +0000 | [diff] [blame^] | 101 | ./build-swig-${curlang}.sh $SRC_ROOT $TARGET_DIR $CONFIG_BUILD_DIR "${PREFIX}" "${debug_flag}" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 102 | fi |
| 103 | fi |
| 104 | done |
| 105 | |