Author Topic: Getting the file path  (Read 7703 times)

Offline threeS

  • Multiple posting newcomer
  • *
  • Posts: 36
Getting the file path
« 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Getting the file path
« Reply #1 on: October 06, 2014, 11:50:25 pm »
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!]

Offline threeS

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Getting the file path
« Reply #2 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]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Getting the file path
« Reply #3 on: October 09, 2014, 12:09:23 am »
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!]

Offline threeS

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Getting the file path
« Reply #4 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?  :'(

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Getting the file path
« Reply #5 on: October 12, 2014, 05:13:12 pm »
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!]

Offline threeS

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Getting the file path
« Reply #6 on: October 12, 2014, 06:32:35 pm »
We don't really know what you mean but we are creating a plugin.  :)

Offline threeS

  • Multiple posting newcomer
  • *
  • Posts: 36
[SOLVED]: Getting the file path
« Reply #7 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  :)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Getting the file path
« Reply #8 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?
(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!]