I will come out and say it: I dislike IDEs. From Visual Studio to Eclipse by way of IntelliJ and Netbeans I find them all slow, unwieldy, complicated and buggy. They hide too much of the workings of the toolchains, spread configruation over a zillion dialogs, collaborate with source control like a stray dog with an alley cat and litter the workspace with all kinds of useless files.
Way back in `07 Jeff Atwood penned “The F5 Key Is Not A Build Process”. While I could add about 4 pages of things you can do with a “build script” outside of an IDE it wouldn’t add anything to the point so go read it.
Then go print “The F5 Key Is Not A Build Process” on a banner, hung it in the office and live by it.
There is one and only one unavoidable reason to use a fully fledged IDE and that is The Debugger! Every other reason can be done away with, provided there is sufficient editor and shell foo.
But IDE projects have big disadvantages when following proper software development practices (e.g. at least continuous integration with automated tests). Generally if you want to develop in an IDE and have a CI system you end up maintaining both separately1.
We define as maintenance the tasks of adding/removing files, defining dependencies between code components, compiler settings etc.
Errors in the IDE projects are also very hard to detect automatically: The build server will not use the IDE so the change is going to propagate to the whole team. There is nothing that drives developers to frustration faster than not being able to compile locally when the build server says everything is fine.
Solution: make the command line build system the master and provide IDE project generation facilities.
When a developer wants to use the IDE, she generates the project from a freshly updated workspace with the correct settings and continues working.
“But, there’s so many IDEs out there and they all use different file formats!” you will say and you will be absolutely correct.
The best case is when the IDE allows you to use a custom build system. This removes Visual Studio and a couple of more obscure ones from the list of frendlies, but VS has a very good documented XML-based format so there are ways around it.
Still the following example can be adapted to work in every case.
##Gaudi & QtCreator Example
QCreator uses two separate files: One file (prj.pro) lists the files, resources, paths etc. while the other (prj.user.pro) contains the IDE settings (layout, colors and more importantly the build & run settings).
Instead of maintaining the QtCreator project files separately we create a template from a functioning project file. In other words use the GUI once to configure everthing just so.
For convenience we use the ERB format for the templates2
The prj.pro.template is very simple:
Here we show only the relevant part from the prj.user.pro.template3 with the custom build system settings
We now have our templates. The parameter names are fully arbitrary at the moment, they serve only as descriptive names.
We are faced with the task of collecting the file names, setting paths correctly etc. This is where Gaudi comes in. The Rake task code that generates the prj.pro file looks like the following:
What we get from Gaudi:
- The configuration defining the workspace (output directory, base directory etc.)
- A few classes (Deployment, Program, Component) linking sources to binary artifacts and encapsulating the dependencies between code constructs
- Helpers for template handling (from_template, write_file etc.)
##Conclusion Creating IDE project files while maintaining a fully command line enabled build system is not very difficult. The combination of one of the myriad template engines with a few lines of scripting to collect the necessary information gets you quickly to a very usable solution. The bulk of the time spent is dedicated to deciphering the IDE file format and creating the template.
##You never walk alone
QtCreator expertise provided and code polished by jahnf who suffered through all my explanations of Gaudi interna and managed to write tasks at the end.
1 It can be done but driving the process of development from the IDE throws up all sorts of hurdles in a proper CI workflow.
2 Gaudi is built on Rake, which is Ruby, which offers ERB in the standard library
3 Because XML!
4 Once set up and configured properly