Per-Build Config

The following options can be set on a per-project basis by placing zls.build.json in the project root directory next to build.zig.

OptionTypeDefault valueWhat it Does
relative_builtin_path?[]const u8nullIf present, this path is used to resolve @import("builtin")
build_options?[]BuildOptionnullIf present, this contains a list of user options to pass to the build. This is useful when options are used to conditionally add packages in build.zig.

The file must be valid JSON which cannot contain comments or trailing commas.

BuildOption

BuildOption is defined as follows:

const BuildOption = struct {
    name: []const u8,
    value: ?[]const u8 = null,
};

When value is present, the option will be passed the same as in zig build -Dname=value. When value is null, the option will be passed as a flag instead as in zig build -Dflag.

Example

{
    "build_options": [
        {
            "name": "target",
            "value": "templeos-armless"
        },
        {
            "name": "single-threaded",
            "value": "false"
        },
        {
            "name": "use-llvm"
        }
    ]
}

The example above will translate into the following CLI arguments:

zig build -Dtarget=templeos-armless -Dsingle-threaded=false -Duse-llvm