blob: f0bca4bf18e252982533500b99c087aeeabd3c42 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001#! /bin/sh
2
3# finish-swig-wrapper-classes.sh
4#
5# For each scripting language liblldb supports, we need to create the
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +00006# appropriate Script Bridge wrapper classes for that language so that
Chris Lattner24943d22010-06-08 16:52:24 +00007# users can call Script Bridge functions from within the script interpreter.
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +00008#
Chris Lattner24943d22010-06-08 16:52:24 +00009# We use SWIG to create a C++ file containing the appropriate wrapper classes
10# and funcitons for each scripting language, before liblldb is built (thus
11# the C++ file can be compiled into liblldb. In some cases, additional work
12# may need to be done after liblldb has been compiled, to make the scripting
13# language stuff fully functional. Any such post-processing is handled through
14# the shell scripts called here.
15
Caroline Tice9dbe7172010-06-16 19:26:52 +000016# 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 generated from running SWIG.
20# PREFIX is the root directory used to determine where third-party modules
21# for scripting languages should be installed.
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
Chris Lattner24943d22010-06-08 16:52:24 +000029
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000030shift 4
31
32if [ -n "$1" -a "$1" = "-debug" ]
Chris Lattner24943d22010-06-08 16:52:24 +000033then
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000034 debug_flag=$1
Chris Lattner24943d22010-06-08 16:52:24 +000035 Debug=1
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000036 shift
Chris Lattner24943d22010-06-08 16:52:24 +000037else
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000038 debug_flag=""
Chris Lattner24943d22010-06-08 16:52:24 +000039 Debug=0
40fi
41
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000042if [ -n "$1" -a "$1" = "-m" ]
43then
44 makefile_flag="$1"
45 shift
46else
47 makefile_flag=""
48fi
Chris Lattner24943d22010-06-08 16:52:24 +000049
50#
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000051# For each scripting language, see if a post-processing script for that
Chris Lattner24943d22010-06-08 16:52:24 +000052# language exists, and if so, call it.
53#
54# For now the only language we support is Python, but we expect this to
55# change.
56
57languages="Python"
Caroline Tice9dbe7172010-06-16 19:26:52 +000058cwd=${SRC_ROOT}/scripts
Chris Lattner24943d22010-06-08 16:52:24 +000059
60for curlang in $languages
61do
Jason Molendae2801e12012-09-27 21:26:57 +000062 if [ $Debug -eq 1 ]
Chris Lattner24943d22010-06-08 16:52:24 +000063 then
64 echo "Current language is $curlang"
65 fi
66
67 if [ ! -d "$cwd/$curlang" ]
68 then
69 echo "error: unable to find $curlang script sub-dirctory" >&2
70 continue
71 else
72
Jason Molendae2801e12012-09-27 21:26:57 +000073 if [ $Debug -eq 1 ]
Chris Lattner24943d22010-06-08 16:52:24 +000074 then
75 echo "Found $curlang sub-directory"
76 fi
77
78 cd $cwd/$curlang
79
Caroline Tice9dbe7172010-06-16 19:26:52 +000080 filename="./finish-swig-${curlang}-LLDB.sh"
Chris Lattner24943d22010-06-08 16:52:24 +000081
82 if [ -f $filename ]
83 then
Jason Molendae2801e12012-09-27 21:26:57 +000084 if [ $Debug -eq 1 ]
Chris Lattner24943d22010-06-08 16:52:24 +000085 then
Caroline Tice9dbe7172010-06-16 19:26:52 +000086 echo "Found $curlang post-processing script for LLDB"
Chris Lattner24943d22010-06-08 16:52:24 +000087 echo "Executing $curlang post-processing script..."
88 fi
89
Filipe Cabecinhasf2b0fef2012-11-01 18:55:16 +000090
91 ./finish-swig-${curlang}-LLDB.sh $SRC_ROOT $TARGET_DIR $CONFIG_BUILD_DIR "${PREFIX}" "${debug_flag}" "${makefile_flag}"
Chris Lattner24943d22010-06-08 16:52:24 +000092 fi
93 fi
94done
95
96exit 0