blob: d15af40f12b3c86db0a3ac7e55051c2d4f568091 [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
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000029
30shift 4
Caroline Tice9dbe7172010-06-16 19:26:52 +000031
32#
33# Check to see if we are in debug-mode or not.
34#
Chris Lattner24943d22010-06-08 16:52:24 +000035
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000036if [ -n "$1" -a "$1" = "-debug" ]
Chris Lattner24943d22010-06-08 16:52:24 +000037then
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000038 debug_flag="$1"
Chris Lattner24943d22010-06-08 16:52:24 +000039 Debug=1
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000040 shift
Chris Lattner24943d22010-06-08 16:52:24 +000041else
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000042 debug_flag=""
Chris Lattner24943d22010-06-08 16:52:24 +000043 Debug=0
44fi
45
46#
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000047# 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
51if [ -n "$1" -a "$1" = "-m" ]
52then
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
62else
63 makefile_flag=""
64 dependency_flag=""
65fi
66
67#
Chris Lattner24943d22010-06-08 16:52:24 +000068# Verify that 'lldb.swig' exists.
69#
70
Caroline Tice9dbe7172010-06-16 19:26:52 +000071if [ ! -f ${SRC_ROOT}/scripts/lldb.swig ]
Chris Lattner24943d22010-06-08 16:52:24 +000072then
73 echo Error: unable to find file 'lldb.swig' >&2
74 exit 1
75fi
76
Jason Molendae2801e12012-09-27 21:26:57 +000077if [ $Debug -eq 1 ]
Chris Lattner24943d22010-06-08 16:52:24 +000078then
79 echo "Found lldb.swig file"
80fi
81
82#
Jim Ingham2396b9f2011-03-01 01:39:04 +000083# Next look for swig
84#
85
Daniel Malea01945532012-11-28 23:49:11 +000086SWIG=`which swig`
87if [ ! -x "$SWIG" -a -f /usr/bin/swig ]
Jim Ingham2396b9f2011-03-01 01:39:04 +000088then
89 SWIG=/usr/bin/swig
90else
91 if [ -f /usr/local/bin/swig ]
92 then
93 SWIG=/usr/local/bin/swig
94 fi
95fi
96
Jason Molendae2801e12012-09-27 21:26:57 +000097if [ ${SWIG}a = a ]
Jim Ingham2396b9f2011-03-01 01:39:04 +000098then
99 echo Error: could not find the swig binary
100 exit 1
101fi
102
103#
Chris Lattner24943d22010-06-08 16:52:24 +0000104# 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
110languages="Python"
Caroline Tice9dbe7172010-06-16 19:26:52 +0000111cwd=${SRC_ROOT}/scripts
Chris Lattner24943d22010-06-08 16:52:24 +0000112
113for curlang in $languages
114do
Jason Molendae2801e12012-09-27 21:26:57 +0000115 if [ $Debug -eq 1 ]
Chris Lattner24943d22010-06-08 16:52:24 +0000116 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 Molendae2801e12012-09-27 21:26:57 +0000126 if [ $Debug -eq 1 ]
Chris Lattner24943d22010-06-08 16:52:24 +0000127 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 Molendae2801e12012-09-27 21:26:57 +0000141 if [ $Debug -eq 1 ]
Chris Lattner24943d22010-06-08 16:52:24 +0000142 then
143 echo "Found $curlang build script."
144 echo "Executing $curlang build script..."
145 fi
146
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +0000147 ./build-swig-${curlang}.sh "$SRC_ROOT" "$TARGET_DIR" "$CONFIG_BUILD_DIR" "${PREFIX}" "${debug_flag}" "${SWIG}" "${makefile_flag}" "${dependency_flag}" || exit $?
Chris Lattner24943d22010-06-08 16:52:24 +0000148 fi
149 fi
150done
151