[Lldb-commits] [lldb] r180705 - Add a final fall-back to PlatformDarwin::GetDeveloperDirectory() which

Jason Molenda jmolenda at apple.com
Mon Apr 29 02:48:26 PDT 2013


Author: jmolenda
Date: Mon Apr 29 04:48:26 2013
New Revision: 180705

URL: http://llvm.org/viewvc/llvm-project?rev=180705&view=rev
Log:
Add a final fall-back to PlatformDarwin::GetDeveloperDirectory() which
will run xcode-select --print-path to find the currently selected 
Xcode developer directory.  Mostly useful for when lldb is not being run out
of the /Applications/Xcode.app bundle so it can't locate the iOS or
kernel SDKs.

Modified:
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=180705&r1=180704&r2=180705&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon Apr 29 04:48:26 2013
@@ -969,6 +969,43 @@ PlatformDarwin::GetDeveloperDirectory()
             }
         }
         
+        if (!developer_dir_path_valid)
+        {
+            FileSpec xcode_select_cmd ("/usr/bin/xcode-select", false);
+            if (xcode_select_cmd.Exists())
+            {
+                int exit_status = -1;
+                int signo = -1;
+                std::string command_output;
+                Error error = Host::RunShellCommand ("/usr/bin/xcode-select --print-path", 
+                                                     NULL,                                 // current working directory
+                                                     &exit_status,
+                                                     &signo,
+                                                     &command_output,
+                                                     2,                                     // short timeout
+                                                     NULL);                                 // don't run in a shell
+                if (error.Success() && exit_status == 0 && !command_output.empty())
+                {
+                    const char *cmd_output_ptr = command_output.c_str();
+                    developer_dir_path[sizeof (developer_dir_path) - 1] = '\0';
+                    int i;
+                    for (i = 0; i < sizeof (developer_dir_path) - 1; i++)
+                    {
+                        if (cmd_output_ptr[i] == '\r' || cmd_output_ptr[i] == '\n' || cmd_output_ptr[i] == '\0')
+                            break;
+                        developer_dir_path[i] = cmd_output_ptr[i];
+                    }
+                    developer_dir_path[i] = '\0';
+
+                    FileSpec devel_dir (developer_dir_path, false);
+                    if (devel_dir.Exists() && devel_dir.IsDirectory())
+                    {
+                        developer_dir_path_valid = true;
+                    }
+                }
+            }
+        }
+
         if (developer_dir_path_valid)
         {
             temp_file_spec.SetFile (developer_dir_path, false);





More information about the lldb-commits mailing list