blob: 34726eb62d3fa22f527cdaec155ac12960f090e5 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001#!/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 Tice9dbe7172010-06-16 19:26:52 +000013# 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
25SRC_ROOT=$1
26TARGET_DIR=$2
27CONFIG_BUILD_DIR=$3
28PREFIX=$4
29debug_flag=$5
30
31#
32# Check to see if we are in debug-mode or not.
33#
Chris Lattner24943d22010-06-08 16:52:24 +000034
35if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ]
36then
37 Debug=1
38else
39 Debug=0
40fi
41
42#
43# Verify that 'lldb.swig' exists.
44#
45
Caroline Tice9dbe7172010-06-16 19:26:52 +000046if [ ! -f ${SRC_ROOT}/scripts/lldb.swig ]
Chris Lattner24943d22010-06-08 16:52:24 +000047then
48 echo Error: unable to find file 'lldb.swig' >&2
49 exit 1
50fi
51
52if [ $Debug == 1 ]
53then
54 echo "Found lldb.swig file"
55fi
56
57#
Jim Ingham2396b9f2011-03-01 01:39:04 +000058# Next look for swig
59#
60
61SWIG=
62if [ -f /usr/bin/swig ]
63then
64 SWIG=/usr/bin/swig
65else
66 if [ -f /usr/local/bin/swig ]
67 then
68 SWIG=/usr/local/bin/swig
69 fi
70fi
71
72if [ ${SWIG}a == a ]
73then
74 echo Error: could not find the swig binary
75 exit 1
76fi
77
78#
Chris Lattner24943d22010-06-08 16:52:24 +000079# 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
85languages="Python"
Caroline Tice9dbe7172010-06-16 19:26:52 +000086cwd=${SRC_ROOT}/scripts
Chris Lattner24943d22010-06-08 16:52:24 +000087
88for curlang in $languages
89do
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 Cabecinhas4bb4f302012-09-14 17:09:15 +0000122 ./build-swig-${curlang}.sh "$SRC_ROOT" "$TARGET_DIR" "$CONFIG_BUILD_DIR" "${PREFIX}" "${debug_flag}" "${SWIG}"
Chris Lattner24943d22010-06-08 16:52:24 +0000123 fi
124 fi
125done
126