summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python/build-swig-Python.sh
blob: 9dc4b991c4ad647560b9fbf27e665a49c09510e4 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh

# build-swig-Python.sh


debug_flag=$1

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


HEADER_FILES="${SRCROOT}/include/lldb/lldb-types.h"\
" ${SRCROOT}/include/lldb/API/SBAddress.h"\
" ${SRCROOT}/include/lldb/API/SBBlock.h"\
" ${SRCROOT}/include/lldb/API/SBBreakpoint.h"\
" ${SRCROOT}/include/lldb/API/SBBreakpointLocation.h"\
" ${SRCROOT}/include/lldb/API/SBBroadcaster.h"\
" ${SRCROOT}/include/lldb/API/SBCommandContext.h"\
" ${SRCROOT}/include/lldb/API/SBCommandInterpreter.h"\
" ${SRCROOT}/include/lldb/API/SBCommandReturnObject.h"\
" ${SRCROOT}/include/lldb/API/SBCompileUnit.h"\
" ${SRCROOT}/include/lldb/API/SBDebugger.h"\
" ${SRCROOT}/include/lldb/API/SBError.h"\
" ${SRCROOT}/include/lldb/API/SBEvent.h"\
" ${SRCROOT}/include/lldb/API/SBFrame.h"\
" ${SRCROOT}/include/lldb/API/SBFunction.h"\
" ${SRCROOT}/include/lldb/API/SBLineEntry.h"\
" ${SRCROOT}/include/lldb/API/SBListener.h"\
" ${SRCROOT}/include/lldb/API/SBModule.h"\
" ${SRCROOT}/include/lldb/API/SBProcess.h"\
" ${SRCROOT}/include/lldb/API/SBSourceManager.h"\
" ${SRCROOT}/include/lldb/API/SBStringList.h"\
" ${SRCROOT}/include/lldb/API/SBSymbol.h"\
" ${SRCROOT}/include/lldb/API/SBSymbolContext.h"\
" ${SRCROOT}/include/lldb/API/SBTarget.h"\
" ${SRCROOT}/include/lldb/API/SBThread.h"\
" ${SRCROOT}/include/lldb/API/SBType.h"\
" ${SRCROOT}/include/lldb/API/SBValue.h"


if [ $Debug == 1 ]
then
    echo "Header files are:"
    echo ${HEADER_FILES}
fi

NeedToUpdate=0

swig_output_file=${SCRIPT_INPUT_FILE_1}

if [ ! -f $swig_output_file ]
then
    NeedToUpdate=1
    if [ $Debug == 1 ]
    then
        echo "Failed to find LLDBWrapPython.cpp"
    fi
fi

if [ $NeedToUpdate == 0 ]
then
    for hdrfile in ${HEADER_FILES}
    do
        if [ $hdrfile -nt $swig_output_file ]
        then
            NeedToUpdate=1
            if [ $Debug == 1 ]
            then
                echo "${hdrfile} is newer than ${swig_output_file}"
                echo "swig file will need to be re-built."
            fi
        fi
    done
fi

framework_python_dir="${CONFIGURATION_BUILD_DIR}/LLDB.framework/Versions/A/Resources/Python"

if [ ! -L "${framework_python_dir}/_lldb.so" ]
then
    NeedToUpdate=1
fi

if [ ! -f "${framework_python_dir}/lldb.py" ]
then
    NeedToUpdate=1
fi


if [ $NeedToUpdate == 0 ]
then
    echo "Everything is up-to-date."
    exit 0
else
    echo "SWIG needs to be re-run."
fi


# Build the SWIG C++ wrapper file for Python.

swig -c++ -shadow -python -I"${SRCROOT}/include" -I./. -outdir "${CONFIGURATION_BUILD_DIR}" -o "${SCRIPT_INPUT_FILE_1}" "${SCRIPT_INPUT_FILE_0}"

# Edit the C++ wrapper file that SWIG generated for Python.  There are two
# global string replacements needed, which the following script file takes
# care of.  It reads in 'LLDBWrapPython.cpp' and generates 
# 'LLDBWrapPython.cpp.edited'.

# The need for this has been eliminated by fixing the namespace qualifiers on return types.
# Leaving this here for now, just in case...
#
#if [ -f "${SRCROOT}/scripts/Python/edit-swig-python-wrapper-file.py" ]
#then
#    python "${SRCROOT}/scripts/Python/edit-swig-python-wrapper-file.py"
#fi

#
# Now that we've got a C++ file we're happy with (hopefully), rename the
# edited file and move it to the appropriate places.
#

if [ -f "${SCRIPT_INPUT_FILE_1}.edited" ]
then
    mv "${SCRIPT_INPUT_FILE_1}.edited" "${SCRIPT_INPUT_FILE_1}"
fi
OpenPOWER on IntegriCloud