BoxFactory Development Log 2

In this entry, I introduce BoxFactory through a bit of history and a NAQ (Never Asked Questions).

In with BoxFactory

We always joked that we should write a build system instead of using CMake, as this would be easier than work around its limitations. This is not a joke anymore, as I set myself to actually work on a build system for our needs.

A little bit of history

BoxFactory started as a small bash script I hardcoded for fun to try building something without make or anything. It was nothing more than the series of commands I entered to build my test program. Starting from that, I de-hardcoded some parts of it and made it loop on *.cpp files from the JsonBox project. It worked surprisingly well for a project without much dependencies.

Then I started separating parts of that small script to make it more manageable. This is when BoxFactory started. I separated the things that are about the project itself in a file that is sourced by the BoxFactory main script and put only the generic parts in the BoxFactory script. This was the first commit.

The current state

This is when I started making more changes to have it work with modules. This means that BoxFactory could actually work with more than only C++ applications, but for now it is still pretty much hardcoded to our needs. It might work for you if you are building static libraries or an application entirely in C++, but not much more.

The future

The C++ module will need some work to actually only do the compilation part. I will need a linking module that can link anything that is a proper .o file. Then a C module. The C and C++ module will be pretty much the same thing though.

Then the modules will need to actually work with multiple compilers. This means that the flags that are currently put as cc-style flags in the instructions file will need to be parameters that the module will need to work with to translate across the different kind of compilers (cc-like and VC for now). The same thing will be needed for the linker part. It works currently with ar, but this will need to change for Microsoft's linker.

Never Asked Questions

Why bash?

Why not? It had to be written in something. We could have made it with C/C++, but it would have been counter-productive for my quick prototyping work-flow as I am not as accustomed to those languages as I would want.

I looked at other scripting languages, but they all had a drawback: Adoption. I want a build system that is completely language agnostic. This means that having a Python project built with a Ruby script (or vice versa) looked weird to me. Furthermore, the only popular scripting language I master, other than bash, would be PHP and I know that it would not have been well-received with PHP. It also complicated deployment because I would have probably used PHP 5.3 features.

It left bash. Bash is already deployed on the vast majority of Unix-like systems, or it is easily deployable. Working with bash and not sh-only scripts helps a lot with some headaches that shell scripts causes; Bash can be configured to be surprisingly strict.

This leaves Windows, which is not a Unix-like system. On that platform, there are two popular POSIX-like subsystems, Cygwin and MSYS. We already were using MSYS, so I knew what it would be like. We will support MSYS at first. I do not think that there will be problems with Cygwin, but if there are, they will be low priority problems, as long as it works with MSYS.

In the end, I have to work with Bash version 3.1; from the surveying I did, this is the oldest version found on supported systems. MSYS uses 3.1, Cygwin 4.1, Recent Linux systems generally uses 4.x, Mac OS X uses 3.2 from at least 10.6.

Bash 3.1 has everything needed for a complicated system. To be even more portable across platforms, BoxFactory itself has to rely on a minimum of system binaries. This means that I have to use bash builtins and make bash functions that replicates things I would need from external utilities. This makes it more bulletproof, as sometimes different implementations will have different behaviour.

When will I be able to …

I don't know. My time is currently constrained and I might not have time to do things that we don't need right now, but if it is either easy or useful for us, it might be implemented! Also bear in mind that this is bash scripts, I should be easy to add features and send pull requests. I will evaluate them and if they follow the general philosophy of BoxFactory, will be integrated.