Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: threeS on October 06, 2014, 10:01:10 pm

Title: Getting the file path
Post by: threeS on October 06, 2014, 10:01:10 pm
Good day!
In relation to my post previously in:
Quote
http://forums.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.
Title: Re: Getting the file path
Post by: oBFusCATed on October 06, 2014, 11:50:25 pm
Checkout the cbProject and CompileTargetBase classes.
Title: Re: Getting the file path
Post by: threeS on October 08, 2014, 10:43:25 pm
Good day!

We had tried some experiments like

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

-
Quote
Manager::Get()->GetProjectManager()->GetActiveProject()->GetActiveBuildTarget()
Returned output:
Quote
default

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

-
Quote
Manager::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]
Title: Re: Getting the file path
Post by: oBFusCATed on October 09, 2014, 12:09:23 am
What about the CompileTargetBase::GetOutputFilename?
Title: Re: Getting the file path
Post by: threeS on October 12, 2014, 04:55:14 pm
We've tried the
Quote
CompileTargetBase::GetOutputFilename
but it gives the output
Quote
/file/project/location
.


Anybody can help?  :'(
Title: Re: Getting the file path
Post by: oBFusCATed on October 12, 2014, 05:13:12 pm
What object have you used as this project or a target?
Title: Re: Getting the file path
Post by: threeS on October 12, 2014, 06:32:35 pm
We don't really know what you mean but we are creating a plugin.  :)
Title: [SOLVED]: Getting the file path
Post by: threeS on October 12, 2014, 09:15:32 pm
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  :)
Title: Re: Getting the file path
Post by: oBFusCATed on October 12, 2014, 09:50:58 pm
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:
Code
> print(GetProjectManager().GetActiveProject().GetBuildTarget(_T("src")).GetOutputFilename())
devel/codeblocks

Have you search the code of C::B to see how GetOutputFilename is used?