how get "IntermediateDirectory" of active project

Discussion about CodeLite development process and patches
vsfai
CodeLite Enthusiast
Posts: 11
Joined: Tue Jan 10, 2012 11:50 pm
Genuine User: Yes
IDE Question: c++
Contact:

how get "IntermediateDirectory" of active project

Post 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
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: how get "IntermediateDirectory" of active project

Post 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
Make sure you have read the HOW TO POST thread
vsfai
CodeLite Enthusiast
Posts: 11
Joined: Tue Jan 10, 2012 11:50 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: how get "IntermediateDirectory" of active project

Post by vsfai »

Hello,

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

br, vsfai
foxmuldr
CodeLite Expert
Posts: 120
Joined: Sun May 10, 2009 6:56 am
Contact:

Re: how get "IntermediateDirectory" of active project

Post 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,
Best regards,
Rick C. Hodgin
www.Visual-FreePro.org
www.LibSF.org
Post Reply