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 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 {
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
@ -39,10 +26,17 @@ pub fn build(b: *std.build.Builder) void {
exe.setTarget(target);
exe.setBuildMode(mode);
var libs = createLibs(b);
for (libs) |lib| {
exe.linkLibrary(lib);
}
const util = std.build.Pkg{
.name = "util",
.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();
addRunStep(b, exe);