|
1 | 1 | const std = @import("std"); |
2 | 2 |
|
3 | | -const version: std.SemanticVersion = .{ .major = 2, .minor = 13, .patch = 5 }; |
4 | | - |
5 | 3 | pub fn build(b: *std.Build) void { |
6 | 4 | const upstream = b.dependency("libxml2", .{}); |
7 | 5 | const target = b.standardTargetOptions(.{}); |
8 | 6 | const optimize = b.standardOptimizeOption(.{}); |
9 | 7 |
|
| 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 | + |
10 | 13 | const linkage = b.option(std.builtin.LinkMode, "linkage", "Link mode") orelse .static; |
11 | 14 | const strip = b.option(bool, "strip", "Omit debug information"); |
12 | 15 | const pic = b.option(bool, "pie", "Produce Position Independent Code"); |
@@ -84,8 +87,8 @@ pub fn build(b: *std.Build) void { |
84 | 87 | .include_path = "libxml/xmlversion.h", |
85 | 88 | .style = .{ .cmake = upstream.path("include/libxml/xmlversion.h.in") }, |
86 | 89 | }, .{ |
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)), |
89 | 92 | .LIBXML_VERSION_EXTRA = "", |
90 | 93 | .WITH_THREADS = threads, |
91 | 94 | .WITH_THREAD_ALLOC = thread_alloc, |
|
0 commit comments