On Sunday, 12 June 2016 at 20:03:06 UTC, Walter Bright wrote:
On 6/3/2016 1:26 AM, Dicebot wrote:
From that perspective, the best build system you could possibly have would look
like this:

```
#!/usr/bin/rdmd

import std.build;

// define your build script as D code
```

Yeah, I have often thought that writing a self-contained D program to build D would work well. The full power of the language would be available, there'd be nothing new to learn, and all you'd need is an existing D compiler (which we already require to build).

The core functionality of Button could be split off into a library fairly easily and there would be no dependency on Lua. Using it might look something like this:

import button;

immutable Rule[] rules = [
    {
        inputs: [Resource("foo.c"), Resource("baz.h")],
task: Task([Command(["gcc", "-c", "foo.c", "-o", "foo.o"])]),
        outputs: [Resource("foo.o")]
    },
    {
        inputs: [Resource("bar.c"), Resource("baz.h")],
task: Task([Command(["gcc", "-c", "bar.c", "-o", "bar.o"])]),
        outputs: [Resource("bar.o")]
    },
    {
        inputs: [Resource("foo.o"), Resource("bar.o")],
task: Task([Command(["gcc", "foo.o", "bar.o", "-o", "foobar"])]),
        outputs: [Resource("foobar")]
    }
];

void main()
{
    build(rules);
}

Of course, more abstractions would be added to make creating the list of rules less verbose.

However, I question the utility of even doing this in the first place. You miss out on the convenience of using the existing command line interface. And for what? Just so everything can be in D? Writing the same thing in Lua would be much prettier. I don't understand this dependency-phobia.

Reply via email to