Skip to content

Commit

Permalink
macOS: use more "persistent" paths
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
eranif committed Nov 23, 2024
1 parent b2e856f commit 63d324d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 38 deletions.
46 changes: 10 additions & 36 deletions CodeLite/Platform/LINUX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion CodeLite/tags_options_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions DebugAdapterClient/DapLocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,15 @@ void DapLocator::find_lldb_dap(std::vector<DapEntry>* 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<DapEntry>* entries)
Expand Down
1 change: 1 addition & 0 deletions DebugAdapterClient/DebugAdapterClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion submodules/wxdap

0 comments on commit 63d324d

Please sign in to comment.