The issue

As all of you probably don’t know, I mantain a series of PKGBUILD’s in the AUR arch repository, most of them related to the D language, version 2.

The D language is great (I have already written about it before), but the still-a-bit-in-development version 2 has  one maintenance problem for me: 3 compilers, the official dmd, the gcc-based gdc, and the LLVM-based ldc. Thing is, you must compile a library with the compiler you’re gonna use in your project (I think, I might be wrong, with those ‘runtime’ rumors I keep hearing). Even without this, you don’t need dmd if you have gdc installed, so forcing the user to install one compiler or the other just so they can use gtkD with their project doesn’t sound too good.

Anyway, I have written in D2 a small script, d2-config, that helps me with the rest of D2 packages. Instead of depending on one compiler or the other, I can now depend only on d2-config, knowing the user must have at least one working compiler along with it. It

By the way, it’s inspired by the gcc-config from Gentoo, although used for a different task.

The workings

 All three compilers have a compatible command-line interface (a wrapper in two of the cases), so the script just manages a symbolic link to the default compiler.

It may be called in three ways:

d2-config [-h|–help]:  shows the usage and usual help
d2-config <-l|–list>:   shows a list of the installed compilers, with an ‘*’ before the current default one.
d2-config <-c|–change>=NUM: switches the current default one to the NUMth one in the list.

As simple as that.