build baseline: pinned sqlite + mbedtls, static musl cross targets, cli stub
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
const std = @import("std");
|
||||
const version = @import("version.zig");
|
||||
|
||||
const usage =
|
||||
\\usage: nxdns <command>
|
||||
\\
|
||||
\\commands:
|
||||
\\ run serve DNS
|
||||
\\ check validate the configuration
|
||||
\\ export write local records to stdout
|
||||
\\ import read local records from stdin
|
||||
\\ version print version information
|
||||
\\
|
||||
;
|
||||
|
||||
const exit_ok = 0;
|
||||
const exit_not_implemented = 2;
|
||||
const exit_usage = 64;
|
||||
|
||||
pub fn main(init: std.process.Init) u8 {
|
||||
var args = init.minimal.args.iterate();
|
||||
_ = args.skip();
|
||||
const command = args.next() orelse return fail(init.io, usage);
|
||||
|
||||
if (std.mem.eql(u8, command, "version")) {
|
||||
return print(init.io, "nxdns {s} ({s})\nzig {s}\n", .{
|
||||
version.string,
|
||||
version.git_commit,
|
||||
version.zig_version_string,
|
||||
});
|
||||
}
|
||||
|
||||
for ([_][]const u8{ "run", "check", "export", "import" }) |known| {
|
||||
if (std.mem.eql(u8, command, known)) {
|
||||
_ = print(init.io, "not implemented\n", .{});
|
||||
return exit_not_implemented;
|
||||
}
|
||||
}
|
||||
|
||||
return fail(init.io, usage);
|
||||
}
|
||||
|
||||
fn print(io: std.Io, comptime format: []const u8, arguments: anytype) u8 {
|
||||
var buffer: [512]u8 = undefined;
|
||||
var file_writer = std.Io.File.stdout().writer(io, &buffer);
|
||||
file_writer.interface.print(format, arguments) catch return 1;
|
||||
file_writer.interface.flush() catch return 1;
|
||||
return exit_ok;
|
||||
}
|
||||
|
||||
fn fail(io: std.Io, message: []const u8) u8 {
|
||||
var buffer: [512]u8 = undefined;
|
||||
var file_writer = std.Io.File.stderr().writer(io, &buffer);
|
||||
file_writer.interface.writeAll(message) catch {};
|
||||
file_writer.interface.flush() catch {};
|
||||
return exit_usage;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
const std = @import("std");
|
||||
|
||||
comptime {
|
||||
_ = @import("main.zig");
|
||||
_ = @import("version.zig");
|
||||
_ = @import("platform/address.zig");
|
||||
_ = @import("platform/tls_client.zig");
|
||||
_ = @import("platform/tls_client_integration_test.zig");
|
||||
_ = @import("platform/tls_server.zig");
|
||||
}
|
||||
|
||||
extern fn sqlite3_libversion() [*:0]const u8;
|
||||
/// Mbed TLS documents 18 bytes as the minimum buffer size for this call.
|
||||
extern fn mbedtls_version_get_string_full(buffer: [*]u8) void;
|
||||
|
||||
test "sqlite3 links and reports a version" {
|
||||
const reported = std.mem.span(sqlite3_libversion());
|
||||
try std.testing.expect(reported.len > 0);
|
||||
try std.testing.expect(std.mem.startsWith(u8, reported, "3."));
|
||||
}
|
||||
|
||||
test "mbedtls links and reports a version" {
|
||||
var buffer: [32]u8 = undefined;
|
||||
mbedtls_version_get_string_full(&buffer);
|
||||
const reported = std.mem.sliceTo(&buffer, 0);
|
||||
try std.testing.expect(reported.len > 0);
|
||||
try std.testing.expect(std.mem.startsWith(u8, reported, "Mbed TLS 3.6"));
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
const build_options = @import("build_options");
|
||||
|
||||
pub const string: []const u8 = build_options.version_string;
|
||||
pub const git_commit: []const u8 = build_options.git_commit;
|
||||
pub const zig_version_string: []const u8 = build_options.zig_version_string;
|
||||
Reference in New Issue
Block a user