Showing posts with label build system. Show all posts
Showing posts with label build system. Show all posts

2007-10-28

SCons is not bad, not bad at all

For my personal project where I learn a language by writing five small example applications, I had ended up writing my own build tool. It was nothing much: specify the source extension, compiled file extension, and the command to execute. But then each language added some tweak that caused issues. Haskell, for instance, was the first language I wrote my example apps in that had several intermediate files that needed to be cleaned up. So then I needed to add support for specifying file extensions that could be safely deleted. And all of this was being kept in a config file that required using ConfigParser (not the nicest module in Python's stdlib to work with). I was writing too much code for a problem others have solved in separate tools for a long time.

But I hate Makefiles and that is the one build tool that I have any experience with. I have talked about replacing Python's build system with an alternative, so I figured I might as well learn a new one so as to compare against GNU Make. I considered using Bakefile, CMake, and SCons.

Bakefile was killed as a possible solution immediately based on lack of development. The mailing list has only a single new thread in October and the last release was back in February. Now being a open-source software developer I can understand having several months between releases, but I just tend to trust projects that have been updated within the last six months or at least have an active mailing list to back it up, especially when the project lacks a 1.0 release. So Bakefile was out.

CMake was a definite contender. Since it is the unofficial leader in the race in my head for a build system replacement for Python I really wanted to give CMake a try. Unfortunately I couldn't easily figure out how to create a custom build command. Since my use case is compiling several non-standard languages I needed an easy way to specify a custom build command along with a way to state what files to delete on cleanup. I just couldn't figure out how to do that in CMake.

And that left SCons. I was able to get it work with all the languages without much issue. I do have some boilerplate in several SConstruct files for tacking on file extensions of files to remove during cleanup, but it isn't bad. Plus having the build files be Python made it easy to extend it to do whatever I needed. My only complaint is that I had to hard-code the paths to the compilers since Builder commands don't seem to execute within a shell. I might just write a 'which' replacement and stick in my root SConstruct file (along with any other boilerplate I have written) and just expose the code through SCons variables. But overall I am happy with SCons for my personal use.

2007-04-24

Finding a replacement for autoconf/make

In a post I derided having to use autoconf and GNU Make. In a comment Alexander Dymo reminded me that KDE and many of its associated projects have moved over to CMake. Now I am sure KDE's build process is at least as complicated as Python's, especially since it contains a bunch of external projects which Python itself now does (such as the sqlite3 and ctypes libraries).

That has me thinking that after I get my TODO list done (mostly moving the tracker, closing some bugs, and then getting Python to use my import implementation), I will need a new Python project. Fixing the bloody build system is probably a good one. =)

But what will I need? I need to replace both autoconf and GNU Make. Usually the trick is replacing autoconf as we have a bunch of IFDEFs in various places that activate the compilation of a method or function on an object based on whether the underlying C implementation exposes something. We also have a ton of macros that make sure that certain values (such as Py_ssize_t) are at a guaranteed width.

But portability is really critical. Python runs on basically any platform that has a shell, GNU Make, and a C89 compiler. That portability cannot be lost.

So who seem to be the bigger players out there? Now granted I have not researched this at all and this is just based on my various readings around the web and keeping an eye on this topic since I hate autoconf and GNU Make so much. But there seems to be about two projects that have really tried to replace these two tools (or at least GNU Make):

  • CMake (major project - KDE 4). KDE is a big project. The fact that they moved over to it and seem to have been happy with the switch is a big plus. Minus is that I don't know how active development is as the news page has as its last announcement that KDE 4 was using the tool. It generates Makefiles and such so it is just as portable which is great.
  • Bakefile (major project - wxWidgets). Considering how many different operating systems wxWidgets builds on this speaks well for Bakefile. They had a release in February which is encouraging, although it was version 0.2.2. I don't know how mature Bakefile is. But it is written in Python which is a (minor) perk. It also generates Makefiles which makes it very portable.
I would have listed Aap, but it has not had a new news item since 2004! And SCons can't be listed as it requires Python to be installed; doesn't work when the thing you are trying to build is Python. =). There are probably more, but these are the two that I know of off the top of my head.

As I said, this might be a project that I tackle after I finish my Python TODO list (which is already long), so it will be months before I even consider seriously looking at this.