diff options
Diffstat (limited to 'lldb/scripts/Python')
-rwxr-xr-x | lldb/scripts/Python/build-swig-Python.sh | 61 | ||||
-rwxr-xr-x | lldb/scripts/Python/finish-swig-Python-LLDB.sh | 44 | ||||
-rw-r--r-- | lldb/scripts/Python/modify-python-lldb.py | 2 |
3 files changed, 85 insertions, 22 deletions
diff --git a/lldb/scripts/Python/build-swig-Python.sh b/lldb/scripts/Python/build-swig-Python.sh index 59394f9cc0e..efbc7485a6c 100755 --- a/lldb/scripts/Python/build-swig-Python.sh +++ b/lldb/scripts/Python/build-swig-Python.sh @@ -4,22 +4,39 @@ # 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 +# 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 +# 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 +debug_flag=$5 SWIG=$6 +makefile_flag=$7 +dependency_flag=$8 -os_name=`uname -s` -if [ "$os_name" = "Darwin" ] +if [ -n "$makefile_flag" -a "$makefile_flag" = "-m" ] +then + MakefileCalled=1 + if [ -n "$dependency_flag" -a "$dependency_flag" = "-M" ] + then + GenerateDependencies=1 + swig_depend_file="${TARGET_DIR}/LLDBWrapPython.cpp.d" + SWIG_DEPEND_OPTIONS="-MMD -MF \"${swig_depend_file}.tmp\"" + else + GenerateDependencies=0 + fi +else + MakefileCalled=0 + GenerateDependencies=0 +fi + +if [ $MakefileCalled -eq 0 ] then swig_output_file=${SRC_ROOT}/source/LLDBWrapPython.cpp else @@ -263,20 +280,26 @@ fi python_version=`/usr/bin/env 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" ] +if [ $MakefileCalled -eq 0 ] then - framework_python_dir="${TARGET_DIR}/LLDB.framework/Resources/Python" + framework_python_dir="${TARGET_DIR}/LLDB.framework/Resources/Python/lldb" else - framework_python_dir="${PYTHON_INSTALL_DIR}/python${python_version}" + if [ -n "${PYTHON_INSTALL_DIR}" ] + then + framework_python_dir=`/usr/bin/env python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(True, False, \"${PYTHON_INSTALL_DIR}\");"`/lldb + else + framework_python_dir=`/usr/bin/env python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(True, False);"`/lldb + fi fi +[ -n "${CONFIG_BUILD_DIR}" ] || CONFIG_BUILD_DIR=${framework_python_dir} if [ ! -L "${framework_python_dir}/_lldb.so" ] then NeedToUpdate=1 fi -if [ ! -f "${framework_python_dir}/lldb.py" ] +if [ ! -f "${framework_python_dir}/__init__.py" ] then NeedToUpdate=1 fi @@ -297,7 +320,18 @@ fi # Build the SWIG C++ wrapper file for Python. -$SWIG -c++ -shadow -python -threads -I"/usr/include" -I"${SRC_ROOT}/include" -I./. -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}" +if [ $GenerateDependencies -eq 1 ] +then + if $SWIG -c++ -shadow -python -threads -I"${SRC_ROOT}/include" -I./. -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -MMD -MF "${swig_depend_file}.tmp" -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}" + then + mv -f "${swig_depend_file}.tmp" "${swig_depend_file}" + else + rm -f "${swig_depend_file}.tmp" + exit 1 + fi +else + $SWIG -c++ -shadow -python -threads -I"${SRC_ROOT}/include" -I./. -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}" || exit $? +fi # Implement the iterator protocol and/or eq/ne operators for some lldb objects. # Append global variable to lldb Python module. @@ -312,7 +346,12 @@ fi if [ -f "${current_dir}/edit-swig-python-wrapper-file.py" ] then - python ${current_dir}/edit-swig-python-wrapper-file.py + if [ $MakefileCalled -eq 1 ] + then + python ${current_dir}/edit-swig-python-wrapper-file.py "${TARGET_DIR}" + else + python ${current_dir}/edit-swig-python-wrapper-file.py + fi if [ -f "${swig_output_file}.edited" ] then mv "${swig_output_file}.edited" ${swig_output_file} diff --git a/lldb/scripts/Python/finish-swig-Python-LLDB.sh b/lldb/scripts/Python/finish-swig-Python-LLDB.sh index 12ffb412567..8c1fb4e5107 100755 --- a/lldb/scripts/Python/finish-swig-Python-LLDB.sh +++ b/lldb/scripts/Python/finish-swig-Python-LLDB.sh @@ -5,10 +5,10 @@ # For the Python script interpreter (external to liblldb) to be able to import # 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 +# 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 +# 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. @@ -20,11 +20,11 @@ # 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 +# 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 +# debug_flag (optional) determines whether or not this script outputs # additional information when running. SRC_ROOT=$1 @@ -32,6 +32,7 @@ TARGET_DIR=$2 CONFIG_BUILD_DIR=$3 PYTHON_INSTALL_DIR=$4 debug_flag=$5 +makefile_flag=$6 # If we don't want Python, then just do nothing here. # Note, at present iOS doesn't have Python, so if you're building for iOS be sure to @@ -46,6 +47,13 @@ else Debug=0 fi +if [ -n "$makefile_flag" -a "$makefile_flag" = "-m" ] +then + MakefileCalled=1 +else + MakefileCalled=0 +fi + OS_NAME=`uname -s` PYTHON_VERSION=`/usr/bin/env python --version 2>&1 | sed -e 's,Python ,,' -e 's,[.][0-9],,2' -e 's,[a-z][a-z][0-9],,'` @@ -56,12 +64,19 @@ then echo "The Python version is $PYTHON_VERSION" fi +if [ ${OS_NAME} = "Darwin" ] +then + SOEXT=".dylib" +else + SOEXT=".so" +fi + # # Determine where to put the files. -if [ ${OS_NAME} = "Darwin" ] +if [ $MakefileCalled -eq 0 ] then - # We are on a Darwin system, so all the lldb Python files can go + # We are being built by Xcode, so all the lldb Python files can go # into the LLDB.framework/Resources/Python subdirectory. if [ ! -d "${TARGET_DIR}/LLDB.framework" ] @@ -79,13 +94,20 @@ then framework_python_dir="${TARGET_DIR}/LLDB.framework/Resources/Python/lldb" else - # We are on a non-Darwin system, so use the PYTHON_INSTALL_DIR argument, + # We are being built by LLVM, 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}/lldb" + if [ -n "${PYTHON_INSTALL_DIR}" ] + then + framework_python_dir=`/usr/bin/env python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(True, False, \"${PYTHON_INSTALL_DIR}\");"`/lldb + else + framework_python_dir=`/usr/bin/env python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(True, False);"`/lldb + fi fi +[ -n "${CONFIG_BUILD_DIR}" ] || CONFIG_BUILD_DIR=${framework_python_dir} + # # Look for the directory in which to put the Python files; if it does not # already exist, attempt to make it. @@ -130,10 +152,12 @@ then then echo "Creating symlink for _lldb.so" fi - if [ ${OS_NAME} = "Darwin" ] + cd "${framework_python_dir}" + if [ $MakefileCalled -eq 0 ] then - cd "${framework_python_dir}" ln -s "../../../LLDB" _lldb.so + else + ln -s "../../../liblldb${SOEXT}" _lldb.so fi else if [ $Debug -eq 1 ] diff --git a/lldb/scripts/Python/modify-python-lldb.py b/lldb/scripts/Python/modify-python-lldb.py index 75f97e78ba9..4345ea26bba 100644 --- a/lldb/scripts/Python/modify-python-lldb.py +++ b/lldb/scripts/Python/modify-python-lldb.py @@ -386,7 +386,7 @@ for line in content.splitlines(): new_content.add_line(section_iter % d[cls+'-section']) new_content.add_line(compile_unit_iter % d[cls+'-compile-unit']) new_content.add_line(d[cls+'-symbol-in-section']) - + # This special purpose iterator is for SBValue only!!! if cls == "SBValue": new_content.add_line(linked_list_iter_def) |