Installation & Setup
Lighting requires Zig 0.17 (or master build compatible with the 0.17 API release).
Adding to build.zig.zon
To declare Lighting as a dependency in your Zig project, add it to your build.zig.zon:
.{
.name = .my_web_app,
.fingerprint = 0x8a9e1029c374b5fa, // Run `zig build` to generate/update
.version = "0.1.0",
.dependencies = .{
.lighting = .{
.url = "git+https://github.com/jiacai2050/lighting.git#main",
.hash = "...", // Generated by `zig build` or `zig fetch`
},
},
.paths = .{
"build.zig",
"build.zig.zon",
"src",
},
}
You can automatically resolve and pin the hash by running:
zig fetch --save git+https://github.com/jiacai2050/lighting.git
Integrating with build.zig
In your root build.zig, expose the lighting module to your executable target:
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Obtain the lighting dependency
const lighting_dep = b.dependency("lighting", .{
.target = target,
.optimize = optimize,
});
const lighting_mod = lighting_dep.module("lighting");
// Add executable
const exe = b.addExecutable(.{
.name = "my_web_app",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "lighting", .module = lighting_mod },
},
}),
});
b.installArtifact(exe);
}