summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/finish-swig-wrapper-classes.sh
blob: 806f2862af69975454a8a4d78900fce426aca3e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#! /bin/sh

# finish-swig-wrapper-classes.sh
#
# For each scripting language liblldb supports, we need to create the
# appropriate Script Bridge wrapper classes for that language so that
# users can call Script Bridge functions from within the script interpreter.
#
# We use SWIG to create a C++ file containing the appropriate wrapper classes
# and funcitons for each scripting language, before liblldb is built (thus
# the C++ file can be compiled into liblldb.  In some cases, additional work
# may need to be done after liblldb has been compiled, to make the scripting
# language stuff fully functional.  Any such post-processing is handled through
# the shell scripts called here.

# SRC_ROOT is the root of the lldb source tree.
# TARGET_DIR is where the lldb framework/shared library gets put.
# CONFIG_BUILD_DIR is where the build-swig-Python-LLDB.sh  shell script
#           put the lldb.py file it generated from running SWIG.
# PREFIX is the root directory used to determine where third-party modules
#         for scripting languages should be installed.
# debug_flag (optional) determines whether or not this script outputs
#           additional information when running.

SRC_ROOT=$1
TARGET_DIR=$2
CONFIG_BUILD_DIR=$3
PREFIX=$4

shift 4

if [ -n "$1" -a "$1" = "-debug" ]
then
    debug_flag=$1
    Debug=1
    shift
else
    debug_flag=""
    Debug=0
fi

if [ -n "$1" -a "$1" = "-m" ]
then
    makefile_flag="$1"
    shift
else
    makefile_flag=""
fi

#
# For each scripting language, see if a post-processing script for that
# language exists, and if so, call it.
#
# For now the only language we support is Python, but we expect this to
# change.

languages="Python"
cwd=${SRC_ROOT}/scripts

for curlang in $languages
do
    if [ $Debug -eq 1 ]
    then
        echo "Current language is $curlang"
    fi

    if [ ! -d "$cwd/$curlang" ]
    then
        echo "error:  unable to find $curlang script sub-dirctory" >&2
        continue
    else

        if [ $Debug -eq 1 ]
        then
            echo "Found $curlang sub-directory"
        fi

        cd $cwd/$curlang

        filename="./finish-swig-${curlang}-LLDB.sh"

        if [ -f $filename ]
        then
            if [ $Debug -eq 1 ]
            then
                echo "Found $curlang post-processing script for LLDB"
                echo "Executing $curlang post-processing script..."
            fi


            ./finish-swig-${curlang}-LLDB.sh $SRC_ROOT $TARGET_DIR $CONFIG_BUILD_DIR "${PREFIX}" "${debug_flag}" "${makefile_flag}"
            retval=$?
            if [ $retval -ne 0 ]; then
                echo "$(pwd)/finish-swig-${curlang}-LLDB.sh failed with exit code $retval"
                exit $retval
            fi
        fi
    fi
done

exit 0
OpenPOWER on IntegriCloud