fast-cli/build.zig
Caeser af4d3971c9
Updated to zig 0.15.1 and zli 4.1.0
* Refactor: Update build process and improve memory management

- Commented out library tests in build.zig for clarity.
- Changed minimum Zig version to 0.15.1 in build.zig.zon.
- Modified root.zig to accept a Writer for output instead of using log.
- Updated bandwidth.zig tests to use std.Thread.sleep for consistency.
- Adjusted fast.zig to improve memory allocation handling.
- Enhanced http_latency_tester.zig to manage latencies with allocator.
- Refined speed_worker.zig to utilize std.Thread.sleep for delays.
- Improved measurement_strategy.zig to handle speed measurements with allocator.
- Updated main.zig to flush writer after command execution.

* Fix: Update zli dependency to use URL and hash instead of path

* Fix: Add newline to spinner output for better readability

* switch worksflows to using zig 0.15.1

---------

Co-authored-by: mikkelam <mikkelarm@gmail.com>
2025-11-17 13:42:35 +00:00

79 lines
2.9 KiB
Zig

const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// // library tests
// const library_tests = b.addTest(.{
// .root_source_file = b.path("src/test.zig"),
// .target = target,
// .optimize = optimize,
// });
// const run_library_tests = b.addRunArtifact(library_tests);
// const test_step = b.step("test", "Run all tests");
// test_step.dependOn(&run_library_tests.step);
const dep_zli = b.dependency("zli", .{
.target = target,
});
const mod_zli = dep_zli.module("zli");
const dep_mvzr = b.dependency("mvzr", .{
.target = target,
.optimize = optimize,
});
const mod_mvzr = dep_mvzr.module("mvzr");
// Create build options for version info
const build_options = b.addOptions();
// Read version from build.zig.zon at compile time
const build_zon_content = @embedFile("build.zig.zon");
const version = blk: {
// Simple parsing to extract version string
const start = std.mem.indexOf(u8, build_zon_content, ".version = \"") orelse unreachable;
const version_start = start + ".version = \"".len;
const end = std.mem.indexOfPos(u8, build_zon_content, version_start, "\"") orelse unreachable;
break :blk build_zon_content[version_start..end];
};
build_options.addOption([]const u8, "version", version);
const exe = b.addExecutable(.{
.name = "fast-cli",
.root_module = b.createModule(.{
// b.createModule defines a new module just like b.addModule but,
// unlike b.addModule, it does not expose the module to consumers of
// this package, which is why in this case we don't have to give it a name.
.root_source_file = b.path("src/main.zig"),
// Target and optimization levels must be explicitly wired in when
// defining an executable or library (in the root module), and you
// can also hardcode a specific target for an executable or library
// definition if desireable (e.g. firmware for embedded devices).
.target = target,
.optimize = optimize,
}),
});
exe.root_module.addImport("zli", mod_zli);
exe.root_module.addImport("mvzr", mod_mvzr);
exe.root_module.addImport("build_options", build_options.createModule());
// library_tests.root_module.addImport("mvzr", mod_mvzr);
// Link against the static library instead
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// b.default_step.dependOn(test_step); // Disabled for cross-compilation
}