diff --git a/build.zig b/build.zig index 75857d5..66fa850 100644 --- a/build.zig +++ b/build.zig @@ -24,10 +24,12 @@ pub fn build(b: *std.Build) void { // My version stuff const options = b.addOptions(); - const zon_content = std.fs.cwd().readFileAlloc(b.allocator, "build.zig.zon", 1024 * 1024) catch @panic("Failed to read build.zig.zon"); - defer b.allocator.free(zon_content); + // Read version and name form build.zig.zon + const zon = @import("build.zig.zon"); + const name_str = @tagName(zon.name); + const version = zon.version; - const version = parseVersionFromZon(zon_content); + options.addOption([]const u8, "name", name_str); options.addOption([]const u8, "version", version); // This creates a module, which represents a collection of source files alongside @@ -55,11 +57,6 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); - const modHelp = b.addModule("help", .{ - .root_source_file = b.path("src/help.zig"), - .target = target, - }); - // Here we define an executable. An executable needs to have a root module // which needs to expose a `main` function. While we could add a main function // to the module defined above, it's sometimes preferable to split business @@ -98,7 +95,6 @@ pub fn build(b: *std.Build) void { // can be extremely useful in case of collisions (which can happen // importing modules from different packages). .{ .name = "grab", .module = mod }, - .{ .name = "help", .module = modHelp }, }, }), }); @@ -206,7 +202,6 @@ pub fn build(b: *std.Build) void { resolved_target, optimize, mod, - modHelp, clap, options, ); @@ -323,7 +318,6 @@ fn addReleaseExecutable( target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, mod: *std.Build.Module, - modHelp: *std.Build.Module, clap: *std.Build.Dependency, options: *std.Build.Step.Options, ) *std.Build.Step.Compile { @@ -337,7 +331,6 @@ fn addReleaseExecutable( .optimize = release_optimize, .imports = &.{ .{ .name = "grab", .module = mod }, - .{ .name = "help", .module = modHelp }, }, }), }); diff --git a/changelog.d/+bedcba4a.misc.md b/changelog.d/+bedcba4a.misc.md new file mode 100644 index 0000000..459ffb0 --- /dev/null +++ b/changelog.d/+bedcba4a.misc.md @@ -0,0 +1 @@ +Updated the towncrier configuration to allows show the contains of the misc fragments. diff --git a/changelog.d/51.misc.md b/changelog.d/51.misc.md new file mode 100644 index 0000000..23c27a3 --- /dev/null +++ b/changelog.d/51.misc.md @@ -0,0 +1 @@ +Updated the build system to make use of the zon file reading. diff --git a/src/main.zig b/src/main.zig index 17f205d..7d20d7d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,7 +1,7 @@ const std = @import("std"); const clap = @import("clap"); const grab = @import("grab"); -const help = @import("help"); +const help = @import("help.zig"); pub const Level = enum { info, debug, @"error", warn }; pub const std_options: std.Options = .{ @@ -69,7 +69,7 @@ pub fn main() !void { return clap.helpToFile(.stderr(), clap.Help, ¶ms, .{}); if (res.args.version != 0) { const build_options = @import("build_options"); - std.log.info("grab: {s}", .{build_options.version}); + std.log.info("{s}: {s}", .{ build_options.name, build_options.version }); std.process.exit(0); } diff --git a/towncrier.toml b/towncrier.toml index c2527f9..06f7dcf 100644 --- a/towncrier.toml +++ b/towncrier.toml @@ -3,3 +3,28 @@ name = "git-grab" filename = "CHANGELOG.md" directory = "changelog.d" + +[[tool.towncrier.type]] +directory = "feature" +name = "Features" +showcontent = true + +[[tool.towncrier.type]] +directory = "bugfix" +name = "Bugfixes" +showcontent = true + +[[tool.towncrier.type]] +directory = "doc" +name = "Improved Documentation" +showcontent = true + +[[tool.towncrier.type]] +directory = "removal" +name = "Removals" +showcontent = true + +[[tool.towncrier.type]] +directory = "misc" +name = "Misc" +showcontent = true