From 63d324dff661da15b1c139391e722983dda3cecd Mon Sep 17 00:00:00 2001 From: Eran Ifrah Date: Sat, 23 Nov 2024 12:41:12 +0200 Subject: [PATCH] macOS: use more "persistent" paths Before this change, when using "brew" on macOS CodeLite detected executables (e.g. "clangd") under their versioned path (e.g. "/opt/homebrew/Cellar/llvm-19.1/bin/clangd") However, this approach was error prone since with each version update - the setup in CodeLite was broken (e.g. "clangd" stopped working, since it pointed to a non existing executable) With this fix, CodeLite will no longer search under the "versioned" path, instead it will use the more persistent path (if it exists): "/opt/homebrew/opt/llvm/bin" lldb-dap fix: on macOS, use socket based lldb-dap since using stdio crashes lldb-dap wxdap: updated wxdap to its latest version (which forces C++17 for the project) Signed-off-by: Eran Ifrah --- CodeLite/Platform/LINUX.cpp | 46 +++++------------------ CodeLite/tags_options_data.cpp | 2 +- DebugAdapterClient/DapLocator.cpp | 6 +++ DebugAdapterClient/DebugAdapterClient.cpp | 1 + submodules/wxdap | 2 +- 5 files changed, 19 insertions(+), 38 deletions(-) diff --git a/CodeLite/Platform/LINUX.cpp b/CodeLite/Platform/LINUX.cpp index fc5b080e38..ef7d2a7b90 100644 --- a/CodeLite/Platform/LINUX.cpp +++ b/CodeLite/Platform/LINUX.cpp @@ -20,42 +20,16 @@ namespace #ifdef __WXMAC__ /// Homebrew install formulas in a specific location, this function /// attempts to discover this location -bool macos_find_homebrew_cellar_path_for_formula(const wxString& formula, wxString* install_path) +bool macos_find_homebrew_opt_formula_dir(const wxString& formula, wxString* install_path) { - wxString cellar_path = "/opt/homebrew/Cellar"; - if (!wxFileName::DirExists(cellar_path)) { - cellar_path = "/usr/local/Cellar"; - } - - cellar_path << "/" << formula; - - if (!wxFileName::DirExists(cellar_path)) { - return false; - } - - // we take the string with the highest value - clFilesScanner fs; - clFilesScanner::EntryData::Vec_t results; - if (fs.ScanNoRecurse(cellar_path, results) == 0) { - return false; - } - - // we are only interested in the name part - for (auto& result : results) { - result.fullpath = result.fullpath.AfterLast('/'); + wxFileName fn("/opt/homebrew/opt", wxEmptyString); + fn.AppendDir(formula); + fn.AppendDir("bin"); + if (fn.DirExists()) { + *install_path = fn.GetPath(); + return true; } - - std::sort(results.begin(), results.end(), - [](const clFilesScanner::EntryData& a, const clFilesScanner::EntryData& b) { - clVersionString vs_a{ a.fullpath }; - clVersionString vs_b{ b.fullpath }; - // want to sort in descending order - return vs_b.to_number() < vs_a.to_number(); - }); - - *install_path << cellar_path << "/" << results[0].fullpath; - clDEBUG() << "Using cellar path:" << *install_path << endl; - return true; + return false; } #endif } // namespace @@ -159,8 +133,8 @@ bool LINUX::GetPath(wxString* value, bool useSystemPath) // llvm is placed under a special location // if we find it, we place it first wxString llvm_path; - if (macos_find_homebrew_cellar_path_for_formula("llvm", &llvm_path)) { - paths.Insert(llvm_path + "/bin", 0); + if (macos_find_homebrew_opt_formula_dir("llvm", &llvm_path)) { + paths.Insert(llvm_path, 0); } #endif diff --git a/CodeLite/tags_options_data.cpp b/CodeLite/tags_options_data.cpp index 96d3176cd0..5792945dc7 100644 --- a/CodeLite/tags_options_data.cpp +++ b/CodeLite/tags_options_data.cpp @@ -436,7 +436,7 @@ TagsOptionsData::TagsOptionsData() , m_clangOptions(0) , m_clangBinary("") , m_clangCachePolicy(TagsOptionsData::CLANG_CACHE_ON_FILE_LOAD) - , m_ccNumberOfDisplayItems(150) + , m_ccNumberOfDisplayItems(500) , m_version(0) { // Initialize defaults diff --git a/DebugAdapterClient/DapLocator.cpp b/DebugAdapterClient/DapLocator.cpp index 8131b888ed..e2a9239cff 100644 --- a/DebugAdapterClient/DapLocator.cpp +++ b/DebugAdapterClient/DapLocator.cpp @@ -96,9 +96,15 @@ void DapLocator::find_lldb_dap(std::vector* entries) } wxString entry_name = wxFileName(lldb_debugger).GetName(); +#ifdef __WXMAC__ + auto entry = create_entry(entry_name, 12345, { lldb_debugger, "--port", "12345" }, DapLaunchType::LAUNCH); + entry.SetEnvFormat(dap::EnvFormat::LIST); + entries->push_back(entry); +#else auto entry = create_entry_stdio(entry_name, { lldb_debugger }, DapLaunchType::LAUNCH); entry.SetEnvFormat(dap::EnvFormat::LIST); entries->push_back(entry); +#endif } void DapLocator::find_debugpy(std::vector* entries) diff --git a/DebugAdapterClient/DebugAdapterClient.cpp b/DebugAdapterClient/DebugAdapterClient.cpp index 65084b0f42..acb2473259 100644 --- a/DebugAdapterClient/DebugAdapterClient.cpp +++ b/DebugAdapterClient/DebugAdapterClient.cpp @@ -509,6 +509,7 @@ void DebugAdapterClient::OnDebugStart(clDebugEvent& event) } // start the debugger + LOG_DEBUG(LOG) << "Initializing debugger for executable:" << exepath << endl; if (!InitialiseSession(dap_server, exepath, args, working_directory, ssh_account, env)) { return; } diff --git a/submodules/wxdap b/submodules/wxdap index 0da9692bca..80acb15b7d 160000 --- a/submodules/wxdap +++ b/submodules/wxdap @@ -1 +1 @@ -Subproject commit 0da9692bca50ce744847ce76286fa18b24942ca6 +Subproject commit 80acb15b7d73fef142233b31e80e401aa286c1e9