Author Topic: Compile on demand plugin  (Read 20350 times)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Compile on demand plugin
« on: February 07, 2012, 12:13:40 pm »
I have found a plugin again which I wrote some time ago.
It enables you to let C::B build a file whenever you save it, so that the project is always up-to-date. (It requires a patch on the compiler plugin to work.)

Here it comes... feel free to report if it is of help...
« Last Edit: February 16, 2012, 08:54:33 am by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ptDev

  • Almost regular
  • **
  • Posts: 222
Re: Compile on demand plugin
« Reply #1 on: February 16, 2012, 08:51:29 am »
Works as advertised on my local build. :) This is a very interesting plugin indeed. Can I make small changes to it?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: Compile on demand plugin
« Reply #2 on: February 16, 2012, 08:54:25 am »
Works as advertised on my local build. :) This is a very interesting plugin indeed. Can I make small changes to it?
Sure, but please use the (updated) version I have attached to this post.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12066
    • Travis build status
Re: Compile on demand plugin
« Reply #3 on: February 16, 2012, 09:38:16 am »
I've also wanted to try it, but it was intended to build as part of the contrib plugins, so I didn't bother to fix it to compile off tree.

I don't like the practice of making plugins compile from inside the c::b tree.
We must make sure we provide proper sdk which can be used easily to make plugins for c::b.
(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 ptDev

  • Almost regular
  • **
  • Posts: 222
Re: Compile on demand plugin
« Reply #4 on: February 16, 2012, 10:12:19 am »
Fixing the paths is relatively easy. We can already use the CB variable to allow plugins compilation anywhere.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: Compile on demand plugin
« Reply #5 on: February 16, 2012, 10:22:46 am »
I don't like the practice of making plugins compile from inside the c::b tree.
As I have in mind to submit it later, I didn't want to change it at that time. ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ptDev

  • Almost regular
  • **
  • Posts: 222
Re: Compile on demand plugin
« Reply #6 on: March 03, 2012, 12:18:15 pm »
I'm trying to make CompileOnDemand add a check item to the Build menu instead of using that single-checkbox dialog to turn it on or off. It just makes more sense IMHO. I made it inherit from cbPlugin instead of cbToolPlugin and added the needed BuildMenu(...) and event handler.

The problem is that it always fails to find the Build menu. Why is this the case? Is it being loaded before the Compiler plugin? Is there a simple way to fix it?

I'm also wondering whether it wouldn't be better to simply add the functionality to the Compiler plugin...

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: Compile on demand plugin
« Reply #7 on: March 03, 2012, 12:39:05 pm »
The problem is that it always fails to find the Build menu. Why is this the case? Is it being loaded before the Compiler plugin?
Yes - that most likely the reason. And keep in mind that in the future it may have way more config options! I don't kn ow if that is such a good idea... (see below).

Is there a simple way to fix it?
You'll need to delay the attachment to the menu.
 
I'm also wondering whether it wouldn't be better to simply add the functionality to the Compiler plugin...
I ad in mind to enhance it step by step: So that in the end it will sit in the background and compile what's needed not only on save.

And btw: As of now it has a serious bug that it interferes with C::B (and makes it hang) if you have modified files open and hit compile. At that time the interim compilation will make C::B hang. Solution: If the build process is started, ignore the events from Compile n demand (or don't send them from the plugin).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ptDev

  • Almost regular
  • **
  • Posts: 222
Re: Compile on demand plugin
« Reply #8 on: March 03, 2012, 12:52:56 pm »
Yes - that most likely the reason. And keep in mind that in the future it may have way more config options! I don't know if that is such a good idea...

I'll keep the options dialog here too, then. On the other hand, how do I delay attaching the menus, if building the plugins menu is called from CodeBlocks through the cbPlugin interface?

Quote
As of now it has a serious bug that it interferes with C::B (and makes it hang) if you have modified files open and hit compile. At that time the interim compilation will make C::B hang. Solution: If the build process is started, ignore the events from Compile n demand (or don't send them from the plugin).

I'll learn if I can check if a compilation is already started and make CompileOnDemand skip the event handler in that case.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: Compile on demand plugin
« Reply #9 on: March 03, 2012, 01:34:14 pm »
how do I delay attaching the menus, if building the plugins menu is called from CodeBlocks through the cbPlugin interface?
I.e. storing the menu pointers and adjusting the menu after the startup complete event.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Compile on demand plugin
« Reply #10 on: March 03, 2012, 02:22:33 pm »
how do I delay attaching the menus, if building the plugins menu is called from CodeBlocks through the cbPlugin interface?
I.e. storing the menu pointers and adjusting the menu after the startup complete event.


Another idea would be to add the possibility to make one plugin depend on another to be loaded.

That would (of course) require changes to the pluginmanager.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: Compile on demand plugin
« Reply #11 on: March 03, 2012, 03:16:52 pm »
That would (of course) require changes to the pluginmanager.
My idea (a while back) was to have a plugin weight, which can be read from the plugin's manifest file. This way, a user can modify the load order if needed, it should be easy to implement and we can re-use code of the file weight for compilation units.

(I did it similar in another project of mine...)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12066
    • Travis build status
Re: Compile on demand plugin
« Reply #12 on: March 03, 2012, 06:51:33 pm »
Another idea would be to add the possibility to make one plugin depend on another to be loaded.

That would (of course) require changes to the pluginmanager.
+1 here.
Plugin-load-weight sounds like a hack/workaround/hard to maintain feature...
(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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: Compile on demand plugin
« Reply #13 on: March 03, 2012, 09:09:11 pm »
Another idea would be to add the possibility to make one plugin depend on another to be loaded.
So what would be the base for the comparison then? The plugin's name, a GUID?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ptDev

  • Almost regular
  • **
  • Posts: 222
Re: Compile on demand plugin
« Reply #14 on: March 03, 2012, 09:39:29 pm »
Another idea would be to add the possibility to make one plugin depend on another to be loaded.
So what would be the base for the comparison then? The plugin's name, a GUID?

Would using the plugin's name for this be a bad idea?

One could allow a vector of strings of "dependencies" to be passed to a plugin, and plugin manager would make a check for each plugin being loaded, if all of its dependencies have already been loaded (by finding by name).

EDIT: Actually, scratch that. It's probably better to just list dependencies in the plugin manifest file.
Since most plugins do not need this, the required overhead at startup would actually still be acceptable.
« Last Edit: March 03, 2012, 09:41:46 pm by ptDev »