Help with build file changes for 0.15

I wanted to try latest Zig to see if I can replicate the problem I found with multi-dimensional array blit on my PinePhone hardware. But I cant find documentation or info on the new build system. It was hard enough to solve this for 0.14.0, but without any examples online I 'm a bit lost.

Can someone show me the new magics required to port the following build script please?

const std = @import("std");

pub fn build(b: *std.Build) void {
    const elf = b.addExecutable(.{
        .name = "pp.elf",
        .optimize = .ReleaseSmall,
        .single_threaded = true,
        .root_source_file = b.path("main.zig"),
        .target = b.resolveTargetQuery(.{
            .cpu_arch = .aarch64,
            .os_tag = .freestanding,
            .abi = .none,
            .cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_a53 },
        }),
    });
    elf.addAssemblyFile(b.path("pp.S"));
    //elf.addCSourceFile(b.path("framebuffers.c"));
    elf.setLinkerScript(b.path("linker.ld"));

    const elfCopy = b.addInstallArtifact(elf, .{});
    b.default_step.dependOn(&elfCopy.step);

    const hex = elf.addObjCopy(.{
        .format = .bin,
    });
    b.default_step.dependOn(&elfCopy.step);

    const hexCopy = b.addInstallBinFile(hex.getOutput(), "pp.bin");
    b.default_step.dependOn(&hexCopy.step);
}

Well, what do the compile errors tell you when you run zig build? And have you tried applying any fixes yourself?

The build system hasn’t changed a lot between 0.14.0 and now, other than that some APIs that were clearly marked as deprecated have now been removed. In particular, you might want to take a look at 0.14.0 Release Notes - Creating Artifacts from Existing Modules and follow the guidance for how to update .root_source_file = b.path(...) to root_module = b.createModule(...).

Try this:

const elf = b.addExecutable(.{
    .name = "pp.elf",
    .root_module = b.createModule(.{
        .root_source_file = b.path("main.zig"),
        .target = b.resolveTargetQuery(.{
            .cpu_arch = .aarch64,
            .os_tag = .freestanding,
            .abi = .none,
            .cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_a53 },
        }),
        .optimize = .ReleaseSmall,
        .single_threaded = true,
    }),
});

Thanks both, I’ll have another look. I followed what I thought was the official build system documentation, and what few examples are dotted around the net.

I wasnt aware of modules being a mandatory part of the build process now. I thought they were being added for external dependency management. Always learning :slight_smile:

I did try to fight the compiler, but by design it isnt going to tell me what has been deprecated and what to try. I deduced b.release_mode = .small based on what little I could see in the standard library pages. But even that seems wrong, so I am happy I asked.

Are there release notes for 0.15.0 tucked away somewhere? They seem like a treasure trove of information!

[Edit - 0.15.0 goodies unlocked, thanks!]

Honestly, I find myself just right-clicking something like addExecutable in my IDE and looking at the definition. Then I see it wants ExecutableOptions, which in turn wants a Module. Code as docs, I guess…

Thanks for the tip, my editor was not that well connected. So I just installed Kate to try again with ZLS (assuming that is what you are using?), but I am not sure if ZLS is avail for 0.15.0 at least from the zigtools site, assuming that is the kinda official ZLS.

It’s a bit odd: you need to enter an exact Zig version on zigtools, e.g. 0.15.0-dev.1254+c9ce1debe.