libipc-examples/zig/build.zig

91 lines
3.3 KiB
Zig
Raw Normal View History

const std = @import("std");
2024-06-14 16:20:37 +02:00
const module = std.Build.Module;
2024-06-14 16:20:37 +02:00
//fn link_and_install(exe : *std.Build.CompileStep) void {
// const source_file = std.Build.FileSource.relative("./lib/ipc/src/main.zig");
// // var empty : []const std.Build.ModuleDependency = &.{};
// exe.addModule("ipc", .{ .source_file = source_file, .dependencies = &.{} });
// exe.linkLibC();
//
// // This declares intent for the executable to be installed into the
// // standard location when the user invokes the "install" step (the default
// // step when running `zig build`).
// exe.install();
//}
// 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(.{});
// 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(.{});
2024-06-14 16:20:37 +02:00
const ipc_static_lib = b.addStaticLibrary(.{
.name = "ipc",
.optimize = optimize,
.target = target,
2024-06-14 16:20:37 +02:00
.root_source_file = b.path("./lib/ipc/src/main.zig")
});
2024-06-14 16:20:37 +02:00
// const ipc_module = b.dependency("ipc", .{}).module("ipc");
// ipc_module.linkSystemLibrary("ipc", .{ .needed = true });
2024-06-14 16:20:37 +02:00
const ipcd_exe = b.addExecutable(.{
.name = "ipcd",
.root_source_file = .{ .path = "src/ipcd.zig" },
.target = target,
.optimize = optimize,
});
2024-06-14 16:20:37 +02:00
ipcd_exe.linkLibrary(ipc_static_lib);
b.installArtifact(ipc_static_lib);
ipcd_exe.linkSystemLibrary("ipc");
ipcd_exe.linkLibC();
b.installArtifact(ipcd_exe);
//
// const tcpd_exe = b.addExecutable(.{
// .name = "tcpd",
// .root_source_file = .{ .path = "src/tcpd.zig" },
// .target = target,
// .optimize = optimize,
// });
// // tcpd_exe.addModule("ipc", module.CreateOptions);
// tcpd_exe.linkLibC();
// b.installArtifact(tcpd_exe);
//
// const pong_exe = b.addExecutable(.{
// .name = "pong",
// .root_source_file = .{ .path = "src/pong.zig" },
// .target = target,
// .optimize = optimize,
// });
// // pong_exe.addModule("ipc", module.CreateOptions);
// pong_exe.linkLibC();
// b.installArtifact(pong_exe);
//
// const pongd_exe = b.addExecutable(.{
// .name = "pongd",
// .root_source_file = .{ .path = "src/pongd.zig" },
// .target = target,
// .optimize = optimize,
// });
// // pongd_exe.addModule("ipc", module.CreateOptions);
// pongd_exe.linkLibC();
// b.installArtifact(pongd_exe);
const is_static = b.option(bool, "static", "Compile static binaries.") orelse false;
if (is_static) {
ipcd_exe.linkage = .static;
2024-06-14 16:20:37 +02:00
// tcpd_exe.linkage = .static;
// pong_exe.linkage = .static;
// pongd_exe.linkage = .static;
}
}