Page 1 of 1

how get "IntermediateDirectory" of active project

Posted: Tue Feb 07, 2012 12:22 am
by vsfai
hello,

how can i get name for "IntermediateDirectory" for active project in the plugin?

for example with this i can get project name for active project:
IManager *m_mgr;
wxString projectName = m_mgr->GetWorkspace()->GetActiveProjectName();

But how can i check this for Intermediate Directory, which is setup for example ./Debug

thx.

br, vsfai

Re: how get "IntermediateDirectory" of active project

Posted: Tue Feb 07, 2012 9:19 pm
by eranif
To get values of codelite's macros, use the IMacroManager interface.

For example, to get the value of the intermediateDirectory, use this snippet:

Code: Select all

m_mgr->GetMacrosManager()->Expand(wxT("$(IntermediateDirectory)"), m_mgr, wxT("MyProject"), wxT("Debug"));
Where:
MyProject / Debug are the Project Name / Configuration

You can always take the "long" path and use this approach:

Code: Select all


wxString confToBuild = wxT("Debug");
wxString project     = wxT("MyProject");

// Get the workspace instance
Workspace *workspace = m_mgr->GetWorkspace();
wxString errMsg;

// Locate our project
ProjectPtr proj = workspace->FindProjectByName(project, errMsg);
if(proj) {
	// Find the relevant build configuration 
	BuildConfigPtr bldConf = workspace->GetProjBuildConf(proj->GetName(), confToBuild);
	if(bldConf) {
		// and finally, we got a complete access to the entire build configuration
		// the BuildConfigPtr holds everythign that a user sees in the project settings dialog per project/configuration
		
		// Note that some of the values held in it are not expanded ! (they might contain macros) 
		// so you will still need to expand them using the macro manager
		wxString imdDir = bldConf->GetIntermediateDirectory();
		
	}
}
Eran

Re: how get "IntermediateDirectory" of active project

Posted: Wed Feb 08, 2012 12:47 am
by vsfai
Hello,

thank you, the "long" path works very well, thank you for advice.

br, vsfai

Re: how get "IntermediateDirectory" of active project

Posted: Fri Apr 13, 2012 12:51 pm
by foxmuldr
You could also write some code to read in the project.mk file and parse the lines themselves. For example, look for "IntermediateDirectory" and skip past whitespaces to reach ":=" and then it's the data after that.

The CL .mk file looks like this (in part):

Code: Select all

##
## Auto Generated makefile by CodeLite IDE
## any manual changes will be erased      
##
## WinReleaseUnicode
ProjectName            :=LiteEditor
ConfigurationName      :=WinReleaseUnicode
IntermediateDirectory  :=./Release
OutDir                 := $(IntermediateDirectory)
WorkspacePath          := "/home/rick/source/Codelite"
ProjectPath            := "/home/rick/source/Codelite/LiteEditor"
By simply reading that text file, you can obtain the value as well, inside or outside of CL.

Best regards,