Building on swift build

The upcoming extensible build tools proposal may well make this experiment obsolete, but I've been continuing to tinker around with it anyway, for my own amusement.

I've split the example out into a separate repo, which illustrates how it's nicely able to pull in its own tool dependencies, including builder itself.

I've also worked a bit on a cleaner way to specify settings and schemes/actions, using a similar style of syntax to Packages:

import BuilderConfiguration

let settings = Settings(schemes: [
    .scheme(
        name: "common",
        swift: ["Dexample"],
        inherits: [
            .scheme(name: "mac", filter: ["macOS"]),
            .scheme(name: "debug", filter: ["debug"])
        ]
    ),
    .scheme(
        name: "mac",
        swift: ["target", "x86_64-apple-macosx10.12"]
    ),
    .scheme(
        name: "debug",
        swift: ["Onone"]
    )
    ]
)

let configuration = Configuration(
    settings: settings,
    actions: [
        .action(name:"build", phases:[
            .toolPhase(name:"Preparing", tool: "BuilderToolExample"),
            .buildPhase(name:"Building", target:"Example"),
            .toolPhase(name:"Packaging", tool: "BuilderToolExample", arguments:["blah", "waffle"]),
            ]),
        .action(name:"test", phases:[
            .testPhase(name:"Testing", target:"Example"),
            ]),
        .action(name:"run", phases:[
            .actionPhase(name:"Building", action: "build"),
            .toolPhase(name:"Running", tool: "run", arguments:["Example"]),
            ]),
    ]
)

configuration.outputToBuilder()

It would still be far better to be able to hook directly into llbuild, which is what the extensible build tools proposal is aiming for, but in the meantime...

1 Like