|
|
|
@ -1,59 +1,60 @@
|
|
|
|
|
const std = @import("std");
|
|
|
|
|
|
|
|
|
|
const bin_dir = "bin";
|
|
|
|
|
const build_dir = "build";
|
|
|
|
|
const VERSION = "0.1.5";
|
|
|
|
|
|
|
|
|
|
pub fn build(b: *std.build.Builder) void {
|
|
|
|
|
// Standard release options allow the person running `zig build` to select
|
|
|
|
|
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
|
|
|
|
// const mode = b.standardReleaseOptions();
|
|
|
|
|
// const mode = std.builtin.Mode.Debug;
|
|
|
|
|
const mode = std.builtin.Mode.ReleaseSmall;
|
|
|
|
|
// Although this function looks imperative, note that its job is to
|
|
|
|
|
// declaratively construct a build graph that will be executed by an external
|
|
|
|
|
// runner.
|
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
|
|
|
// Standard target options allows the person running `zig build` to choose
|
|
|
|
|
// what target to build for. Here we do not override the defaults, which
|
|
|
|
|
// means any target is allowed, and the default is native. Other options
|
|
|
|
|
// for restricting supported target set are available.
|
|
|
|
|
const target = b.standardTargetOptions(.{});
|
|
|
|
|
|
|
|
|
|
const ipcd_exe = b.addExecutable("ipcd", "apps/ipcd.zig");
|
|
|
|
|
ipcd_exe.addPackagePath("ipc", "./src/ipc.zig");
|
|
|
|
|
ipcd_exe.setOutputDir(bin_dir);
|
|
|
|
|
ipcd_exe.linkLibC();
|
|
|
|
|
ipcd_exe.setBuildMode(mode);
|
|
|
|
|
ipcd_exe.install();
|
|
|
|
|
// Standard optimization options allow the person running `zig build` to select
|
|
|
|
|
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
|
|
|
|
|
// set a preferred release mode, allowing the user to decide how to optimize.
|
|
|
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
|
|
|
|
|
|
const tcpd_exe = b.addExecutable("tcpd", "apps/tcpd.zig");
|
|
|
|
|
tcpd_exe.addPackagePath("ipc", "./src/ipc.zig");
|
|
|
|
|
tcpd_exe.setOutputDir(bin_dir);
|
|
|
|
|
tcpd_exe.linkLibC();
|
|
|
|
|
tcpd_exe.setBuildMode(mode);
|
|
|
|
|
tcpd_exe.install();
|
|
|
|
|
const lib = b.addStaticLibrary(.{
|
|
|
|
|
.name = "ipc",
|
|
|
|
|
// 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 = .{ .path = "src/bindings.zig" },
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const pong_exe = b.addExecutable("pong", "apps/pong.zig");
|
|
|
|
|
pong_exe.addPackagePath("ipc", "./src/ipc.zig");
|
|
|
|
|
pong_exe.setOutputDir(bin_dir);
|
|
|
|
|
pong_exe.linkLibC();
|
|
|
|
|
pong_exe.setBuildMode(mode);
|
|
|
|
|
pong_exe.install();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const pongd_exe = b.addExecutable("pongd", "apps/pongd.zig");
|
|
|
|
|
pongd_exe.addPackagePath("ipc", "./src/ipc.zig");
|
|
|
|
|
pongd_exe.setOutputDir(bin_dir);
|
|
|
|
|
pongd_exe.linkLibC();
|
|
|
|
|
pongd_exe.setBuildMode(mode);
|
|
|
|
|
pongd_exe.install();
|
|
|
|
|
|
|
|
|
|
const lib = b.addStaticLibrary("ipc", "src/bindings.zig");
|
|
|
|
|
lib.setOutputDir(build_dir);
|
|
|
|
|
// Link with the libc of the target system since the C allocator
|
|
|
|
|
// is required in the bindings.
|
|
|
|
|
lib.linkLibC();
|
|
|
|
|
lib.setBuildMode(mode);
|
|
|
|
|
|
|
|
|
|
// This declares intent for the library to be installed into the standard
|
|
|
|
|
// location when the user invokes the "install" step (the default step when
|
|
|
|
|
// running `zig build`).
|
|
|
|
|
lib.install();
|
|
|
|
|
|
|
|
|
|
const solib = b.addSharedLibrary("ipc", "src/bindings.zig", b.version(0, 1, 0));
|
|
|
|
|
solib.setOutputDir(build_dir);
|
|
|
|
|
const solib = b.addSharedLibrary(.{
|
|
|
|
|
.name = "ipc",
|
|
|
|
|
.root_source_file = .{ .path = "src/bindings.zig" },
|
|
|
|
|
.version = comptime (try std.builtin.Version.parse(VERSION)),
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
});
|
|
|
|
|
solib.linkLibC();
|
|
|
|
|
solib.setBuildMode(mode);
|
|
|
|
|
solib.install();
|
|
|
|
|
|
|
|
|
|
const main_tests = b.addTest("src/main.zig");
|
|
|
|
|
main_tests.setBuildMode(mode);
|
|
|
|
|
// Creates a step for unit testing.
|
|
|
|
|
const main_tests = b.addTest(.{
|
|
|
|
|
.root_source_file = .{ .path = "src/main.zig" },
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// This creates a build step. It will be visible in the `zig build --help` menu,
|
|
|
|
|
// and can be selected like this: `zig build test`
|
|
|
|
|
// This will evaluate the `test` step rather than the default, which is "install".
|
|
|
|
|
const test_step = b.step("test", "Run library tests");
|
|
|
|
|
test_step.dependOn(&main_tests.step);
|
|
|
|
|
}
|
|
|
|
|