News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Getting the file path

Started by threeS, October 06, 2014, 10:01:10 PM

Previous topic - Next topic

threeS

Good day!
In relation to my post previously in:
Quote
http://forums.next.codeblocks.org/index.php/topic,19604.new.html#new

How can i get the file path of my compiled program using my build plugin.
The events already works every time i hit compile button.

thank you for the response.

oBFusCATed

Checkout the cbProject and CompileTargetBase classes.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

threeS

Good day!

We had tried some experiments like

-
QuoteManager::Get()->GetProjectManager()->GetActiveProject()->GetFilename()
Returned output:
Quote/file/project/location/file.cbp
(It returns the cbp file)

-
QuoteManager::Get()->GetProjectManager()->GetActiveProject()->GetActiveBuildTarget()
Returned output:
Quotedefault

-
QuoteManager::Get()->GetProjectManager()->GetActiveProject()->GetBasePath()
Returned output:
Quote/file/project/location/
(It returns the project path)

-
QuoteManager::Get()->GetProjectManager()->GetActiveProject()->GetCurrentlyCompilingTarget()->GetFilename()
Returned output: (codeblocks crashes along with codeblocks debug file)

We're trying to get the file path of the compiled file but we have no luck on finding it., :(
Expected:
Quote/file/project/location/file.cpp

[attachment deleted by admin]

oBFusCATed

What about the CompileTargetBase::GetOutputFilename?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

threeS

We've tried the
QuoteCompileTargetBase::GetOutputFilename
but it gives the output
Quote/file/project/location
.


Anybody can help?  :'(

oBFusCATed

What object have you used as this project or a target?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

threeS

We don't really know what you mean but we are creating a plugin.  :)

threeS

After a lot of trials and errors, we derive on these one:
Quote
wxString activetarget = Manager::Get()->GetProjectManager()->GetActiveProject()->GetActiveBuildTarget();

    wxString outputfile = Manager::Get()->GetProjectManager()->GetActiveProject()->GetBuildTarget(activetarget)->GetOutputFilename();
    wxString basepath = Manager::Get()->GetProjectManager()->GetActiveProject()->GetBasePath();
    wxString executable = basepath  + outputfile;
    executable.replace(executable.find(_(".")), 4,_(".cpp"));

and we successfully get what we're looking for, getting the
Quote/file/project/location/file.cpp
.
thanks a lot  :)

oBFusCATed

I don't know what project you have loaded, but this is the output for the following script run when the codeblocks-unix.cbp project is open:

> print(GetProjectManager().GetActiveProject().GetBuildTarget(_T("src")).GetOutputFilename())
devel/codeblocks


Have you search the code of C::B to see how GetOutputFilename is used?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]