Something went wrong. Try again.
htop for your network: a real-time IP traffic monitor for the terminal, ported to Zig from iptop
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us>// SPDX-License-Identifier: MIT
const std = @import("std");const package = @import("build.zig.zon");
pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{});
// The version lives in build.zig.zon and reaches `--version` from there, // so there is only one place to change it. const build_info = b.addOptions(); build_info.addOption([]const u8, "version", package.version);
const vaxis = b.dependency("vaxis", .{ .target = target, .optimize = optimize, }).module("vaxis");
// The HTTP client that asks ip-api.com where an address is and ipify what // the public address is. const http = b.dependency("http", .{ .target = target, .optimize = optimize, });
// Reverse lookups, so that a remote host is shown by name. const dns_client = b.dependency("dns_client", .{ .target = target, .optimize = optimize, }).module("dns_client");
// Telling a private or link-local address from one worth locating. const z46 = b.dependency("z46", .{ .target = target, .optimize = optimize, }).module("z46");
// The time zone for the clock in the title bar. const datetime = b.dependency("datetime", .{ .target = target, .optimize = optimize, }).module("datetime");
const exe = b.addExecutable(.{ .name = "ziptop", .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "vaxis", .module = vaxis }, .{ .name = "http", .module = http.module("http") }, .{ .name = "http_io", .module = http.module("http_io") }, .{ .name = "dns_client", .module = dns_client }, .{ .name = "z46", .module = z46 }, .{ .name = "datetime", .module = datetime }, .{ .name = "build_info", .module = build_info.createModule() }, }, }), }); b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); run_cmd.addPassthruArgs(); const run_step = b.step("run", "Run ziptop"); run_step.dependOn(&run_cmd.step);
// Regenerates src/worldmap_data.zig from the polygons; see the tool for // where to get them. Built for the machine running the build, never for // whatever -Dtarget the program is being built for, and only when this // step or `check` asks for it. const geojson = b.dependency("geojson", .{ .target = b.graph.host, .optimize = .ReleaseSafe, }).module("geojson"); const worldmap = b.addExecutable(.{ .name = "worldmap", .root_module = b.createModule(.{ .root_source_file = b.path("tools/worldmap.zig"), .target = b.graph.host, .optimize = .ReleaseSafe, .imports = &.{.{ .name = "geojson", .module = geojson }}, }), }); const run_worldmap = b.addRunArtifact(worldmap); run_worldmap.addPassthruArgs(); run_worldmap.stdio = .inherit; const worldmap_step = b.step("worldmap", "Rasterize country polygons into src/worldmap_data.zig (pass the two JSON files)"); worldmap_step.dependOn(&run_worldmap.step);
// The self-hosted backend, which Debug uses by default, emits no coverage // instrumentation, so kcov reports nothing at all against it. LLVM does. const exe_tests = b.addTest(.{ .root_module = exe.root_module, .use_llvm = true, }); const test_step = b.step("test", "Run tests"); test_step.dependOn(&b.addRunArtifact(exe_tests).step);
// Compiles everything without running it, for an editor's build-on-save. const check_step = b.step("check", "Check that everything compiles"); check_step.dependOn(&exe.step); check_step.dependOn(&exe_tests.step); check_step.dependOn(&worldmap.step);}