Make Out with SCons
Nice2Cats writes "I stumbled across this and can't find a mention of it here yet: SCons, a stable alternative for the vilified make. Built-in support, they claim, for C, C++, and Java, built-in support for use with SCCS, CVS, and BitKeeper, supports .NET, and works with Linux, *BSD systems, Windows NT, and Mac OS X. I'd love something to would finally get rid of the awkward (no pun intended) make, and having a system based on Python would make it double good. Maybe one of the serious C/C++ programers here could give a verdict on if this is the dragon slayer we've been waiting for."
SCOns may have SCO's intellectual property!
They need to change the name.
Watching Cowboy Bebop in my jammies, eating a bowl of Shreddies.
Integrated Autoconf-like support for finding #include files, libraries, functions and typedefs.
Is SCons viewed as a replacement for Autoconf and Automake, or just a replacement for Make?
Built in support for...
What does this mean? Will SCons somehow only work with languages that SCons has built in support for?
How does SCons compare to Apache's Ant?
How am I supposed to know if I like the look and feel if there aren't any screenshots? :D
"Times have not become more violent. They have just become more televised."
-Marilyn Manson
Though i guess for now it only supports java - but there's nothing preventing you from writing custom tasks for it.
It's called Ant.
Daniel
Carpe Diem
Am I the only one who saw the title to this and thought is was another article about that sexy Darl McBride and his burgeoning company?
and thought "No thanks"
SB
It's old. The more humans I meet, the more I like my cats. At least they are honest.
I've been using make for like 10+ years. What exactly is the instability?
One thing I never liked about make was the dependence on whitespace in the makefile. Hopefully this Python-based solution will fi...uh never mind.
I predict Make will be around for a while still. I've used Ant but Make is fine for 90% of what I do.
Unfortunately it does not solve the problem. (Auto)Make's main problems are the lack of a robust syntax which would make it easier to give good error messages / feedback, the lack of a syntax that can easily be parsed and modified in IDEs and that it is far too complex for the casual developer / contributor. Most people want to program, not fiddle with the Make system. Scons may have some evolutionary improvements, but does not solve those issues. Actually replacing the make files by python scripts makes it only worse.
Ant solves the problem, but only for Java (admittedly building Java is much easier than C/C++).
I'd love something to would finally get rid of the awkward (no pun intended) make, and having a system based on Python would make it double good.
So now my C, C++, or Java programs can be dependent on yet another language runtime environment? Awesome!
Yes, there are limitations to Make, but why hasn't a genuinely better replacement materialized in the last twenty years and become truly widely adopted (in a manner like Perl, for example)?
Truth is, if you avoid fancy GNU extensions and stick to POSIX, make really isn't all the stuff people cry about.
Healthcare article at Kuro5hin
After spending several hours trying to get make to do something complicated with shared libraries and multiple configurations, I started looking for a replacement, and stumbled across SCONS. It took me a few moments to download and install it, and a very short time to go from no knowledge of the system to having solved my problem.
Since then I've shifted several of my projects to using SCONS as the build system. I'm sure it's theoretically possible to achieve what I was trying using make, but I wasted many hours wading through man pages and howtos without success, and SCONS did it with almost zero effort.
I haven't tried using it on Windows yet, but my understanding is that you can use the same script under both platforms.
So, just one data point, but my experience with it has been 100% positive.
-alyosha
A /. story about making out!
[rant-on]
make's syntax is so incredibly baroque. Its basically only to do one thing, but over the years its gotten so much crap stapled onto it that its a time trap. Add to that automake, which has to be layered on top just to keep make doing its job. Stop the madness!
[rant-off]
Nowadays I just write my build scripts in sh. Its on every platform. It takes less time in the long run because its a real programming language.
For example, in make when you want to do arcane-thing-X, you have to dig through the manual to figure out what feature is there to help you, then fret about whether you're only supporting GNU make, blah blah blah.
With sh you already know how to do anything since its a general purpose computing language with good support for groping files.
Spend some time to look at Scons. It's not a silver bullet, but it's a great step forward.
It can, among other things, generate Makefiles or Visual Studio project files, or run the build itself. It does have "autoconf" style checks, which you can embed in the sconstruct/makefile. It's built for parallel make from the start. It does not suffer from network clock skew.
And it has much better multiplatform support than any tool I've seen so far (automake/autoconf, make, qmake, tmake, cmake).
It will take time to mature, and it doesn't solve the problem, but it does makes things much better.
My SCons experience is that I like it a lot!
:-) The recursive GNU make system was developed in-house and was much more solid, but painfully slow and absolutely horrible to use. It required Cygwin (which is evil, IMO) tools and bizarre mappings from source control, so it was hard to convince other people in the company to build our project.
We use SCons at work to build a huge, highly componentized project with upwards of 5000 source files. It's hands down the best experience I've ever had for building large projects. The other two big projects I've been on used GNU make and Microsoft nmake, and neither was satisfactory.
The nmake-based system required running "nmake depends" before a build, and it simply wasn't reliable. Paranoia was high; when we hit a bug while developing, the first thing we did was a clean build, just to make sure we weren't looking at a build problem. (It was justified paranoia -- half of the time, it WAS a build problem
SCons was loads faster than our (admittedly bad) GNU make recursive build system, though noticably slower than our nmake build. With that cost, though, you get a correct build every time, something we never got in our "make depends" system. The paranoia is gone. SCons caches dependencies, so the cost for this accuracy isn't as bad as you might think. There were hiccups in the past, but the C++ dependency generation has been rock solid for at least nine months now.
I have a little toy project at home with maybe 25 source files which also uses SCons. I use MinGW's gcc at home, and SCons worked well with it "out of the box". Right now all I do is maintain a list of source files to build just like I would with any other system, but the setup was painless, and it's awesome to know that I can write Python to solve any problems I might hit later.
My big complaint with SCons is that a no-op build (running SCons when no source has changed) takes way too long on our big project, making iterative development painful. There's a command (-U) to build only components in a subtree of your file system, but that doesn't really speed things up much. Hopefully they can improve on that. That's about my only gripe, though.
Something similar/related is A-A-P from Bram Moolenaar of vim. A 1.0 version was just released last week. It is a make+Python kind of thing. There was short article about it at osdir a few months ago.
Larry
Has the scons site been slashdotted?
And I just checked out - Gentoo has an ebuild for it too. Go Gentoo!!
Nandz.
The jamfiles are easy to set up, and much faster to calculate dependencies -- I built freetype via gnu make and via jam. Jam was done building before make had even started compiling!
Also, props to perforce. It's proprietary (just like bitkeeper), kicks cvs's ass (just like bitkeeper), and is free for open source projects (just like bitkeeper). MySQL uses p4, IIRC. Unlike bitkeeper, you can get a single-seat version free (I use it for my internal projects, though CVS would probably suit my needs).
One thing I see is a lot of people referring to how slow and unreliable recursive makes are, and they're completely correct. However, you can make your life a lot easier by using make but getting rid of the recursion, using a make with an 'include' feature. See Recursive Make Considered Harmful for nice write up on why recursive makes don't work, and how to do it correctly.
I converted our build system, and no-op builds went from a few minutes to about 5 seconds. Really. If I change one file, all the necessary stuff gets rebuilt, and none of the unnecessary. Every time. With a little gmake if-then-else (all in one place, not scattered around in a bunch of files), the same Makefile and segments work on Linux, AIX, and Solaris. And while the organization of the files is a little unusual for those who are used to the recursive style, they are just makefiles, no new syntax.
The downside? It pretty much requires gmake, but since this particular product is proprietary, we control the build machines. I don't think you can use automake...but I consider that a positive :-). You could use autoconf -- just put all the config stuff in one makefile fragment, and include it into the master.
We switched away from Make a few years ago. I looked at jam and other make replacements before settling on Cons, the perl-based precursor of SCons. We are now in the process of switching over from Cons to SCons (slowly), and so far it is working very well.
We are using it on Windows (MSVC and Intel compilers), Linux, IRIX, and Mac OS X (gcc and two versions of CodeWarrior). Handles all of those with ease. It can do things like properly handle dependencies on auto-generated source and header files, which would be a nightmare in make.
Some things like error handling and documentation need some work, but overall it is very solid. Automatic dependency checking, parallel build support, autoconf-like stuff, switchable tools, and easy to extend.
Yes, it requires python, but will run on just about any version back to 1.5.2, and doesn't require any python add-ons, so it's not too onerous a requirement really.
So far I am very happy with it; I'd suggest checking it out if make is making you crazy.
-- Tristero
Everyone tries to replace make and freinds, and everybody fails. (Well, at least fails to be a true replacement that's actually better in every way). A few small tweaks aside, you can't really make serious design improvements to the standard unix make and related tools without taking some large tradeoffs that make it unacceptable for at least some uses. It's a very flexible tool as it stands, and it's hard to make it better without losing that flexibility.
11*43+456^2
I've used make/gnumake a lot for C/C++ and Java. I've used ant a lot for Java.
For a large primarily Java project ant is the hands down winner. It has two advantages over make. Out of the box, ant "knows" how to build java and java technologies. The same way that the make "knows" how to build C/C++ and UNIX style stuff. Sure you can do this in make but not without a lot of additional rules and setup... and it never feels as seamless as in ant. The second thing ant does is only use one java JVM to do the build. Each java compile happens in the same JVM that ant is running in. With make you are constantly reinvoking the JVM and it really slows things down.
gnumake's -j option (for executing jobs in parallel) doesn't work on windows... does SCons'? That might be the killer feature.
mmmmmmmmmmmm
Plan 9's new take on `make' is `mk'. Unfortunately, I wasn't able to find a good on-line source for the original paper on mk:
I seem to have no trouble finding things that reference this paper. The following might also be helpful:
There are so many of these... And this isn't going to change.
/bin/sh, you *know* it will exist on your target platform. I wouldn't hold my brath waiting for either makefiles or shell scripts to disappear any time soon.
:-)
The nice thing about SCons is that you code the "makefile" in Python instead of some build-tool specific language. Of course, that's also its main disadvantage. Build tool languages are typically nicer for this specific problem domain. Not to mention you need to install the Python run-time environment first. Well, not everybody wants to install it just for the sake of a build script.
As for its other claims to fame, there's nothing new about them. All modern build tools (and there are many) do away with "recursive make", "make depend" etc. This has been the case for more than a decade now. Comparing a new build tool with this crude method is the equivalent of a car maker coming out with a new model whose claim to fame is having airbags and ABS. Yawn.
The only reason that (reasonable) people use make is portability; like
I doubt SCons is better than cake, jam or cook (to name a few example). There was also the original Cons which had the same idea as SCons but was based on Perl instead of Python; Ant that does the same thing with XML and Java. None have even made a dent in plain old make.
We are stuck with makefiles for almost anything that needs to be delivered as an open source project, regardless of size. I'd probably use GNU make for the larger projects. While GNU make isn't quite up to the task, it is common enough to be acceptable and advanced enough that the pain is tolerable. That is, as long as you do *NOT* use it recursively. Recursive make is an abomination.
For serious in-house projects I personally prefer to use cook, since I'd want to use Aegis as well and cook is the best match for it. Cook is really a great build tool independently from Aegis. It is just that their combination is such an amazingly useful development framework that if you hit on one you usually end up sucked into using the other as well
Of course, most people couldn't care less; in fact, most people use the Visual Studio build system. It makes recursive make look advanced!
I've used SCons in two projects so far, an OS kernel and something for work. Its absolutely awesome. The kernel bit was extremely telling. You can't compile a kernel just like any old userspace program. You have to use special linker scripts and compiler options. Further, the compiler I'm using (Intel C++) allows a special optimization mode that requires a few changes to the usual compile/link process. Implementing support for all that would have been very complex with makefiles. With SCons, the Python code that implements configuration management (deciding what files to build based on features included in the kernel) and software installation (installing headers and binaries to appropriate places in the filesystem) is only 200 lines of code in all. Autoconf-generated Makefiles for a single directory can be larger than that! Having a full programming language on hand when you need it (in my setup, even config files are regular old Python scripts) is very powerful.
A deep unwavering belief is a sure sign you're missing something...