diff options
| -rw-r--r-- | lldb/lldb.xcodeproj/project.pbxproj | 6 | ||||
| -rwxr-xr-x | lldb/scripts/Python/build-swig-Python.sh | 108 | ||||
| -rwxr-xr-x | lldb/scripts/Python/finish-swig-Python-LLDB.sh | 158 | ||||
| -rwxr-xr-x | lldb/scripts/build-swig-wrapper-classes.sh | 28 | ||||
| -rwxr-xr-x | lldb/scripts/finish-swig-wrapper-classes.sh | 24 |
5 files changed, 241 insertions, 83 deletions
diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 1586c0b4fa1..75292fcded9 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -2337,15 +2337,13 @@ files = ( ); inputPaths = ( - "$(SRCROOT)/scripts/lldb.swig", - "$(SRCROOT)/source/LLDBWrapPython.cpp", ); name = "Build swig wrapper classes"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "sh $SRCROOT/scripts/build-swig-wrapper-classes.sh\n"; + shellScript = "sh $SRCROOT/scripts/build-swig-wrapper-classes.sh $SRCROOT $TARGET_BUILD_DIR $CONFIGURATION_BUILD_DIR \"\"\n"; }; 9A19ACE2116563A700E0D453 /* Finish swig wrapper classes (lldb) */ = { isa = PBXShellScriptBuildPhase; @@ -2365,7 +2363,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "sh $SRCROOT/scripts/finish-swig-wrapper-classes.sh"; + shellScript = "sh $SRCROOT/scripts/finish-swig-wrapper-classes.sh $SRCROOT $TARGET_BUILD_DIR $CONFIGURATION_BUILD_DIR \"\""; }; /* End PBXShellScriptBuildPhase section */ diff --git a/lldb/scripts/Python/build-swig-Python.sh b/lldb/scripts/Python/build-swig-Python.sh index 9dc4b991c4a..69c40a76b12 100755 --- a/lldb/scripts/Python/build-swig-Python.sh +++ b/lldb/scripts/Python/build-swig-Python.sh @@ -2,8 +2,24 @@ # build-swig-Python.sh +# 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 was 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 +PYTHON_INSTALL_DIR=$4 +debug_flag=$5 + +swig_output_file=${SRC_ROOT}/source/LLDBWrapPython.cpp +swig_input_file=${SRC_ROOT}/scripts/lldb.swig -debug_flag=$1 if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ] then @@ -13,33 +29,33 @@ else 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" +HEADER_FILES="${SRC_ROOT}/include/lldb/lldb-types.h"\ +" ${SRC_ROOT}/include/lldb/API/SBAddress.h"\ +" ${SRC_ROOT}/include/lldb/API/SBBlock.h"\ +" ${SRC_ROOT}/include/lldb/API/SBBreakpoint.h"\ +" ${SRC_ROOT}/include/lldb/API/SBBreakpointLocation.h"\ +" ${SRC_ROOT}/include/lldb/API/SBBroadcaster.h"\ +" ${SRC_ROOT}/include/lldb/API/SBCommandContext.h"\ +" ${SRC_ROOT}/include/lldb/API/SBCommandInterpreter.h"\ +" ${SRC_ROOT}/include/lldb/API/SBCommandReturnObject.h"\ +" ${SRC_ROOT}/include/lldb/API/SBCompileUnit.h"\ +" ${SRC_ROOT}/include/lldb/API/SBDebugger.h"\ +" ${SRC_ROOT}/include/lldb/API/SBError.h"\ +" ${SRC_ROOT}/include/lldb/API/SBEvent.h"\ +" ${SRC_ROOT}/include/lldb/API/SBFrame.h"\ +" ${SRC_ROOT}/include/lldb/API/SBFunction.h"\ +" ${SRC_ROOT}/include/lldb/API/SBLineEntry.h"\ +" ${SRC_ROOT}/include/lldb/API/SBListener.h"\ +" ${SRC_ROOT}/include/lldb/API/SBModule.h"\ +" ${SRC_ROOT}/include/lldb/API/SBProcess.h"\ +" ${SRC_ROOT}/include/lldb/API/SBSourceManager.h"\ +" ${SRC_ROOT}/include/lldb/API/SBStringList.h"\ +" ${SRC_ROOT}/include/lldb/API/SBSymbol.h"\ +" ${SRC_ROOT}/include/lldb/API/SBSymbolContext.h"\ +" ${SRC_ROOT}/include/lldb/API/SBTarget.h"\ +" ${SRC_ROOT}/include/lldb/API/SBThread.h"\ +" ${SRC_ROOT}/include/lldb/API/SBType.h"\ +" ${SRC_ROOT}/include/lldb/API/SBValue.h" if [ $Debug == 1 ] @@ -50,7 +66,6 @@ fi NeedToUpdate=0 -swig_output_file=${SCRIPT_INPUT_FILE_1} if [ ! -f $swig_output_file ] then @@ -77,7 +92,16 @@ then done fi -framework_python_dir="${CONFIGURATION_BUILD_DIR}/LLDB.framework/Versions/A/Resources/Python" +os_name=`uname -s` +python_version=`/usr/bin/python --version 2>&1 | sed -e 's,Python ,,' -e 's,[.][0-9],,2' -e 's,[a-z][a-z][0-9],,'` + +if [ "$os_name" == "Darwin" ] +then + framework_python_dir="${TARGET_DIR}/LLDB.framework/Resources/Python" +else + framework_python_dir="${PYTHON_INSTALL_DIR}/python${python_version}" +fi + if [ ! -L "${framework_python_dir}/_lldb.so" ] then @@ -101,27 +125,5 @@ 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 +swig -c++ -shadow -python -I"${SRC_ROOT}/include" -I./. -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}" -# -# 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 diff --git a/lldb/scripts/Python/finish-swig-Python-LLDB.sh b/lldb/scripts/Python/finish-swig-Python-LLDB.sh index 293a8b18c66..762496adad5 100755 --- a/lldb/scripts/Python/finish-swig-Python-LLDB.sh +++ b/lldb/scripts/Python/finish-swig-Python-LLDB.sh @@ -3,43 +3,167 @@ # finish-swig-Python.sh # # For the Python script interpreter (external to liblldb) to be able to import -# and use the lldb module, there must be a "_lldb.so" in the framework -# resources directory. Here we make a symlink called "_lldb.so" that just -# points to the executable in the LLDB.framework and copy over the needed -# .py files. +# and use the lldb module, there must be two files, lldb.py and _lldb.so, that +# it can find. lldb.py is generated by SWIG at the same time it generates the +# C++ file. _lldb.so is actually a symlink file that points to the +# LLDB shared library/framework. +# +# The Python script interpreter needs to be able to automatically find +# these two files. On Darwin systems it searches in the LLDB.framework, as +# well as in all the normal Python search paths. On non-Darwin systems +# these files will need to be put someplace where Python will find them. +# +# This shell script creates the _lldb.so symlink in the appropriate place, +# and copies the lldb.py (and embedded_interpreter.py) file to the correct +# directory. +# + +# 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 was generated from running SWIG. +# PYTHON_INSTALL_DIR is where non-Darwin systems want to put the .py and .so +# files so that Python can find them automatically. +# debug_flag (optional) determines whether or not this script outputs +# additional information when running. + +SRC_ROOT=$1 +TARGET_DIR=$2 +CONFIG_BUILD_DIR=$3 +PYTHON_INSTALL_DIR=$4 +debug_flag=$5 -if [ ! -d "${TARGET_BUILD_DIR}/LLDB.framework" ] +if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ] then - echo "Error: Unable to find LLDB.framework" >&2 - exit 1 + Debug=1 +else + Debug=0 +fi + +OS_NAME=`uname -s` +PYTHON_VERSION=`/usr/bin/python --version 2>&1 | sed -e 's,Python ,,' -e 's,[.][0-9],,2' -e 's,[a-z][a-z][0-9],,'` + + +if [ $Debug == 1 ] +then + echo "The current OS is $OS_NAME" + echo "The Python version is $PYTHON_VERSION" +fi + +# +# Determine where to put the files. + +if [ ${OS_NAME} == "Darwin" ] +then + # We are on a Darwin system, so all the lldb Python files can go + # into the LLDB.framework/Resources/Python subdirectory. + + if [ ! -d "${TARGET_DIR}/LLDB.framework" ] + then + echo "Error: Unable to find LLDB.framework" >&2 + exit 1 + else + if [ $Debug == 1 ] + then + echo "Found ${TARGET_DIR}/LLDB.framework." + fi + fi + + # Make the Python directory in the framework if it doesn't already exist + + framework_python_dir="${TARGET_DIR}/LLDB.framework/Resources/Python" +else + # We are on a non-Darwin system, so use the PYTHON_INSTALL_DIR argument, + # and append the python version directory to the end of it. Depending on + # the system other stuff may need to be put here as well. + + framework_python_dir="${PYTHON_INSTALL_DIR}/python${PYTHON_VERSION}" +fi + +# +# Look for the directory in which to put the Python files; if it does not +# already exist, attempt to make it. +# + +if [ $Debug == 1 ] +then + echo "Python files will be put in ${framework_python_dir}" +fi + +if [ ! -d "${framework_python_dir}" ] +then + if [ $Debug == 1 ] + then + echo "Making directory ${framework_python_dir}" + fi + mkdir -p "${framework_python_dir}" +else + if [ $Debug == 1 ] + then + echo "${framework_python_dir} already exists." + fi fi -# Make the Python directory down in the framework if it doesn't already exist -framework_python_dir="${TARGET_BUILD_DIR}/LLDB.framework/Versions/A/Resources/Python" if [ ! -d "${framework_python_dir}" ] then - mkdir -p "${framework_python_dir}" + echo "Error: Unable to find or create ${framework_python_dir}" >&2 + exit 1 fi -# Make the symlink that the script bridge for Python will need in the Python -# framework directory +# Make the symlink that the script bridge for Python will need in the +# Python framework directory + if [ ! -L "${framework_python_dir}/_lldb.so" ] then - cd "${framework_python_dir}" + if [ $Debug == 1 ] + then + echo "Creating symlink for _lldb.so" + fi + if [ ${OS_NAME} == "Darwin" ] + then + cd "${framework_python_dir}" ln -s "../../LLDB" _lldb.so + else + cd "${TARGET_DIR}" + ln -s "./LLDB" _lldb.so + fi +else + if [ $Debug == 1 ] + then + echo "${framework_python_dir}/_lldb.so already exists." + fi fi # Copy the python module (lldb.py) that was generated by SWIG # over to the framework Python directory -if [ -f "${CONFIGURATION_BUILD_DIR}/lldb.py" ] +if [ -f "${CONFIG_BUILD_DIR}/lldb.py" ] then - cp "${CONFIGURATION_BUILD_DIR}/lldb.py" "${framework_python_dir}" + if [ $Debug == 1 ] + then + echo "Copying lldb.py to ${framework_python_dir}" + fi + cp "${CONFIG_BUILD_DIR}/lldb.py" "${framework_python_dir}" +else + if [ $Debug == 1 ] + then + echo "Unable to find ${CONFIG_BUILD_DIR}/lldb.py" + fi fi # Copy the embedded interpreter script over to the framework Python directory -if [ -f "${SRCROOT}/source/Interpreter/embedded_interpreter.py" ] +if [ -f "${SRC_ROOT}/source/Interpreter/embedded_interpreter.py" ] then - cp "${SRCROOT}/source/Interpreter/embedded_interpreter.py" "${framework_python_dir}" + if [ $Debug == 1 ] + then + echo "Copying embedded_interpreter.py to ${framework_python_dir}" + fi + cp "${SRC_ROOT}/source/Interpreter/embedded_interpreter.py" "${framework_python_dir}" +else + if [ $Debug == 1 ] + then + echo "Unable to find ${SRC_ROOT}/source/Interpreter/embedded_interpreter.py" + fi fi exit 0 + diff --git a/lldb/scripts/build-swig-wrapper-classes.sh b/lldb/scripts/build-swig-wrapper-classes.sh index 3d1cf74344f..5582ba0a662 100755 --- a/lldb/scripts/build-swig-wrapper-classes.sh +++ b/lldb/scripts/build-swig-wrapper-classes.sh @@ -10,7 +10,27 @@ # the scripting language. In some cases the file generated by SWIG may # need some tweaking before it is completely ready to use. -debug_flag=$1 +# Below are the arguments/parameters that this script takes (and passes along +# to all the language-specific build scripts that it calls): +# +# 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 was generated from running SWIG. +# PREFIX is where non-Darwin systems want to put the .py and .so +# files so that Python can find them automatically. +# 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 +debug_flag=$5 + +# +# Check to see if we are in debug-mode or not. +# if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ] then @@ -23,7 +43,7 @@ fi # Verify that 'lldb.swig' exists. # -if [ ! -f ${SRCROOT}/scripts/lldb.swig ] +if [ ! -f ${SRC_ROOT}/scripts/lldb.swig ] then echo Error: unable to find file 'lldb.swig' >&2 exit 1 @@ -42,7 +62,7 @@ fi # change. languages="Python" -cwd=${SRCROOT}/scripts +cwd=${SRC_ROOT}/scripts for curlang in $languages do @@ -78,7 +98,7 @@ do echo "Executing $curlang build script..." fi - ./build-swig-${curlang}.sh + ./build-swig-${curlang}.sh $SRC_ROOT $TARGET_DIR $CONFIG_BUILD_DIR "${PREFIX}" "${debug_flag}" fi fi done diff --git a/lldb/scripts/finish-swig-wrapper-classes.sh b/lldb/scripts/finish-swig-wrapper-classes.sh index 5d9713d06a2..a9065b202c5 100755 --- a/lldb/scripts/finish-swig-wrapper-classes.sh +++ b/lldb/scripts/finish-swig-wrapper-classes.sh @@ -13,7 +13,20 @@ # language stuff fully functional. Any such post-processing is handled through # the shell scripts called here. -debug_flag=$1 +# 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 +debug_flag=$5 if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ] then @@ -31,7 +44,7 @@ fi # change. languages="Python" -cwd=${SRCROOT}/scripts +cwd=${SRC_ROOT}/scripts for curlang in $languages do @@ -53,17 +66,18 @@ do cd $cwd/$curlang - filename="./finish-swig-${curlang}-${TARGET_NAME}.sh" + filename="./finish-swig-${curlang}-LLDB.sh" if [ -f $filename ] then if [ $Debug == 1 ] then - echo "Found $curlang post-processing script for ${TARGET_NAME}" + echo "Found $curlang post-processing script for LLDB" echo "Executing $curlang post-processing script..." fi - ./finish-swig-${curlang}-${TARGET_NAME}.sh + + ./finish-swig-${curlang}-LLDB.sh $SRC_ROOT $TARGET_DIR $CONFIG_BUILD_DIR "${PREFIX}" "${debug_flag}" fi fi done |

