Skip to content

Commit

Permalink
Add new macro WorkspaceRealPath (#3544)
Browse files Browse the repository at this point in the history
  • Loading branch information
UffeJakobsen authored Dec 1, 2024
1 parent e68db30 commit baf7836
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Plugin/macromanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "project.h"
#include "workspace.h"
#include "wxStringHash.h"
#include "fileutils.h"

#include <wx/regex.h>

Expand Down Expand Up @@ -156,6 +157,7 @@ const std::unordered_set<wxString> CODELITE_MACROS = {
"WorkspaceName",
"WorkspaceConfiguration",
"WorkspacePath",
"WorkspaceRealPath",
"OutputDirectory",
"ProjectOutputFile",
"OutputFile",
Expand Down Expand Up @@ -254,6 +256,8 @@ wxString MacroManager::DoExpand(const wxString& expression, IManager* manager, c
wspName = clWorkspaceManager::Get().GetWorkspace()->GetName();
}

wxString wspRealPath = FileUtils::RealPath(wspPath);

size_t retries = 0;
wxString dummyname, dummfullname;
while((retries < 5) && FindVariable(expandedString, dummyname, dummyname)) {
Expand All @@ -262,6 +266,7 @@ wxString MacroManager::DoExpand(const wxString& expression, IManager* manager, c
expandedString.Replace("$(WorkspaceName)", wspName);
expandedString.Replace("$(WorkspaceConfiguration)", wspConfig);
expandedString.Replace("$(WorkspacePath)", wspPath);
expandedString.Replace("$(WorkspaceRealPath)", wspRealPath);

if(workspace) {
ProjectPtr proj = workspace->GetProject(project);
Expand Down
1 change: 1 addition & 0 deletions Plugin/macrosdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ void MacrosDlg::Initialize()
case MacrosProject:
AddMacro("$(ProjectPath)", _("Expands to project's path"));
AddMacro("$(WorkspacePath)", _("Expands to workspace's path"));
AddMacro("$(WorkspaceRealPath)", _("Expands to workspace's real path (with symlinks resolved)"));
AddMacro("$(WorkspaceConfiguration)", _("Expands to the workspace selected configuration"));
AddMacro("$(ProjectName)", _("Expands to the current project name as appears in the 'File View'"));
AddMacro("$(IntermediateDirectory)",
Expand Down
6 changes: 1 addition & 5 deletions docs/docs/settings/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Below is a list of supported macros by CodeLite:
`$(WorkspaceName)`|The current workspace name
`$(WorkspaceConfiguration)`|The workspace configuration (e.g. `Debug`)
`$(WorkspacePath)`|The workspace path. For remote workspaces, this expands to the remote workspace path
`$(WorkspaceRealPath)`|The workspace path (with symlinks resolved). For remote workspaces, this expands to the remote workspace path
`$(ProjectName)`|Current project name
`$(IntermediateDirectory)`|The location where CodeLite places object files (`.o`)
`$(ConfigurationName)`|The current **project** configuration name. e.g. (`Debug`)
Expand All @@ -30,8 +31,3 @@ Below is a list of supported macros by CodeLite:
`$(SSH_AccountName)`| When a remote workspace is loaded, this expands to the current account name connected
`$(SSH_Host)`| When a remote workspace is loaded, this expands to the current host connected
`$(SSH_User)`| When a remote workspace is loaded, this expands to the SSH'd user





0 comments on commit baf7836

Please sign in to comment.