[Lldb-commits] [lldb] r163912 - in /lldb/trunk: scripts/Python/build-swig-Python.sh scripts/Python/finish-swig-Python-LLDB.sh scripts/build-swig-wrapper-classes.sh source/Interpreter/Makefile

Filipe Cabecinhas me at filcab.net
Fri Sep 14 10:09:15 PDT 2012


Author: filcab
Date: Fri Sep 14 12:09:15 2012
New Revision: 163912

URL: http://llvm.org/viewvc/llvm-project?rev=163912&view=rev
Log:
Fixed some problems with SWIG bindings.

This may (but shouldn't) break Linux (but I tested and it still worked on FreeBSD).

The same shell scripts are now used on Xcode and Makefiles, for generating
the SWIG bindings.
Some compatibility fixes were applied, too (python path, bash-isms, etc).

Modified:
    lldb/trunk/scripts/Python/build-swig-Python.sh
    lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh
    lldb/trunk/scripts/build-swig-wrapper-classes.sh
    lldb/trunk/source/Interpreter/Makefile

Modified: lldb/trunk/scripts/Python/build-swig-Python.sh
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/build-swig-Python.sh?rev=163912&r1=163911&r2=163912&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/build-swig-Python.sh (original)
+++ lldb/trunk/scripts/Python/build-swig-Python.sh Fri Sep 14 12:09:15 2012
@@ -18,13 +18,19 @@
 debug_flag=$5 
 SWIG=$6
 
-swig_output_file=${SRC_ROOT}/source/LLDBWrapPython.cpp
+os_name=`uname -s`
+if [ "$os_name" == "Darwin" ]
+then
+  swig_output_file=${SRC_ROOT}/source/LLDBWrapPython.cpp
+else
+  swig_output_file=${TARGET_DIR}/LLDBWrapPython.cpp
+fi
 swig_input_file=${SRC_ROOT}/scripts/lldb.swig
 swig_python_extensions=${SRC_ROOT}/scripts/Python/python-extensions.swig
 swig_python_wrapper=${SRC_ROOT}/scripts/Python/python-wrapper.swig
 swig_python_typemaps=${SRC_ROOT}/scripts/Python/python-typemaps.swig
 
-if [ $LLDB_DISABLE_PYTHON = "1" ] ; then
+if [ "$LLDB_DISABLE_PYTHON" = "1" ] ; then
     # We don't want Python for this build, but touch the output file so we don't have to
     # conditionalize the build on this as well.
     # Note, at present iOS doesn't have Python, so if you're building for iOS be sure to
@@ -252,8 +258,7 @@
     fi
 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],,'`
+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" ]
 then

Modified: lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh?rev=163912&r1=163911&r2=163912&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh (original)
+++ lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh Fri Sep 14 12:09:15 2012
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/sh
 
 # finish-swig-Python.sh
 #
@@ -37,7 +37,7 @@
 # Note, at present iOS doesn't have Python, so if you're building for iOS be sure to
 # set LLDB_DISABLE_PYTHON to 1.
 
-if [ ! $LLDB_DISABLE_PYTHON = "1" ] ; then
+if [ ! "$LLDB_DISABLE_PYTHON" = "1" ] ; then
 
 if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ]
 then
@@ -47,7 +47,7 @@
 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],,'`
+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 [ $Debug == 1 ]
@@ -134,9 +134,6 @@
     then
         cd "${framework_python_dir}"
         ln -s "../../../LLDB" _lldb.so
-    else
-        cd "${TARGET_DIR}"
-        ln -s "../LLDB" _lldb.so
     fi
 else
     if [ $Debug == 1 ]
@@ -146,7 +143,7 @@
 fi
 
 
-function create_python_package {
+create_python_package () {
     package_dir="${framework_python_dir}$1"
     package_files="$2"
     package_name=`echo $1 | tr '/' '.'`

Modified: lldb/trunk/scripts/build-swig-wrapper-classes.sh
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/build-swig-wrapper-classes.sh?rev=163912&r1=163911&r2=163912&view=diff
==============================================================================
--- lldb/trunk/scripts/build-swig-wrapper-classes.sh (original)
+++ lldb/trunk/scripts/build-swig-wrapper-classes.sh Fri Sep 14 12:09:15 2012
@@ -119,7 +119,7 @@
                 echo "Executing $curlang build script..."
             fi
 
-            ./build-swig-${curlang}.sh  $SRC_ROOT $TARGET_DIR $CONFIG_BUILD_DIR "${PREFIX}" "${debug_flag}" "${SWIG}"
+            ./build-swig-${curlang}.sh  "$SRC_ROOT" "$TARGET_DIR" "$CONFIG_BUILD_DIR" "${PREFIX}" "${debug_flag}" "${SWIG}"
         fi
     fi
 done

Modified: lldb/trunk/source/Interpreter/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Makefile?rev=163912&r1=163911&r2=163912&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Makefile (original)
+++ lldb/trunk/source/Interpreter/Makefile Fri Sep 14 12:09:15 2012
@@ -16,6 +16,10 @@
 include $(LLDB_LEVEL)/Makefile
 -include $(PROJ_OBJ_DIR)/LLDBWrapPython.cpp.d
 
+# edit-swig-python-wrapper-file.py needs $(SRCROOT)
+export SRCROOT := $(PROJ_SRC_DIR)/$(LLDB_LEVEL)
+TARGET_DIR := $(PROJ_OBJ_DIR)
+
 PYTHON_DIR := $(LibDir)/python/lldb
 ifeq ($(HOST_OS),Darwin)
 PYTHON_DEST_DIR := $(DESTDIR)/$(call realpath,/Library/Python/$(shell python -c 'import sys; print sys.version[:3]')/site-packages)/lldb
@@ -126,26 +130,29 @@
                       else $(RM) -f "$(PROJ_OBJ_DIR)/$*.cpp.d.tmp"; exit 1; fi
 
 LLDBWrapPython.cpp: $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/Python/modify-python-lldb.py \
-                    $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/Python/edit-swig-python-wrapper-file.py
+                    $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/Python/edit-swig-python-wrapper-file.py \
+                    $(wildcard $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/Python/interface/*.i)
 	$(Echo) Generating LLDBWrapPython.cpp
 	$(Verb) $(MKDIR) $(PYTHON_DIR)
-	$(Verb) if swig -c++ -shadow -python $(LLDB_SWIG_INCLUDE_DIRS) \
-          -D__STDC_LIMIT_MACROS -outdir "$(PYTHON_DIR)"   \
-          $(SWIG_DEPEND_OPTIONS) \
-          -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" ; \
-          $(CPP_DEPEND_MOVEFILE)
-	$(Verb) python "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/Python/modify-python-lldb.py" \
-		  "$(PYTHON_DIR)"
-	$(Verb) python "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/Python/edit-swig-python-wrapper-file.py" \
-		  "$(PROJ_OBJ_DIR)"
-	$(Verb) if test -f "$(PROJ_OBJ_DIR)/LLDBWrapPython.cpp.edited"; then \
-		  $(MV) "$(PROJ_OBJ_DIR)/LLDBWrapPython.cpp.edited" \
-				"$(PROJ_OBJ_DIR)/LLDBWrapPython.cpp"; fi
-	$(Verb) $(MV) "$(PYTHON_DIR)/lldb.py" "$(PYTHON_DIR)/__init__.py"
-	$(Verb) $(CP) "$(PROJ_SRC_DIR)/embedded_interpreter.py" "$(PYTHON_DIR)"
-	$(Verb) $(RM) -f $(PYTHON_DIR)/_lldb.so
-	$(Verb) $(AliasTool) $(LIBLLDB) $(PYTHON_DIR)/_lldb.so
-	$(LLDB_COPY_PACKAGE)
+	$(Verb) "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/build-swig-wrapper-classes.sh" "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)" "$(TARGET_DIR)" "$(PYTHON_DIR)" "$(PYTHON_DIR)"
+	$(Verb) "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/finish-swig-wrapper-classes.sh" "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)" "$(TARGET_DIR)" "$(PYTHON_DIR)" "$(PYTHON_DIR)"
+#	$(Verb) if swig -c++ -shadow -python $(LLDB_SWIG_INCLUDE_DIRS) \
+#          -D__STDC_LIMIT_MACROS -outdir "$(PYTHON_DIR)"   \
+#          $(SWIG_DEPEND_OPTIONS) \
+#          -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" ; \
+#          $(CPP_DEPEND_MOVEFILE)
+#	$(Verb) python "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/Python/modify-python-lldb.py" \
+#		  "$(PYTHON_DIR)"
+#	$(Verb) python "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/Python/edit-swig-python-wrapper-file.py" \
+#		  "$(PROJ_OBJ_DIR)"
+#	$(Verb) if test -f "$(PROJ_OBJ_DIR)/LLDBWrapPython.cpp.edited"; then \
+#		  $(MV) "$(PROJ_OBJ_DIR)/LLDBWrapPython.cpp.edited" \
+#				"$(PROJ_OBJ_DIR)/LLDBWrapPython.cpp"; fi
+#	$(Verb) $(MV) "$(PYTHON_DIR)/lldb.py" "$(PYTHON_DIR)/__init__.py"
+#	$(Verb) $(CP) "$(PROJ_SRC_DIR)/embedded_interpreter.py" "$(PYTHON_DIR)"
+#	$(Verb) $(RM) -f $(PYTHON_DIR)/_lldb.so
+#	$(Verb) $(AliasTool) $(LIBLLDB) $(PYTHON_DIR)/_lldb.so
+#	$(LLDB_COPY_PACKAGE)
 
 else
 





More information about the lldb-commits mailing list