Author Topic: How to build project programaticly from plugin using sdk calls ?  (Read 8927 times)

Offline dhia hassen

  • Single posting newcomer
  • *
  • Posts: 3
How to build project programaticly from plugin using sdk calls ?
« on: September 07, 2017, 07:26:19 pm »
I am trying to cause the current project to build to the cirrent target using sdk calls from a plugin in code::blocks , i dont know what code to write for that ! can you help me :)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: How to build project programaticly from plugin using sdk calls ?
« Reply #1 on: September 07, 2017, 11:05:17 pm »
You probably need something like this pseudo code (i did not compiled the code, nor did i test it):
Code
// Get the current project
cbProject* project = Manager::Get()->GetProjectManager()->GetActiveProject();
// Get the debug build target
ProjectBuildTarget* target = project ->GetBuildTarget(wxT("debug"));

PluginsArray arr = Manager::Get()->GetPluginManager()->GetCompilerOffers();
cbCompilerPlugin* comp;
for(size_t i = 0; i < arr.size(); ++i)
{
   comp = dynamic_cast<cbCompilerPlugin*>(arr[i])
   if(comp)
   {
        // here you should check if this is the right compiler. No idea how you can do this
        break;
   }
}

comp->Build(target);
if(comp->GetExitCode() != 0)
{
    //compiling failed
}