[Lldb-commits] [lldb] r117612 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj scripts/Python/build-swig-Python.sh scripts/Python/edit-swig-python-wrapper-file.py source/API/SBBreakpointLocation.cpp source/Interpreter/ScriptInterpreterPython.cpp

Caroline Tice ctice at apple.com
Thu Oct 28 14:51:20 PDT 2010


Author: ctice
Date: Thu Oct 28 16:51:20 2010
New Revision: 117612

URL: http://llvm.org/viewvc/llvm-project?rev=117612&view=rev
Log:
Remove references to particular Python version (use the system default
version);  change include statements to use Python.h in the Python framework
on Mac OS X systems; leave it using regular Python.h on other systems.

Note:  I think this *ought* to work properly on Linux systems, but I don't have
a system to test it on...


Modified:
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/scripts/Python/build-swig-Python.sh
    lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py
    lldb/trunk/source/API/SBBreakpointLocation.cpp
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=117612&r1=117611&r2=117612&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Oct 28 16:51:20 2010
@@ -50,7 +50,7 @@
 		2668022F115FD19D008E1FE4 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; };
 		26680230115FD19E008E1FE4 /* DebugSymbols.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 265ABF6210F42EE900531910 /* DebugSymbols.framework */; };
 		26680231115FD1A0008E1FE4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 260C876910F538E700BB2B04 /* Foundation.framework */; };
-		26680232115FD1A4008E1FE4 /* libpython2.6.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32410F3DF23009D5894 /* libpython2.6.dylib */; };
+		26680232115FD1A4008E1FE4 /* libpython.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32410F3DF23009D5894 /* libpython.dylib */; };
 		26680233115FD1A7008E1FE4 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; };
 		26680324116005D9008E1FE4 /* SBThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9831091125FC5800A56CB0 /* SBThread.cpp */; };
 		26680326116005DB008E1FE4 /* SBTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9831071125FC5800A56CB0 /* SBTarget.cpp */; };
@@ -319,7 +319,7 @@
 		26DE20651161904E00A093E2 /* SBSymbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20641161904E00A093E2 /* SBSymbol.cpp */; };
 		26F5C27710F3D9E4009D5894 /* Driver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27310F3D9E4009D5894 /* Driver.cpp */; };
 		26F5C27810F3D9E4009D5894 /* IOChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27510F3D9E4009D5894 /* IOChannel.cpp */; };
-		26F5C32510F3DF23009D5894 /* libpython2.6.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32410F3DF23009D5894 /* libpython2.6.dylib */; };
+		26F5C32510F3DF23009D5894 /* libpython.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32410F3DF23009D5894 /* libpython.dylib */; };
 		26F5C32C10F3DFDD009D5894 /* libedit.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32A10F3DFDD009D5894 /* libedit.dylib */; };
 		26F5C32D10F3DFDD009D5894 /* libtermcap.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */; };
 		26F5C37510F3F61B009D5894 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; };
@@ -938,7 +938,7 @@
 		26F5C27410F3D9E4009D5894 /* Driver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Driver.h; path = tools/driver/Driver.h; sourceTree = "<group>"; };
 		26F5C27510F3D9E4009D5894 /* IOChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IOChannel.cpp; path = tools/driver/IOChannel.cpp; sourceTree = "<group>"; };
 		26F5C27610F3D9E4009D5894 /* IOChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IOChannel.h; path = tools/driver/IOChannel.h; sourceTree = "<group>"; };
-		26F5C32410F3DF23009D5894 /* libpython2.6.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpython2.6.dylib; path = /usr/lib/libpython2.6.dylib; sourceTree = "<absolute>"; };
+		26F5C32410F3DF23009D5894 /* libpython.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpython.dylib; path = /usr/lib/libpython.dylib; sourceTree = "<absolute>"; };
 		26F5C32A10F3DFDD009D5894 /* libedit.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libedit.dylib; path = /usr/lib/libedit.dylib; sourceTree = "<absolute>"; };
 		26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libtermcap.dylib; path = /usr/lib/libtermcap.dylib; sourceTree = "<absolute>"; };
 		26F5C37410F3F61B009D5894 /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = "<absolute>"; };
@@ -1154,7 +1154,7 @@
 				2668022F115FD19D008E1FE4 /* CoreFoundation.framework in Frameworks */,
 				26680230115FD19E008E1FE4 /* DebugSymbols.framework in Frameworks */,
 				26680231115FD1A0008E1FE4 /* Foundation.framework in Frameworks */,
-				26680232115FD1A4008E1FE4 /* libpython2.6.dylib in Frameworks */,
+				26680232115FD1A4008E1FE4 /* libpython.dylib in Frameworks */,
 				26680233115FD1A7008E1FE4 /* libobjc.dylib in Frameworks */,
 				4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */,
 			);
@@ -1164,7 +1164,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				26F5C32510F3DF23009D5894 /* libpython2.6.dylib in Frameworks */,
+				26F5C32510F3DF23009D5894 /* libpython.dylib in Frameworks */,
 				26F5C32C10F3DFDD009D5894 /* libedit.dylib in Frameworks */,
 				26F5C32D10F3DFDD009D5894 /* libtermcap.dylib in Frameworks */,
 				26F5C37510F3F61B009D5894 /* libobjc.dylib in Frameworks */,
@@ -2176,7 +2176,7 @@
 				260C876910F538E700BB2B04 /* Foundation.framework */,
 				26F5C32A10F3DFDD009D5894 /* libedit.dylib */,
 				26F5C37410F3F61B009D5894 /* libobjc.dylib */,
-				26F5C32410F3DF23009D5894 /* libpython2.6.dylib */,
+				26F5C32410F3DF23009D5894 /* libpython.dylib */,
 				26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */,
 				4C74CB6212288704006A8171 /* Carbon.framework */,
 			);
@@ -3076,7 +3076,7 @@
 				GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
 				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_VERSION = 4.2;
-				HEADER_SEARCH_PATHS = /usr/include/python2.6;
+				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "resources/LLDB-Info.plist";
 				INSTALL_PATH = /Developer/Library/PrivateFrameworks;
 				LD_DYLIB_INSTALL_NAME = "@rpath/LLDB.framework/Versions/A/LLDB";
@@ -3129,7 +3129,7 @@
 				GCC_ENABLE_OBJC_GC = supported;
 				GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
 				GCC_VERSION = 4.2;
-				HEADER_SEARCH_PATHS = /usr/include/python2.6;
+				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "resources/LLDB-Info.plist";
 				INSTALL_PATH = /Developer/Library/PrivateFrameworks;
 				LD_DYLIB_INSTALL_NAME = "@rpath/LLDB.framework/Versions/A/LLDB";
@@ -3201,7 +3201,7 @@
 				GCC_MODEL_TUNING = G5;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_VERSION = 4.2;
-				HEADER_SEARCH_PATHS = /usr/include/python2.6;
+				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "lldb-Info.plist";
 				INSTALL_PATH = /Developer/usr/bin;
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
@@ -3240,7 +3240,7 @@
 				GCC_ENABLE_OBJC_GC = supported;
 				GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
 				GCC_VERSION = 4.2;
-				HEADER_SEARCH_PATHS = /usr/include/python2.6;
+				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "resources/LLDB-Info.plist";
 				INSTALL_PATH = /Developer/Library/PrivateFrameworks;
 				LD_DYLIB_INSTALL_NAME = "@rpath/LLDB.framework/Versions/A/LLDB";
@@ -3291,7 +3291,7 @@
 				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_VERSION = 4.2;
-				HEADER_SEARCH_PATHS = /usr/include/python2.6;
+				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "lldb-Info.plist";
 				INSTALL_PATH = /Developer/usr/bin;
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
@@ -3331,7 +3331,7 @@
 				GCC_MODEL_TUNING = G5;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_VERSION = 4.2;
-				HEADER_SEARCH_PATHS = /usr/include/python2.6;
+				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "lldb-Info.plist";
 				INSTALL_PATH = /Developer/usr/bin;
 				LIBRARY_SEARCH_PATHS = "$(inherited)";

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=117612&r1=117611&r2=117612&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/build-swig-Python.sh (original)
+++ lldb/trunk/scripts/Python/build-swig-Python.sh Thu Oct 28 16:51:20 2010
@@ -179,3 +179,14 @@
 then
     python ${current_dir}/append-debugger-id.py ${CONFIG_BUILD_DIR}
 fi
+
+# Fix the "#include" statement in the swig output file
+
+if [ -f "${current_dir}/edit-swig-python-wrapper-file.py" ]
+then
+    python ${current_dir}/edit-swig-python-wrapper-file.py
+    if [ -f "${swig_output_file}.edited" ]
+    then
+        mv "${swig_output_file}.edited" ${swig_output_file}
+    fi
+fi

Modified: lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py?rev=117612&r1=117611&r2=117612&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py (original)
+++ lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py Thu Oct 28 16:51:20 2010
@@ -3,17 +3,28 @@
 #
 # This script performs some post-processing editing on the C++ file that
 # SWIG generates for python, after running on 'lldb.swig'.   In
-# particular, the types SWIGTYPE_p_SBThread and SWIGTYPE_p_SBTarget are
-# being used, when the types that *should* be used are 
-# SWIGTYPE_p_lldb__SBThread and SWIGTYPE_p_lldb__SBTarget.
-# This script goes through the C++ file SWIG generated, reading it in line
-# by line and doing a search-and-replace for these strings.
+# particular, on Apple systems we want to include the Python.h file that
+# is used in the /System/Library/Frameworks/Python.framework, but on other
+# systems we want to include plain <Python.h>.  So we need to replace:
+#
+# #include <Python.h>
+#
+# with:
+#
+# #if defined (__APPLE__)
+# #include <Python/Python.h>
+# #else
+# #include <Python.h>
+# #endif
+#
+# That's what this python script does.
 #
 
 
 import os
 
-full_input_name = os.environ["SCRIPT_INPUT_FILE_1"];
+input_dir_name = os.environ["SRCROOT"]
+full_input_name = input_dir_name + "/source/LLDBWrapPython.cpp"
 full_output_name = full_input_name + ".edited"
 
 try:
@@ -26,8 +37,7 @@
     except IOError:
         print "Error:  Unable to open file for writing: " + full_output_name
     else:
-        target_typedef_found = False
-        thread_typedef_found = False
+        include_line_found = False
 
         try:
             line = f_in.readline()
@@ -37,15 +47,18 @@
             while line:
                 #
                 #
-                if (line.find ("SWIGTYPE_p_SBTarget")):
-                    if (line.find ("define") < 0):
-                        line = line.replace ("SWIGTYPE_p_SBTarget", 
-                                             "SWIGTYPE_p_lldb__SBTarget")
-                if (line.find ("SWIGTYPE_p_SBThread")):
-                    if (line.find ("define") < 0):
-                        line = line.replace ("SWIGTYPE_p_SBThread", 
-                                             "SWIGTYPE_p_lldb__SBThread")
-                f_out.write (line)
+                if not include_line_found:
+                    if (line.find ("#include <Python.h>") == 0):
+                        f_out.write ("#if defined (__APPLE__)\n");
+                        f_out.write ("#include <Python/Python.h>\n");
+                        f_out.write ("#else\n");
+                        f_out.write (line);
+                        f_out.write ("#endif\n");
+                        include_line_found = True
+                    else:
+                        f_out.write (line)
+                else:
+                    f_out.write (line)
                 try:
                     line = f_in.readline()
                 except IOError:

Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=117612&r1=117611&r2=117612&view=diff
==============================================================================
--- lldb/trunk/source/API/SBBreakpointLocation.cpp (original)
+++ lldb/trunk/source/API/SBBreakpointLocation.cpp Thu Oct 28 16:51:20 2010
@@ -7,11 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// In order to guarantee correct working with Python, Python.h *MUST* be
-// the *FIRST* header file included:
-
-#include <Python.h>
-
 #include "lldb/API/SBBreakpointLocation.h"
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBDebugger.h"

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=117612&r1=117611&r2=117612&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Thu Oct 28 16:51:20 2010
@@ -10,7 +10,11 @@
 // In order to guarantee correct working with Python, Python.h *MUST* be
 // the *FIRST* header file included:
 
+#if defined (__APPLE__)
+#include <Python/Python.h>
+#else
 #include <Python.h>
+#endif
 
 #include "lldb/Interpreter/ScriptInterpreterPython.h"
 





More information about the lldb-commits mailing list