authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-31 16:41:35-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-31 16:41:35-07:00
loge8810f579406673edad0c9780c9d990f3034717a
treec505f7eedbe46f9bb1b42057776cf40ba0c496bd
parent9afe5859a3e428b259a306c36a860e4d82dbb4bb

Revert "stage2: SemVer compliance for development builds"

This reverts commit 4af763d401b48f7186650335c8e42e8fe29751bf.

3 files changed, 24 insertions(+), 37 deletions(-)

CMakeLists.txt+2-2
...@@ -44,7 +44,7 @@ if("${ZIG_VERSION}" STREQUAL "")...@@ -44,7 +44,7 @@ if("${ZIG_VERSION}" STREQUAL "")
44 # Tagged release version.44 # Tagged release version.
45 set(GIT_TAG ${CMAKE_MATCH_1})45 set(GIT_TAG ${CMAKE_MATCH_1})
46 if(NOT GIT_TAG VERSION_EQUAL ZIG_VERSION)46 if(NOT GIT_TAG VERSION_EQUAL ZIG_VERSION)
47 message(SEND_ERROR "Zig version (${ZIG_VERSION}) does not match Git tag (${GIT_TAG}).")47 message(SEND_ERROR "Configured Zig version (${ZIG_VERSION}) does not match Git tag (${GIT_TAG}).")
48 endif()48 endif()
49 elseif(GIT_DESCRIBE MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-(.+)$")49 elseif(GIT_DESCRIBE MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-(.+)$")
50 # Untagged pre-release. The Zig version is updated to include the number of commits50 # Untagged pre-release. The Zig version is updated to include the number of commits
...@@ -54,7 +54,7 @@ if("${ZIG_VERSION}" STREQUAL "")...@@ -54,7 +54,7 @@ if("${ZIG_VERSION}" STREQUAL "")
54 set(GIT_COMMITS_AFTER_TAG ${CMAKE_MATCH_2})54 set(GIT_COMMITS_AFTER_TAG ${CMAKE_MATCH_2})
55 set(GIT_COMMIT ${CMAKE_MATCH_3})55 set(GIT_COMMIT ${CMAKE_MATCH_3})
56 if(NOT ZIG_VERSION VERSION_GREATER GIT_TAG)56 if(NOT ZIG_VERSION VERSION_GREATER GIT_TAG)
57 message(SEND_ERROR "Zig version (${ZIG_VERSION}) must be greater than tagged ancestor (${GIT_TAG}).")57 message(SEND_ERROR "Configured Zig version (${ZIG_VERSION}) must be greater than tagged ancestor (${GIT_TAG}).")
58 endif()58 endif()
59 set(ZIG_VERSION "${ZIG_VERSION}-dev.${GIT_COMMITS_AFTER_TAG}+${GIT_COMMIT}")59 set(ZIG_VERSION "${ZIG_VERSION}-dev.${GIT_COMMITS_AFTER_TAG}+${GIT_COMMIT}")
60 else()60 else()
build.zig+16-34
...@@ -11,7 +11,7 @@ const fs = std.fs;...@@ -11,7 +11,7 @@ const fs = std.fs;
11const InstallDirectoryOptions = std.build.InstallDirectoryOptions;11const InstallDirectoryOptions = std.build.InstallDirectoryOptions;
12const assert = std.debug.assert;12const assert = std.debug.assert;
1313
14const zig_version = std.builtin.Version{ .major = 0, .minor = 8, .patch = 0 };14const zig_version = std.builtin.Version{ .major = 0, .minor = 7, .patch = 1 };
1515
16pub fn build(b: *Builder) !void {16pub fn build(b: *Builder) !void {
17 b.setPreferredReleaseMode(.ReleaseFast);17 b.setPreferredReleaseMode(.ReleaseFast);
...@@ -227,42 +227,24 @@ pub fn build(b: *Builder) !void {...@@ -227,42 +227,24 @@ pub fn build(b: *Builder) !void {
227 const version_string = b.fmt("{}.{}.{}", .{ zig_version.major, zig_version.minor, zig_version.patch });227 const version_string = b.fmt("{}.{}.{}", .{ zig_version.major, zig_version.minor, zig_version.patch });
228228
229 var code: u8 = undefined;229 var code: u8 = undefined;
230 const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{230 const git_sha_untrimmed = b.execAllowFail(&[_][]const u8{
231 "git", "-C", b.build_root, "describe", "--match", "*.*.*", "--tags",231 "git", "-C", b.build_root, "name-rev", "HEAD",
232 "--tags", "--name-only", "--no-undefined", "--always",
232 }, &code, .Ignore) catch {233 }, &code, .Ignore) catch {
233 break :v version_string;234 break :v version_string;
234 };235 };
235 const git_describe = mem.trim(u8, git_describe_untrimmed, " \n\r");236 const git_sha_trimmed = mem.trim(u8, git_sha_untrimmed, " \n\r");
236237
237 switch (mem.count(u8, git_describe, "-")) {238 // This will look like e.g. "0.7.0^0" for a tag commit.
238 0 => {239 if (mem.endsWith(u8, git_sha_trimmed, "^0")) {
239 // Tagged release version (e.g. 0.7.0).240 const git_ver_string = git_sha_trimmed[0 .. git_sha_trimmed.len - 2];
240 if (!mem.eql(u8, git_describe, version_string)) {241 if (!mem.eql(u8, git_ver_string, version_string)) {
241 std.debug.print("Zig version '{}' does not match Git tag '{}'\n", .{ version_string, git_describe });242 std.debug.print("Expected git tag '{}', found '{}'\n", .{ version_string, git_ver_string });
242 std.process.exit(1);243 std.process.exit(1);
243 }244 }
244 break :v version_string;245 break :v b.fmt("{}", .{version_string});
245 },246 } else {
246 2 => {247 break :v b.fmt("{}+{}", .{ version_string, git_sha_trimmed });
247 // Untagged development build (e.g. 0.7.0-684-gbbe2cca1a).
248 var it = mem.split(git_describe, "-");
249 const tagged_ancestor = it.next() orelse unreachable;
250 const commit_height = it.next() orelse unreachable;
251 const commit_id = it.next() orelse unreachable;
252
253 const ancestor_ver = try std.builtin.Version.parse(tagged_ancestor);
254 if (zig_version.order(ancestor_ver) != .gt) {
255 std.debug.print("Zig version '{}' must be greater than tagged ancestor '{}'\n", .{ zig_version, ancestor_ver });
256 std.process.exit(1);
257 }
258
259 // The version is reformatted in accordance with the https://semver.org specification.
260 break :v b.fmt("{}-dev.{}+{}", .{ version_string, commit_height, commit_id });
261 },
262 else => {
263 std.debug.print("Failed to parse `git describe` output: {}\n", .{git_describe});
264 break :v version_string;
265 },
266 }248 }
267 };249 };
268 exe.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version));250 exe.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version));
src/config.zig.in+6-1
...@@ -1,6 +1,11 @@...@@ -1,6 +1,11 @@
1pub const have_llvm = true;1pub const have_llvm = true;
2pub const version: [:0]const u8 = "@ZIG_VERSION@";2pub const version: [:0]const u8 = "@ZIG_VERSION@";
3pub const semver = try @import("std").SemanticVersion.parse(version);3pub const semver: @import("std").SemanticVersion = .{
4 .major = @ZIG_VERSION_MAJOR@,
5 .minor = @ZIG_VERSION_MINOR@,
6 .patch = @ZIG_VERSION_PATCH@,
7 .build = "@ZIG_GIT_REV@",
8};
4pub const log_scopes: []const []const u8 = &[_][]const u8{};9pub const log_scopes: []const []const u8 = &[_][]const u8{};
5pub const zir_dumps: []const []const u8 = &[_][]const u8{};10pub const zir_dumps: []const []const u8 = &[_][]const u8{};
6pub const enable_tracy = false;11pub const enable_tracy = false;