make sunriset available as a module

This commit is contained in:
Emil Lerch 2026-01-06 19:35:53 -08:00
parent ddd6f3b61f
commit 5c1d6f41e6
Signed by: lobo
GPG key ID: A7B62D657EF764F8
2 changed files with 27 additions and 0 deletions

View file

@ -19,6 +19,28 @@ pub fn build(b: *std.Build) void {
const maxminddb_upstream = b.dependency("maxminddb", .{});
// Build sunriset as a static library
const sunriset = b.addLibrary(.{
.name = "sunriset",
.linkage = .static,
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
}),
});
sunriset.addIncludePath(b.path("libs/sunriset"));
sunriset.addCSourceFiles(.{
.root = b.path("libs/sunriset"),
.files = &.{
"sunriset.c",
},
.flags = &.{ "-D_DEFAULT_SOURCE", "-DSUNRISET_NO_MAIN" },
});
sunriset.linkLibC();
sunriset.linkSystemLibrary("m");
// Build phoon as a static library
const phoon = b.addLibrary(.{
.name = "phoon",
@ -98,9 +120,11 @@ pub fn build(b: *std.Build) void {
exe.root_module.addOptions("build_options", build_options);
exe.root_module.addIncludePath(maxminddb_upstream.path("include"));
exe.root_module.addIncludePath(b.path("libs/phoon_14Aug2014"));
exe.root_module.addIncludePath(b.path("libs/sunriset"));
exe.root_module.addConfigHeader(maxminddb_config);
exe.linkLibrary(maxminddb);
exe.linkLibrary(phoon);
exe.linkLibrary(sunriset);
exe.linkLibC();
b.installArtifact(exe);
@ -135,9 +159,11 @@ pub fn build(b: *std.Build) void {
tests.root_module.addOptions("build_options", test_options);
tests.root_module.addIncludePath(maxminddb_upstream.path("include"));
tests.root_module.addIncludePath(b.path("libs/phoon_14Aug2014"));
tests.root_module.addIncludePath(b.path("libs/sunriset"));
tests.root_module.addConfigHeader(maxminddb_config);
tests.linkLibrary(maxminddb);
tests.linkLibrary(phoon);
tests.linkLibrary(sunriset);
tests.linkLibC();
const run_tests = b.addRunArtifact(tests);

View file

@ -19,6 +19,7 @@
.hash = "zeit-0.6.0-5I6bk36tAgATpSl9wjFmRPMqYN2Mn0JQHgIcRNcqDpJA",
},
.phoon = .{ .path = "libs/phoon_14Aug2014" },
.sunriset = .{ .path = "libs/sunriset" },
},
.fingerprint = 0x710c2b57e81aa678,
.minimum_zig_version = "0.15.2",