diff options
author | Caroline Tice <ctice@apple.com> | 2010-06-16 19:26:52 +0000 |
---|---|---|
committer | Caroline Tice <ctice@apple.com> | 2010-06-16 19:26:52 +0000 |
commit | d6ac38485b35bb90fe85c770565ac95451ed44fd (patch) | |
tree | 6c083f8afdef815748aba3f0ab716d136e4f3170 /lldb/scripts/Python/finish-swig-Python-LLDB.sh | |
parent | 23a8a06554c1b03932010e5a233fa11656f3363a (diff) | |
download | bcm5719-llvm-d6ac38485b35bb90fe85c770565ac95451ed44fd.tar.gz bcm5719-llvm-d6ac38485b35bb90fe85c770565ac95451ed44fd.zip |
Parameterize the shell scripts for creating and copying the python and
other script files around, so they can be run from outside Xcode. Also,
check the current OS, and only try to use the framework structure stuff on
Darwin systems.
llvm-svn: 106132
Diffstat (limited to 'lldb/scripts/Python/finish-swig-Python-LLDB.sh')
-rwxr-xr-x | lldb/scripts/Python/finish-swig-Python-LLDB.sh | 158 |
1 files changed, 141 insertions, 17 deletions
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 + |