Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: Alpha on September 02, 2011, 02:53:23 am

Title: Project Exporter Plugin
Post by: Alpha on September 02, 2011, 02:53:23 am
I have written a plugin that will export the active project as a premake 4 (http://industriousone.com/premake) script.  Premake has the ability to generate multiple IDE project files and makefiles, so if proper Premake support is achieved, Code::Blocks will in essence be able to export to all of them.

v0.3 (https://skydrive.live.com/self.aspx/Public/ProjectExporter.7z?cid=5183ac017415bf92&sc=documents) Bakefile support added; GUI cut down to be reasonable; several minor fixes in project reading

v0.2 (https://skydrive.live.com/self.aspx/Public/ExportProject-3.7z?cid=5183ac017415bf92&sc=documents) GUI drafted; upgrade targets to projects option; evaluate variables option; language detection.

v0.1.1 (http://ngcoding.tech.officelive.com/Documents/ExportProject-2.7z) fixed crash on restart.
Here (http://ngcoding.tech.officelive.com/Documents/ExportProject.7z) (v0.1) is the initial source code.

Known problems/To-Do's:

Note: if you are looking for mature makefile generation, see cbp2make (http://forums.codeblocks.org/index.php/topic,13675.0.html).
Title: Re: Project Exporter Plugin
Post by: Alpha on September 05, 2011, 03:15:15 am
Version 0.2 released.  Please note that although the dialog has many options, only the first two are implemented (the others will do nothing).  Also, the dialog is likely to be completely changed in the next version.

Switched hosting to SkyDrive (sorry, to download, you will need to click twice instead of just once; however, the files should not go offline at the end of the year now).

Does anyone have enough knowledge with premake/makefiles to tell me why C projects do not compile?  Thanks.
Title: Re: Project Exporter Plugin
Post by: Alpha on November 08, 2011, 12:57:24 am
Version 0.3 released.  This release adds preliminary Bakefile support.  (If you decide to look at the code for this section, be warned that it is quite messy at the moment.)

The Premake options dialog now is condensed to the few essentials.

Does anyone have a favorite build system they would like me to look into next (when I have time)?
Title: Re: Project Exporter Plugin
Post by: oBFusCATed on November 08, 2011, 01:12:10 am
Autotools of course :)
Title: Re: Project Exporter Plugin
Post by: Alpha on November 08, 2011, 11:33:14 pm
OK, I will see what I can do (this may be a bit more complicated...).

Do you have any suggested reading?  Most of my experience with Autotools has been only what I needed to use through MSYS.
Title: Re: Project Exporter Plugin
Post by: oBFusCATed on November 09, 2011, 01:25:22 am
You can start with this http://www.flameeyes.eu/autotools-mythbuster/ and then the manual of autotools (automake/autoconf,etc)
Title: Re: Project Exporter Plugin
Post by: Alpha on November 15, 2011, 11:56:05 pm
oBFusCATed, I have done a lot of Autotools reading (from the page you provided, the manuals, and multiple pages search engines have brought up), and begun work on creation of this system.  Would it be possible for you (or someone) to post/send me an example configure.ac + makefile.am that could be used to build a small Code::Blocks plugin (like this one)?
I believe having this example of something more complex than the standard "hello world", but still extremely small (only a few files in a single directory) will greatly speed my learning (and give me an example of what a well formatted script should look like).  (I have looked through Code::Blocks' Autotools build system, but it is extremely large and interdependent, making it a difficult place to start.)
Title: Re: Project Exporter Plugin
Post by: oBFusCATed on November 16, 2011, 09:38:00 am
You can try these two:
svn://smrt.is-a-geek.org/cb_gdb_mi/debbugger_gdbmi
svn://smrt.is-a-geek.org/cb_editor_navigation/

Both have working Autotools systems and both are made after reading the link I've posted.
Title: Re: Project Exporter Plugin
Post by: Alpha on November 16, 2011, 11:20:11 pm
Thank you very much; I have checked out their sources, and they look to be quite helpful in my learning of Autotools and designing of the exporter.
Title: Re: Project Exporter Plugin
Post by: Alpha on November 20, 2011, 05:48:17 am
Does anyone know if there is a function in Code::Blocks that I can call to acquire a list of all the files that are #included?  (Or is do I need to write a function to parse the source files myself?)
Title: Re: Project Exporter Plugin
Post by: ollydbg on November 20, 2011, 05:54:45 am
Once I know that gcc can generate a include files dependency. see:
c++ - Tool to track #include dependencies - Stack Overflow (http://stackoverflow.com/questions/42308/tool-to-track-include-dependencies)

and:

2.7 Automatic Dependency Generation (http://www.makelinux.net/make3/make3-CHP-2-SECT-7)
Title: Re: Project Exporter Plugin
Post by: oBFusCATed on November 20, 2011, 11:19:01 am
I think that depslib does this, check the source it is in svn.
Title: Re: Project Exporter Plugin
Post by: Alpha on November 20, 2011, 08:37:34 pm
Thank you both; I will look to see which option fits my needs.

(By the way, I just managed to compile Code::Blocks with a makefile generated from a Bakefile exported by this plugin :).)
Title: Re: Project Exporter Plugin
Post by: Alpha on November 21, 2011, 06:30:15 pm
Should the Autotools section of this plugin be dependent on autoscan?
Autoscan already has many of rules for determining which macros should be included.  I am not sure if it would be wise for me to spend a lot of time to attempt to replicate this functionality.

I am considering having this plugin set up everything except for the detection macros autoscan produces; for these, it would read the configure.scan, if it is available, and insert them in the relevant parts.  (The files would still be created if there was no configure.scan, however they would contain a message warning that the user must run autoscan first if they want additional detection macros.)
Title: Re: Project Exporter Plugin
Post by: ollydbg on November 22, 2011, 10:16:38 am
Thank you both; I will look to see which option fits my needs.

(By the way, I just managed to compile Code::Blocks with a makefile generated from a Bakefile exported by this plugin :).)

I just see some other good tools:
include-what-you-use (http://code.google.com/p/include-what-you-use)
Quote
include-what-you-use is a tool to ensure that a file directly #includes all .h files that provide a symbol that the file uses. It also removes superfluous #includes from source files.

In the LLVM 3.0 Release Notes (http://llvm.org/docs/ReleaseNotes.html) page.
Title: Re: Project Exporter Plugin
Post by: Alpha on November 22, 2011, 04:15:25 pm
I just see some other good tools:
include-what-you-use (http://code.google.com/p/include-what-you-use)
That looks to be a very powerful tool (in progress), but I think it is a bit of overkill for my purposes (aiding pseudo-detection of used libraries).  I have ended up (currently) using a regex to scan the files.
Title: Re: Project Exporter Plugin
Post by: MortenMacFly on May 24, 2012, 02:29:18 pm
At work, I had to provide a Premake build script today and tried this plugin. It works pretty well from what I see. Are you still working on this?

If you have no own repository, I would like to integrate this into the official C::B repo. Would that be OK? Hence I would need some help (if you are willing) to adopt the Linux build system and the Linux project file. Did you ever try this on Linux?
Title: Re: Project Exporter Plugin
Post by: Alpha on May 25, 2012, 02:01:22 am
Yes, I am still working on this, however, I have been very busy with studies, and lacked the time to finish a working Autotools export (which is what I was waiting for before posting the next version).

I do not have my own repository, so that would be great if you could include it in Code::Blocks' repository.  Unfortunately, I do not currently have easy access to a Linux computer, so it is untested there.
(If it is integrated, the ProjectsImporter plugin should probably be patched to be made aware of this plugin, so the menu building hack in this plugin can be removed.)

My current code (0.3a (https://skydrive.live.com/redir.aspx?cid=5183ac017415bf92&resid=5183AC017415BF92!131&parid=5183AC017415BF92!123&authkey=!)) contains minor tweaks to Premake, decent accuracy improvement for Bakefile, and preliminary Autotools code (not yet functional).

(Glad to hear that it works.)
Title: Re: Project Exporter Plugin
Post by: Alpha on May 25, 2012, 09:28:00 pm
Attached is my initial attempt at integration with the build systems.  I am sure I have missed something, but at least it should help (I hope).