mod: remove dependency to c std library and replace with ztime dependency for a pure zig implementation
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 57s

This commit is contained in:
2024-11-30 14:45:57 +01:00
parent 06752299be
commit df515b8cad
3 changed files with 17 additions and 19 deletions

View File

@@ -27,14 +27,19 @@ pub fn build(b: *std.Build) void {
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
const ztime_dependency = b.dependency("ztime", .{
.target = target,
.optimize = optimize,
});
const zlog_module = b.addModule("zlog", .{
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = b.path("src/zlog.zig"),
.target = target,
.optimize = optimize,
.link_libc = include_timestamp, // uses c std library <time.h>
});
zlog_module.addImport("ztime", ztime_dependency.module("ztime"));
zlog_module.addImport("build_options", options_module);
const exe = b.addExecutable(.{
@@ -43,6 +48,7 @@ pub fn build(b: *std.Build) void {
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("ztime", ztime_dependency.module("ztime"));
exe.root_module.addImport("zlog", zlog_module);
// This declares intent for the executable to be installed into the
@@ -50,17 +56,6 @@ pub fn build(b: *std.Build) void {
// step when running `zig build`).
b.installArtifact(exe);
const exe_check = b.addExecutable(.{
.name = "check",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe_check.root_module.addImport("zlog", zlog_module);
const check = b.step("check", "Check if project compiles");
check.dependOn(&exe_check.step);
// This *creates* a Run step in the build graph, to be executed when another
// step is evaluated that depends on it. The next line below will establish
// such a dependency.
@@ -91,6 +86,8 @@ pub fn build(b: *std.Build) void {
.target = target,
.optimize = optimize,
});
lib_unit_tests.root_module.addImport("ztime", ztime_dependency.module("ztime"));
lib_unit_tests.root_module.addImport("build_options", options_module);
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);