Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 },
},
}),
});
Expand Down Expand Up @@ -206,7 +202,6 @@ pub fn build(b: *std.Build) void {
resolved_target,
optimize,
mod,
modHelp,
clap,
options,
);
Expand Down Expand Up @@ -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 {
Expand All @@ -337,7 +331,6 @@ fn addReleaseExecutable(
.optimize = release_optimize,
.imports = &.{
.{ .name = "grab", .module = mod },
.{ .name = "help", .module = modHelp },
},
}),
});
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+bedcba4a.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated the towncrier configuration to allows show the contains of the misc fragments.
1 change: 1 addition & 0 deletions changelog.d/51.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated the build system to make use of the zon file reading.
4 changes: 2 additions & 2 deletions src/main.zig
Original file line number Diff line number Diff line change
@@ -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 = .{
Expand Down Expand Up @@ -69,7 +69,7 @@ pub fn main() !void {
return clap.helpToFile(.stderr(), clap.Help, &params, .{});
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);
}

Expand Down
25 changes: 25 additions & 0 deletions towncrier.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading