authorgravatar for hello@nektro.netMeghan <hello@nektro.net> 2021-01-07 12:54:58 -08:00
committergravatar for hello@nektro.netMeghan <hello@nektro.net> 2021-01-07 12:54:58 -08:00
log0447b40cb611060090f8f9c347d01711fc31b6e3
tree8e19b3ae5a11bda7ed356dc7483151426514634c
parentc21519d293eac9d9cc9d90d0199b335a858b22a4

move version from the file name to being printed by the program


2 files changed, 8 insertions(+), 4 deletions(-)

build.zig+2-2
...@@ -10,8 +10,7 @@ pub fn build(b: *Builder) void {...@@ -10,8 +10,7 @@ pub fn build(b: *Builder) void {
1010
11 const use_full_name = b.option(bool, "use-full-name", "") orelse false;11 const use_full_name = b.option(bool, "use-full-name", "") orelse false;
12 const with_arch_os = b.fmt("-{}-{}", .{@tagName(target.cpu_arch orelse builtin.arch), @tagName(target.os_tag orelse builtin.os.tag)});12 const with_arch_os = b.fmt("-{}-{}", .{@tagName(target.cpu_arch orelse builtin.arch), @tagName(target.os_tag orelse builtin.os.tag)});
13 const version_tag = if (b.option([]const u8, "tag", "")) |vt| b.fmt("-{}", .{vt}) else "";13 const exe_name = b.fmt("{}{}", .{ "zigmod", if (use_full_name) with_arch_os else "" });
14 const exe_name = b.fmt("{}{}{}", .{ "zigmod", version_tag, if (use_full_name) with_arch_os else "" });
1514
16 const exe = b.addExecutable(exe_name, "src/main.zig");15 const exe = b.addExecutable(exe_name, "src/main.zig");
17 exe.setTarget(target);16 exe.setTarget(target);
...@@ -19,6 +18,7 @@ pub fn build(b: *Builder) void {...@@ -19,6 +18,7 @@ pub fn build(b: *Builder) void {
19 if (mode != .Debug) {18 if (mode != .Debug) {
20 exe.strip = true;19 exe.strip = true;
21 }20 }
21 exe.addBuildOption([]const u8, "version", b.option([]const u8, "tag", "") orelse "");
2222
23 exe.linkLibC();23 exe.linkLibC();
2424
src/main.zig+6-2
...@@ -21,7 +21,12 @@ pub fn main() !void {...@@ -21,7 +21,12 @@ pub fn main() !void {
21 const args = proc_args[1..];21 const args = proc_args[1..];
2222
23 if (args.len == 0) {23 if (args.len == 0) {
24 u.print("zigmod-{}-{}-{}", .{@tagName(builtin.os.tag), @tagName(builtin.arch), @tagName(builtin.abi)});24 u.print("zigmod {} {} {} {}", .{
25 @import("build_options").version,
26 @tagName(builtin.os.tag),
27 @tagName(builtin.arch),
28 @tagName(builtin.abi)
29 });
25 return;30 return;
26 }31 }
2732
...@@ -32,6 +37,5 @@ pub fn main() !void {...@@ -32,6 +37,5 @@ pub fn main() !void {
32 return;37 return;
33 }38 }
34 }39 }
35
36 std.debug.panic("Error: unknown command \"{}\" for \"zigmod\"", .{args[0]});40 std.debug.panic("Error: unknown command \"{}\" for \"zigmod\"", .{args[0]});
37}41}