Fix build.zig

This commit is contained in:
jaina heartles 2022-07-09 15:03:57 -07:00
parent 04d83a603c
commit ce08b76cdc

View file

@ -1,18 +1,5 @@
const std = @import("std"); const std = @import("std");
const static_libs = [_][]const u8{
"util",
"http",
};
fn createLibs(b: *std.build.Builder) [static_libs.len]*std.build.LibExeObjStep {
var libs: [static_libs.len]*std.build.LibExeObjStep = undefined;
inline for (static_libs) |name, i| {
libs[i] = b.addStaticLibrary(name, "src/" ++ name ++ "/lib.zig");
}
return libs;
}
fn addRunStep(b: *std.build.Builder, exe: *std.build.LibExeObjStep) void { fn addRunStep(b: *std.build.Builder, exe: *std.build.LibExeObjStep) void {
const run_cmd = exe.run(); const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep()); run_cmd.step.dependOn(b.getInstallStep());
@ -39,10 +26,17 @@ pub fn build(b: *std.build.Builder) void {
exe.setTarget(target); exe.setTarget(target);
exe.setBuildMode(mode); exe.setBuildMode(mode);
var libs = createLibs(b); const util = std.build.Pkg{
for (libs) |lib| { .name = "util",
exe.linkLibrary(lib); .source = std.build.FileSource.relative("src/util/lib.zig"),
} };
const http = std.build.Pkg{
.name = "http",
.source = std.build.FileSource.relative("src/http/lib.zig"),
.dependencies = &[_]std.build.Pkg{util},
};
exe.addPackage(util);
exe.addPackage(http);
exe.install(); exe.install();
addRunStep(b, exe); addRunStep(b, exe);