Fix build of darwin-debug in cmake on OS X. Currently it works in XCode.

This patch fixes test_launch_in_terminal test which doesn't work in OS X since 
the moment as it was added in r225284. The test fails because Target::Launch 
returns the following error: "the 'darwin-debug' executable doesn't exists at 
'/Users/IliaK/p/llvm/build_ninja/lib/python2.7/site-packages/lldb/darwin-debug'".

```
Log:
======================================================================
FAIL: test_launch_in_terminal (TestTerminal.LaunchInTerminalTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File 
"/Users/IliaK/p/llvm/tools/lldb/test/functionalities/tty/TestTerminal.py", line 
36, in test_launch_in_terminal
    self.assertTrue(error.Success(), "Make sure launch happened successfully in 
a terminal window")
AssertionError: False is not True : Make sure launch happened successfully in a 
terminal window
Config=x86_64-clang
```

For more information see following thread: 
http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20150119/014983.html

http://reviews.llvm.org/D7102

Files:
  scripts/Python/finish-swig-Python-LLDB.sh
  scripts/Python/finishSwigPythonLLDB.py
  tools/CMakeLists.txt
  tools/darwin-debug/CMakeLists.txt

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: scripts/Python/finish-swig-Python-LLDB.sh
===================================================================
--- scripts/Python/finish-swig-Python-LLDB.sh
+++ scripts/Python/finish-swig-Python-LLDB.sh
@@ -167,6 +167,22 @@
     fi
 fi
 
+if [ ! -L "${framework_python_dir}/darwin-debug" ]
+then
+    if [ $Debug -eq 1 ]
+    then
+        echo "Creating symlink for darwin-debug"
+    fi
+    cd "${framework_python_dir}"
+    if [ $MakefileCalled -ne 0 ]
+        ln -s "../../../../bin/lldb-launcher" darwin-debug
+    fi
+else
+    if [ $Debug -eq 1 ]
+    then
+        echo "${framework_python_dir}/darwin-debug already exists."
+    fi
+fi
 
 create_python_package () {
     package_dir="${framework_python_dir}$1"
Index: scripts/Python/finishSwigPythonLLDB.py
===================================================================
--- scripts/Python/finishSwigPythonLLDB.py
+++ scripts/Python/finishSwigPythonLLDB.py
@@ -330,6 +330,53 @@
 	return (bOk, strMsg);
 	
 #++---------------------------------------------------------------------------
+# Details:	Make the symbolic link to the darwin-debug. Code for all platforms
+#           apart from Windows.
+# Args:		vDictArgs				- (R) Program input parameters.
+#			vstrFrameworkPythonDir	- (R) Python framework directory.
+#			vstrDarwinDebugFileName	- (R) File name for darwin-debug.
+# Returns:	Bool - True = function success, False = failure.
+#			Str - Error description on task failure.
+# Throws:	None.
+#--
+def make_symlink_darwin_debug( vDictArgs, vstrFrameworkPythonDir, vstrDarwinDebugFileName ):
+	dbg = utilsDebug.CDebugFnVerbose( "Python script make_symlink_other_platforms()" );
+	bOk = True;
+	strMsg = "";
+	bDbg = vDictArgs.has_key( "-d" );
+	strTarget = vstrDarwinDebugFileName
+	strDarwinDebugPath = "%s/%s" % (vstrFrameworkPythonDir, strTarget);
+	strTarget = os.path.normcase( strDarwinDebugPath );
+	strSrc = "";
+			
+	os.chdir( vstrFrameworkPythonDir );
+	bMakeFileCalled = vDictArgs.has_key( "-m" );
+	if not bMakeFileCalled:
+	    return (bOk, strMsg);
+	else:
+		strSrc = os.path.normcase( "../../../bin/lldb-launcher" );
+
+	if os.path.islink( strTarget ):
+		if bDbg:
+			print strMsglldbsoExists % strTarget;
+		return (bOk, strMsg);
+	
+	if bDbg:
+		print strMsglldbsoMk;
+		
+	try:
+		os.symlink( strSrc, strTarget );
+	except OSError as e:
+		bOk = False;
+		strMsg = "OSError( %d ): %s %s" % (e.errno, e.strerror, strErrMsgMakeSymlink);
+		strMsg += " Src:'%s' Target:'%s'" % (strSrc, strTarget);
+	except:
+		bOk = False;
+		strMsg = strErrMsgUnexpected % sys.exec_info()[ 0 ];
+	
+	return (bOk, strMsg);
+
+#++---------------------------------------------------------------------------
 # Details:	Make the symlink that the script bridge for Python will need in 
 # 			the Python framework directory.
 # Args:		vDictArgs				- (R) Program input parameters.
@@ -343,9 +390,10 @@
 	bOk = True;
 	strWkDir = "";
 	strErrMsg = "";
+	eOSType = utilsOsType.determine_os_type();
+
+    # Make symlink for _lldb
 	strSoFileName = "_lldb";
-	 
-	eOSType = utilsOsType.determine_os_type();
 	if eOSType == utilsOsType.EnumOsType.Unknown:
 		bOk = False;
 		strErrMsg = strErrMsgOsTypeUnknown;
@@ -357,6 +405,14 @@
 		bOk, strErrMsg = make_symlink_other_platforms( vDictArgs, 
 													   vstrFrameworkPythonDir,
 													   strSoFileName );		
+
+    # Make symlink for darwin-debug
+	strDarwinDebugFileName = "darwin-debug"
+	if bOk and eOSType == utilsOsType.EnumOsType.Darwin:
+		bOk, strErrMsg = make_symlink_darwin_debug( vDictArgs,
+												    vstrFrameworkPythonDir,
+												    strDarwinDebugFileName );
+
 	return (bOk, strErrMsg);
 
 #++---------------------------------------------------------------------------
Index: tools/CMakeLists.txt
===================================================================
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -1,4 +1,5 @@
 if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+  add_subdirectory(darwin-debug)
   add_subdirectory(debugserver)
 endif()
   add_subdirectory(driver)
Index: tools/darwin-debug/CMakeLists.txt
===================================================================
--- tools/darwin-debug/CMakeLists.txt
+++ tools/darwin-debug/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_lldb_executable(lldb-launcher
+  darwin-debug.cpp
+  )
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to