Skip to content

Commit 5dff575

Browse files
authored
fix version number (#6)
1 parent 86c4742 commit 5dff575

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

build.zig

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
const std = @import("std");
22

3-
const version: std.SemanticVersion = .{ .major = 2, .minor = 13, .patch = 5 };
4-
53
pub fn build(b: *std.Build) void {
64
const upstream = b.dependency("libxml2", .{});
75
const target = b.standardTargetOptions(.{});
86
const optimize = b.standardOptimizeOption(.{});
97

8+
// get version from zon file
9+
const versionString = @import("./build.zig.zon").version;
10+
const version = std.SemanticVersion.parse(versionString) catch @panic("OOM");
11+
const versionNumber = version.major * 1_00_00 + version.minor * 1_00 + version.patch;
12+
1013
const linkage = b.option(std.builtin.LinkMode, "linkage", "Link mode") orelse .static;
1114
const strip = b.option(bool, "strip", "Omit debug information");
1215
const pic = b.option(bool, "pie", "Produce Position Independent Code");
@@ -84,8 +87,8 @@ pub fn build(b: *std.Build) void {
8487
.include_path = "libxml/xmlversion.h",
8588
.style = .{ .cmake = upstream.path("include/libxml/xmlversion.h.in") },
8689
}, .{
87-
.VERSION = b.fmt("{f}", .{version}),
88-
.LIBXML_VERSION_NUMBER = @as(i64, version.major * 10000 + version.major * 100 + version.patch),
90+
.VERSION = b.fmt("{f}", .{std.SemanticVersion{ .major = version.major, .minor = version.minor, .patch = version.patch }}),
91+
.LIBXML_VERSION_NUMBER = @as(i64, @intCast(versionNumber)),
8992
.LIBXML_VERSION_EXTRA = "",
9093
.WITH_THREADS = threads,
9194
.WITH_THREAD_ALLOC = thread_alloc,

0 commit comments

Comments
 (0)