Able to access the zon.flags string array thing from within build.zig?

I want to have dynamic module .flags values, so

I put them in the build.zig.zon and do:

// the zon part:
.flags = .{
    "-std=c99",
    "-I/usr/local/include",
    "-I/home/wise/code/zig/zweb/csrc",
},

To access them inside my build.zig.

and then I do

// this is in build.zig

const zon = @import("build.zig.zon");

...
    myfcgi.addCSourceFile(.{
        .file = b.path("csrc/myfcgi.c"),
        .flags = zon.flags,
    });
...

But it’s types do no match up. Is there a way I can wrangle the .flags list from

the zon file to match the .flags struct member getting passed to .addCSourceFile() ?

This is the type signature for that:

I am still learning zig and the idioms.

You can use this method to convert such a tuple into []const[]const u8.

    const zon = @import("build.zig.zon");
    const flags: [zon.flags.len][]const u8 = zon.flags;
    myfcgi.addCSourceFile(.{
        .file = b.path("csrc/myfcgi.c"),
        .flags = &flags,
    });
1 Like

Hah!
Thanks, that is very helpful.