Use build.zig instead of the makefile to build binaries.
This commit is contained in:
parent
b2bf66c436
commit
a0c446ca28
@ -1,22 +1,22 @@
|
||||
const std = @import("std");
|
||||
const hexdump = @import("./hexdump.zig");
|
||||
const net = std.net;
|
||||
const fmt = std.fmt;
|
||||
const os = std.os;
|
||||
|
||||
const ipc = @import("./main.zig");
|
||||
const ipc = @import("ipc");
|
||||
const hexdump = ipc.hexdump;
|
||||
const Message = ipc.Message;
|
||||
|
||||
// Import send_fd this way in order to produce docs for exchange-fd functions.
|
||||
const exchange_fd = @import("./exchange-fd.zig");
|
||||
const exchange_fd = ipc.exchangefd;
|
||||
const send_fd = exchange_fd.send_fd;
|
||||
|
||||
const builtin = @import("builtin");
|
||||
const native_os = builtin.target.os.tag;
|
||||
const print = std.debug.print;
|
||||
const testing = std.testing;
|
||||
const print_eq = @import("./util.zig").print_eq;
|
||||
const URI = @import("./util.zig").URI;
|
||||
const print_eq = ipc.util.print_eq;
|
||||
const URI = ipc.util.URI;
|
||||
|
||||
// Standard library is unecessary complex regarding networking.
|
||||
// libipc drops it and uses plain old file descriptors instead.
|
@ -1,11 +1,12 @@
|
||||
const std = @import("std");
|
||||
const hexdump = @import("./hexdump.zig");
|
||||
const net = std.net;
|
||||
const fmt = std.fmt;
|
||||
const os = std.os;
|
||||
|
||||
const print = std.debug.print;
|
||||
const ipc = @import("./main.zig");
|
||||
|
||||
const ipc = @import("ipc");
|
||||
const hexdump = ipc.hexdump;
|
||||
const Message = ipc.Message;
|
||||
|
||||
pub fn main() !u8 {
|
@ -1,21 +1,21 @@
|
||||
const std = @import("std");
|
||||
const hexdump = @import("./hexdump.zig");
|
||||
const net = std.net;
|
||||
const fmt = std.fmt;
|
||||
const os = std.os;
|
||||
|
||||
const ipc = @import("./main.zig");
|
||||
const ipc = @import("ipc");
|
||||
const hexdump = ipc.hexdump;
|
||||
const Message = ipc.Message;
|
||||
const util = ipc.util;
|
||||
|
||||
// Import send_fd this way in order to produce docs for exchange-fd functions.
|
||||
const exchange_fd = @import("./exchange-fd.zig");
|
||||
const exchange_fd = ipc.exchangefd;
|
||||
const send_fd = exchange_fd.send_fd;
|
||||
|
||||
const builtin = @import("builtin");
|
||||
const native_os = builtin.target.os.tag;
|
||||
const print = std.debug.print;
|
||||
const testing = std.testing;
|
||||
const util = @import("./util.zig");
|
||||
|
||||
fn create_service() !void {
|
||||
const config = .{.safety = true};
|
@ -1,22 +1,22 @@
|
||||
const std = @import("std");
|
||||
const hexdump = @import("./hexdump.zig");
|
||||
const net = std.net;
|
||||
const fmt = std.fmt;
|
||||
const os = std.os;
|
||||
const testing = std.testing;
|
||||
const print = std.debug.print;
|
||||
|
||||
const ipc = @import("./main.zig");
|
||||
const ipc = @import("ipc");
|
||||
const hexdump = ipc.hexdump;
|
||||
const Message = ipc.Message;
|
||||
|
||||
// Import send_fd this way in order to produce docs for exchange-fd functions.
|
||||
const exchange_fd = @import("./exchange-fd.zig");
|
||||
const exchange_fd = ipc.exchangefd;
|
||||
const send_fd = exchange_fd.send_fd;
|
||||
|
||||
const builtin = @import("builtin");
|
||||
const native_os = builtin.target.os.tag;
|
||||
const print = std.debug.print;
|
||||
const testing = std.testing;
|
||||
const print_eq = @import("./util.zig").print_eq;
|
||||
const URI = @import("./util.zig").URI;
|
||||
const print_eq = ipc.util.print_eq;
|
||||
const URI = ipc.util.URI;
|
||||
|
||||
fn init_tcp_server(allocator: std.mem.Allocator, server: *net.StreamServer) !i32 {
|
||||
var address = std.process.getEnvVarOwned(allocator, "ADDRESS") catch |err| switch(err) {
|
@ -1,13 +1,43 @@
|
||||
const std = @import("std");
|
||||
|
||||
const bin_dir = "bin";
|
||||
const build_dir = "build";
|
||||
|
||||
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;
|
||||
// const mode = std.builtin.Mode.Debug;
|
||||
const mode = std.builtin.Mode.ReleaseSmall;
|
||||
|
||||
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();
|
||||
|
||||
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 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);
|
||||
|
@ -27,30 +27,18 @@ VG_SUPPRESS_WARNINGS ?=
|
||||
VG_GENERATE_SUPPRESSION ?=
|
||||
USE_VALGRIND ?=
|
||||
|
||||
ipcd: src/ipcd.zig
|
||||
$(ZIGC) build-exe $(ZIGOPTS) $^
|
||||
|
||||
tcpd: src/tcpd.zig
|
||||
$(ZIGC) build-exe $(ZIGOPTS) $^
|
||||
|
||||
test-libipc: src/main.zig
|
||||
$(ZIGC) test $(ZIGOPTS) $^
|
||||
|
||||
test-ipcd: src/ipcd.zig
|
||||
$(ZIGC) test $(ZIGOPTS) $^
|
||||
|
||||
doc: src/ipcd.zig
|
||||
$(ZIGC) build-exe $(ZIGOPTS) $(ZIGMAKEDOC) $^
|
||||
|
||||
TO_CLEAN != ls misc/*.zig | sed 's/.zig$\//' | sed 's_misc/__'
|
||||
TO_CLEAN += ipcd tcpd pong pongd
|
||||
TO_CLEAN += *.o
|
||||
TO_CLEAN += bin/ipcd bin/tcpd bin/pong bin/pongd
|
||||
TO_CLEAN += bin/*.o
|
||||
clean:
|
||||
@-rm $(TO_CLEAN) 2>/dev/null
|
||||
|
||||
mrproper: clean
|
||||
@-rm -r docs build zig-cache zig-out 2>/dev/null
|
||||
|
||||
doc: src/ipcd.zig
|
||||
$(ZIGC) build-exe $(ZIGOPTS) $(ZIGMAKEDOC) $^
|
||||
|
||||
ACCESS_LOGS ?= ./access.log
|
||||
servedoc:
|
||||
darkhttpd docs/ --addr 127.0.0.1 --port 35000 --log $(ACCESS_LOGS)
|
||||
|
@ -1,6 +1,6 @@
|
||||
const std = @import("std");
|
||||
const print = std.debug.print;
|
||||
const ipc = @import("./main.zig");
|
||||
const ipc = @import("./ipc.zig");
|
||||
const Context = ipc.Context;
|
||||
const Message = ipc.Message;
|
||||
const CBEventType = ipc.CBEvent.Type;
|
||||
|
@ -21,7 +21,7 @@ const print_eq = @import("./util.zig").print_eq;
|
||||
const Messages = @import("./message.zig").Messages;
|
||||
const SwitchDB = @import("./switch.zig").SwitchDB;
|
||||
const Connections = @import("./connection.zig").Connections;
|
||||
const CBEventType = @import("./main.zig").CBEvent.Type;
|
||||
const CBEventType = @import("./ipc.zig").CBEvent.Type;
|
||||
|
||||
pub const PollFD = std.ArrayList(std.os.pollfd);
|
||||
|
||||
|
@ -9,6 +9,10 @@ pub const Switches = @import("./switch.zig").Switches;
|
||||
pub const Connections = @import("./connection.zig").Connections;
|
||||
pub const Context = @import("./context.zig").Context;
|
||||
|
||||
pub const util = @import("./util.zig");
|
||||
pub const hexdump = @import("./hexdump.zig");
|
||||
pub const exchangefd = @import("./exchange-fd.zig");
|
||||
|
||||
test {
|
||||
_ = @import("./callback.zig");
|
||||
_ = @import("./connection.zig");
|
@ -5,7 +5,7 @@ const fmt = std.fmt;
|
||||
|
||||
const net = std.net;
|
||||
|
||||
const ipc = @import("./main.zig");
|
||||
const ipc = @import("./ipc.zig");
|
||||
const Message = ipc.Message;
|
||||
const CBEventType = ipc.CBEvent.Type;
|
||||
|
||||
|
Reference in New Issue
Block a user