From 92a2ddabd1e6b7abae07221ce99fb14b47a44a01 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 29 Apr 2013 09:48:26 +0000 Subject: [PATCH] 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. llvm-svn: 180705 --- .../Platform/MacOSX/PlatformDarwin.cpp | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index f9391744c972..fc3788529f4c 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -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); -- GitLab