| author | |
| committer | |
| log | ca0b03f7b5a38a497d9f8ee20b3b31e47e007616 |
| tree | 4b39084b8edc41cd3dc9a0c6d8243f4dd4935641 |
| parent | d3ecbbebd33fffc2e283d0c6524c3647c894fa1b |
| parent | ec8c25fd8f1de07bff7850a5b8ce1bafd1add223 |
closes #76298 files changed, 72 insertions(+), 30 deletions(-)
CMakeLists.txt+21-8| ... | @@ -25,8 +25,8 @@ project(zig C CXX) | ... | @@ -25,8 +25,8 @@ project(zig C CXX) |
| 25 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) | 25 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
| 26 | 26 | ||
| 27 | set(ZIG_VERSION_MAJOR 0) | 27 | set(ZIG_VERSION_MAJOR 0) |
| 28 | set(ZIG_VERSION_MINOR 7) | 28 | set(ZIG_VERSION_MINOR 8) |
| 29 | set(ZIG_VERSION_PATCH 1) | 29 | set(ZIG_VERSION_PATCH 0) |
| 30 | set(ZIG_VERSION "" CACHE STRING "Override Zig version string. Default is to find out with git.") | 30 | set(ZIG_VERSION "" CACHE STRING "Override Zig version string. Default is to find out with git.") |
| 31 | 31 | ||
| 32 | if("${ZIG_VERSION}" STREQUAL "") | 32 | if("${ZIG_VERSION}" STREQUAL "") |
| ... | @@ -34,18 +34,31 @@ if("${ZIG_VERSION}" STREQUAL "") | ... | @@ -34,18 +34,31 @@ if("${ZIG_VERSION}" STREQUAL "") |
| 34 | find_program(GIT_EXE NAMES git) | 34 | find_program(GIT_EXE NAMES git) |
| 35 | if(GIT_EXE) | 35 | if(GIT_EXE) |
| 36 | execute_process( | 36 | execute_process( |
| 37 | COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} name-rev HEAD --tags --name-only --no-undefined --always | 37 | COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} describe --match *.*.* --tags |
| 38 | RESULT_VARIABLE EXIT_STATUS | 38 | RESULT_VARIABLE EXIT_STATUS |
| 39 | OUTPUT_VARIABLE ZIG_GIT_REV | 39 | OUTPUT_VARIABLE GIT_DESCRIBE |
| 40 | OUTPUT_STRIP_TRAILING_WHITESPACE | 40 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 41 | ERROR_QUIET) | 41 | ERROR_QUIET) |
| 42 | if(EXIT_STATUS EQUAL "0") | 42 | if(EXIT_STATUS EQUAL "0") |
| 43 | if(ZIG_GIT_REV MATCHES "\\^0$") | 43 | if(GIT_DESCRIBE MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)$") |
| 44 | if(NOT("${ZIG_GIT_REV}" STREQUAL "${ZIG_VERSION}^0")) | 44 | # Tagged release version. |
| 45 | message("WARNING: Tag does not match configured Zig version") | 45 | set(GIT_TAG ${CMAKE_MATCH_1}) |
| 46 | if(NOT GIT_TAG VERSION_EQUAL ZIG_VERSION) | ||
| 47 | message(SEND_ERROR "Zig version (${ZIG_VERSION}) does not match Git tag (${GIT_TAG}).") | ||
| 46 | endif() | 48 | endif() |
| 49 | elseif(GIT_DESCRIBE MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-g(.+)$") | ||
| 50 | # Untagged pre-release. The Zig version is updated to include the number of commits | ||
| 51 | # since the last tagged version and the commit hash. The version is formatted in | ||
| 52 | # accordance with the https://semver.org specification. | ||
| 53 | set(GIT_TAG ${CMAKE_MATCH_1}) | ||
| 54 | set(GIT_COMMITS_AFTER_TAG ${CMAKE_MATCH_2}) | ||
| 55 | set(GIT_COMMIT ${CMAKE_MATCH_3}) | ||
| 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}).") | ||
| 58 | endif() | ||
| 59 | set(ZIG_VERSION "${ZIG_VERSION}-dev.${GIT_COMMITS_AFTER_TAG}+${GIT_COMMIT}") | ||
| 47 | else() | 60 | else() |
| 48 | set(ZIG_VERSION "${ZIG_VERSION}+${ZIG_GIT_REV}") | 61 | message(WARNING "Failed to parse version from output of `git describe`.") |
| 49 | endif() | 62 | endif() |
| 50 | endif() | 63 | endif() |
| 51 | endif() | 64 | endif() |
build.zig+40-16| ... | @@ -11,7 +11,7 @@ const fs = std.fs; | ... | @@ -11,7 +11,7 @@ const fs = std.fs; |
| 11 | const InstallDirectoryOptions = std.build.InstallDirectoryOptions; | 11 | const InstallDirectoryOptions = std.build.InstallDirectoryOptions; |
| 12 | const assert = std.debug.assert; | 12 | const assert = std.debug.assert; |
| 13 | 13 | ||
| 14 | const zig_version = std.builtin.Version{ .major = 0, .minor = 7, .patch = 1 }; | 14 | const zig_version = std.builtin.Version{ .major = 0, .minor = 8, .patch = 0 }; |
| 15 | 15 | ||
| 16 | pub fn build(b: *Builder) !void { | 16 | pub fn build(b: *Builder) !void { |
| 17 | b.setPreferredReleaseMode(.ReleaseFast); | 17 | b.setPreferredReleaseMode(.ReleaseFast); |
| ... | @@ -227,24 +227,48 @@ pub fn build(b: *Builder) !void { | ... | @@ -227,24 +227,48 @@ 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 }); |
| 228 | 228 | ||
| 229 | var code: u8 = undefined; | 229 | var code: u8 = undefined; |
| 230 | const git_sha_untrimmed = b.execAllowFail(&[_][]const u8{ | 230 | const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{ |
| 231 | "git", "-C", b.build_root, "name-rev", "HEAD", | 231 | "git", "-C", b.build_root, "describe", "--match", "*.*.*", "--tags", |
| 232 | "--tags", "--name-only", "--no-undefined", "--always", | ||
| 233 | }, &code, .Ignore) catch { | 232 | }, &code, .Ignore) catch { |
| 234 | break :v version_string; | 233 | break :v version_string; |
| 235 | }; | 234 | }; |
| 236 | const git_sha_trimmed = mem.trim(u8, git_sha_untrimmed, " \n\r"); | 235 | const git_describe = mem.trim(u8, git_describe_untrimmed, " \n\r"); |
| 237 | 236 | ||
| 238 | // This will look like e.g. "0.7.0^0" for a tag commit. | 237 | switch (mem.count(u8, git_describe, "-")) { |
| 239 | if (mem.endsWith(u8, git_sha_trimmed, "^0")) { | 238 | 0 => { |
| 240 | const git_ver_string = git_sha_trimmed[0 .. git_sha_trimmed.len - 2]; | 239 | // Tagged release version (e.g. 0.7.0). |
| 241 | if (!mem.eql(u8, git_ver_string, version_string)) { | 240 | if (!mem.eql(u8, git_describe, version_string)) { |
| 242 | std.debug.print("Expected git tag '{}', found '{}'\n", .{ version_string, git_ver_string }); | 241 | std.debug.print("Zig version '{}' does not match Git tag '{}'\n", .{ version_string, git_describe }); |
| 243 | std.process.exit(1); | 242 | std.process.exit(1); |
| 244 | } | 243 | } |
| 245 | break :v b.fmt("{}", .{version_string}); | 244 | break :v version_string; |
| 246 | } else { | 245 | }, |
| 247 | break :v b.fmt("{}+{}", .{ version_string, git_sha_trimmed }); | 246 | 2 => { |
| 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 | // Check that the commit hash is prefixed with a 'g' (a Git convention). | ||
| 260 | if (commit_id.len < 1 or commit_id[0] != 'g') { | ||
| 261 | std.debug.print("Unexpected `git describe` output: {}\n", .{git_describe}); | ||
| 262 | break :v version_string; | ||
| 263 | } | ||
| 264 | |||
| 265 | // The version is reformatted in accordance with the https://semver.org specification. | ||
| 266 | break :v b.fmt("{}-dev.{}+{}", .{ version_string, commit_height, commit_id[1..] }); | ||
| 267 | }, | ||
| 268 | else => { | ||
| 269 | std.debug.print("Unexpected `git describe` output: {}\n", .{git_describe}); | ||
| 270 | break :v version_string; | ||
| 271 | }, | ||
| 248 | } | 272 | } |
| 249 | }; | 273 | }; |
| 250 | exe.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); | 274 | exe.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); |
ci/azure/linux_script+2| ... | @@ -49,6 +49,8 @@ PATH=$PWD/$WASMTIME:$PATH | ... | @@ -49,6 +49,8 @@ PATH=$PWD/$WASMTIME:$PATH |
| 49 | # Make the `zig version` number consistent. | 49 | # Make the `zig version` number consistent. |
| 50 | # This will affect the cmake command below. | 50 | # This will affect the cmake command below. |
| 51 | git config core.abbrev 9 | 51 | git config core.abbrev 9 |
| 52 | git fetch --unshallow || true | ||
| 53 | git fetch --tags | ||
| 52 | 54 | ||
| 53 | export CC=gcc-7 | 55 | export CC=gcc-7 |
| 54 | export CXX=g++-7 | 56 | export CXX=g++-7 |
ci/azure/macos_script+2| ... | @@ -28,6 +28,8 @@ cd $ZIGDIR | ... | @@ -28,6 +28,8 @@ cd $ZIGDIR |
| 28 | # Make the `zig version` number consistent. | 28 | # Make the `zig version` number consistent. |
| 29 | # This will affect the cmake command below. | 29 | # This will affect the cmake command below. |
| 30 | git config core.abbrev 9 | 30 | git config core.abbrev 9 |
| 31 | git fetch --unshallow || true | ||
| 32 | git fetch --tags | ||
| 31 | 33 | ||
| 32 | mkdir build | 34 | mkdir build |
| 33 | cd build | 35 | cd build |
ci/azure/windows_msvc_script.bat+2| ... | @@ -18,6 +18,8 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliar | ... | @@ -18,6 +18,8 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliar |
| 18 | REM Make the `zig version` number consistent. | 18 | REM Make the `zig version` number consistent. |
| 19 | REM This will affect the cmake command below. | 19 | REM This will affect the cmake command below. |
| 20 | git.exe config core.abbrev 9 | 20 | git.exe config core.abbrev 9 |
| 21 | git.exe fetch --unshallow | ||
| 22 | git.exe fetch --tags | ||
| 21 | 23 | ||
| 22 | mkdir %ZIGBUILDDIR% | 24 | mkdir %ZIGBUILDDIR% |
| 23 | cd %ZIGBUILDDIR% | 25 | cd %ZIGBUILDDIR% |
ci/drone/linux_script+2| ... | @@ -14,6 +14,8 @@ pip3 install s3cmd | ... | @@ -14,6 +14,8 @@ pip3 install s3cmd |
| 14 | # Make the `zig version` number consistent. | 14 | # Make the `zig version` number consistent. |
| 15 | # This will affect the cmake command below. | 15 | # This will affect the cmake command below. |
| 16 | git config core.abbrev 9 | 16 | git config core.abbrev 9 |
| 17 | git fetch --unshallow || true | ||
| 18 | git fetch --tags | ||
| 17 | 19 | ||
| 18 | mkdir build | 20 | mkdir build |
| 19 | cd build | 21 | cd build |
ci/srht/freebsd_script+2| ... | @@ -20,6 +20,8 @@ cd $ZIGDIR | ... | @@ -20,6 +20,8 @@ cd $ZIGDIR |
| 20 | # Make the `zig version` number consistent. | 20 | # Make the `zig version` number consistent. |
| 21 | # This will affect the cmake command below. | 21 | # This will affect the cmake command below. |
| 22 | git config core.abbrev 9 | 22 | git config core.abbrev 9 |
| 23 | git fetch --unshallow || true | ||
| 24 | git fetch --tags | ||
| 23 | 25 | ||
| 24 | # SourceHut reports that it is a terminal that supports escape codes, but it | 26 | # SourceHut reports that it is a terminal that supports escape codes, but it |
| 25 | # is a filthy liar. Here we tell Zig to not try to send any terminal escape | 27 | # is a filthy liar. Here we tell Zig to not try to send any terminal escape |
src/config.zig.in+1-6| ... | @@ -1,11 +1,6 @@ | ... | @@ -1,11 +1,6 @@ |
| 1 | pub const have_llvm = true; | 1 | pub const have_llvm = true; |
| 2 | pub const version: [:0]const u8 = "@ZIG_VERSION@"; | 2 | pub const version: [:0]const u8 = "@ZIG_VERSION@"; |
| 3 | pub const semver: @import("std").SemanticVersion = .{ | 3 | pub const semver = try @import("std").SemanticVersion.parse(version); |
| 4 | .major = @ZIG_VERSION_MAJOR@, | ||
| 5 | .minor = @ZIG_VERSION_MINOR@, | ||
| 6 | .patch = @ZIG_VERSION_PATCH@, | ||
| 7 | .build = "@ZIG_GIT_REV@", | ||
| 8 | }; | ||
| 9 | pub const log_scopes: []const []const u8 = &[_][]const u8{}; | 4 | pub const log_scopes: []const []const u8 = &[_][]const u8{}; |
| 10 | pub const zir_dumps: []const []const u8 = &[_][]const u8{}; | 5 | pub const zir_dumps: []const []const u8 = &[_][]const u8{}; |
| 11 | pub const enable_tracy = false; | 6 | pub const enable_tracy = false; |