Building on swift build

I made a little experimental build tool which sits on top of swift build and allows you to do some of the things (settings, custom build phases) that are arguably missing from the non-Xcode build experience.

I’ve written a bit about it here, or you can go straight to the code.

I’m not at all confident that it’s the way to go, but I’d be interested in any feedback. I guess you could think of this as a pitch for a pre-proposal proposal (or something).

3 Likes

Nice. Thank you for doing this.

1 Like

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

I got distracted by various other projects, but I’ve been tinkering around a bit more with this recently - with a view to adding some sort of rudimentary resource packaging to it.

I’ll probably write that up in a future blog post, but before doing that I went back and blogged a little more detail about the stuff I’ve done so far.

2 Likes