Skip to content

Commit

Permalink
Merge pull request #340 from aherrmann/zig-update-0.13.0
Browse files Browse the repository at this point in the history
chore: update Zig versions up to 0.13.0
  • Loading branch information
aherrmann authored Jul 7, 2024
2 parents 2142538 + 3522387 commit 8aa2b00
Show file tree
Hide file tree
Showing 23 changed files with 377 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/zig_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
run: |
OLD_VERSION="$(grep -m 1 -oP '^\s+"\K\d+\.\d+\.\d+(?=":)' zig/private/versions.json)"
bazel run //util:update_zig_versions
[ -z "$(git status --porcelain=v1 zig/private/versions.json 2>/dev/null)" ] || {
[ -z "$(git status --porcelain=v1 zig/private/versions.json zig/private/versions.bzl 2>/dev/null)" ] || {
NEW_VERSION="$(grep -m 1 -oP '^\s+"\K\d+\.\d+\.\d+(?=":)' zig/private/versions.json)"
BRANCH="zig-update-$NEW_VERSION"
git switch -c "$BRANCH"
git add zig/private/versions.json
git add zig/private/versions.json zig/private/versions.bzl
readarray -t FILES < <(git grep -l -F "$OLD_VERSION" -- ':(exclude)zig/private/versions.json' ':(exclude)zig/private/versions.bzl')
sed -i "s/${OLD_VERSION//./\\.}/$NEW_VERSION/g" "${FILES[@]}"
git add "${FILES[@]}"
Expand Down
2 changes: 2 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ zig_dev = use_extension(
"zig",
dev_dependency = True,
)
zig_dev.toolchain(zig_version = "0.13.0")
zig_dev.toolchain(zig_version = "0.12.1")
zig_dev.toolchain(zig_version = "0.12.0")
zig_dev.toolchain(zig_version = "0.11.0")

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ rules_zig_dependencies()

zig_register_toolchains(
name = "zig",
zig_version = "0.12.0",
zig_version = "0.13.0",
)
```

Expand Down
2 changes: 2 additions & 0 deletions e2e/workspace/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ zig = use_extension(
"zig",
dev_dependency = True,
)
zig.toolchain(zig_version = "0.13.0")
zig.toolchain(zig_version = "0.12.1")
zig.toolchain(zig_version = "0.12.0")
zig.toolchain(zig_version = "0.11.0")
use_repo(zig, "zig_toolchains")
Expand Down
2 changes: 2 additions & 0 deletions e2e/workspace/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ rules_zig_dependencies()
zig_register_toolchains(
name = "zig",
zig_versions = [
"0.13.0",
"0.12.1",
"0.12.0",
"0.11.0",
],
Expand Down
52 changes: 52 additions & 0 deletions e2e/workspace/configure-version/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,55 @@ zig_configure_test(
actual = ":zig_test_0.12.0_manual",
zig_version = "0.12.0",
)

zig_configure(
name = "zig_version_0.12.1",
actual = ":zig_version",
zig_version = "0.12.1",
)

diff_test(
name = "zig_version_test_0.12.1",
size = "small",
file1 = ":zig_version_0.12.1.expected",
file2 = ":zig_version_0.12.1",
)

zig_test(
name = "zig_test_0.12.1_manual",
main = "test-0.12.1.zig",
tags = ["manual"],
)

zig_configure_test(
name = "zig_test_0.12.1",
size = "small",
actual = ":zig_test_0.12.1_manual",
zig_version = "0.12.1",
)

zig_configure(
name = "zig_version_0.13.0",
actual = ":zig_version",
zig_version = "0.13.0",
)

diff_test(
name = "zig_version_test_0.13.0",
size = "small",
file1 = ":zig_version_0.13.0.expected",
file2 = ":zig_version_0.13.0",
)

zig_test(
name = "zig_test_0.13.0_manual",
main = "test-0.13.0.zig",
tags = ["manual"],
)

zig_configure_test(
name = "zig_test_0.13.0",
size = "small",
actual = ":zig_test_0.13.0_manual",
zig_version = "0.13.0",
)
6 changes: 6 additions & 0 deletions e2e/workspace/configure-version/test-0.12.1.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const std = @import("std");
const builtin = @import("builtin");

test "match Zig version" {
try std.testing.expectEqualStrings("0.12.1", builtin.zig_version_string);
}
6 changes: 6 additions & 0 deletions e2e/workspace/configure-version/test-0.13.0.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const std = @import("std");
const builtin = @import("builtin");

test "match Zig version" {
try std.testing.expectEqualStrings("0.13.0", builtin.zig_version_string);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.12.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.13.0
11 changes: 9 additions & 2 deletions e2e/workspace/runfiles-library/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ test "runfiles in nested binary" {

const run = if (builtin.zig_version.major == 0 and builtin.zig_version.minor == 11)
std.ChildProcess.exec
else if (builtin.zig_version.major == 0 and builtin.zig_version.minor == 12)
std.ChildProcess.run
else
std.ChildProcess.run;
std.process.Child.run;
const result = try run(.{
.allocator = std.testing.allocator,
.argv = &[_][]const u8{binary_path},
Expand All @@ -125,6 +127,11 @@ test "runfiles in nested binary" {
defer std.testing.allocator.free(result.stderr);

std.log.warn("stderr: {s}", .{result.stderr});
try std.testing.expectEqual(std.ChildProcess.Term{ .Exited = 0 }, result.term);
const Term = if (builtin.zig_version.major == 0 and builtin.zig_version.minor < 13)
std.ChildProcess.Term
else
std.process.Child.Term;
try std.testing.expectEqual(Term{ .Exited = 0 }, result.term);

try std.testing.expectEqualStrings("data: Hello World!\n", result.stdout);
}
2 changes: 1 addition & 1 deletion zig/private/repo/toolchains_repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
build_content += """
# Use this build flag to select the Zig SDK version. E.g.
#
# $ bazel build --@zig_toolchains//:version=0.12.0 //...
# $ bazel build --@zig_toolchains//:version=0.13.0 //...
#
string_flag(
name = "version",
Expand Down
68 changes: 68 additions & 0 deletions zig/private/versions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,74 @@ def _parse(json_string):

TOOL_VERSIONS = _parse("""\
{
"0.13.0": {
"aarch64-linux": {
"tarball": "https://ziglang.org/download/0.13.0/zig-linux-aarch64-0.13.0.tar.xz",
"shasum": "041ac42323837eb5624068acd8b00cd5777dac4cf91179e8dad7a7e90dd0c556"
},
"aarch64-macos": {
"tarball": "https://ziglang.org/download/0.13.0/zig-macos-aarch64-0.13.0.tar.xz",
"shasum": "46fae219656545dfaf4dce12fb4e8685cec5b51d721beee9389ab4194d43394c"
},
"aarch64-windows": {
"tarball": "https://ziglang.org/download/0.13.0/zig-windows-aarch64-0.13.0.zip",
"shasum": "95ff88427af7ba2b4f312f45d2377ce7a033e5e3c620c8caaa396a9aba20efda"
},
"x86-linux": {
"tarball": "https://ziglang.org/download/0.13.0/zig-linux-x86-0.13.0.tar.xz",
"shasum": "876159cc1e15efb571e61843b39a2327f8925951d48b9a7a03048c36f72180f7"
},
"x86-windows": {
"tarball": "https://ziglang.org/download/0.13.0/zig-windows-x86-0.13.0.zip",
"shasum": "eb3d533c3cf868bff7e74455dc005d18fd836c42e50b27106b31e9fec6dffc4a"
},
"x86_64-linux": {
"tarball": "https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz",
"shasum": "d45312e61ebcc48032b77bc4cf7fd6915c11fa16e4aad116b66c9468211230ea"
},
"x86_64-macos": {
"tarball": "https://ziglang.org/download/0.13.0/zig-macos-x86_64-0.13.0.tar.xz",
"shasum": "8b06ed1091b2269b700b3b07f8e3be3b833000841bae5aa6a09b1a8b4773effd"
},
"x86_64-windows": {
"tarball": "https://ziglang.org/download/0.13.0/zig-windows-x86_64-0.13.0.zip",
"shasum": "d859994725ef9402381e557c60bb57497215682e355204d754ee3df75ee3c158"
}
},
"0.12.1": {
"aarch64-linux": {
"tarball": "https://ziglang.org/builds/zig-linux-aarch64-0.12.1.tar.xz",
"shasum": "27d4fef393e8d8b5f3b1d19f4dd43bfdb469b4ed17bbc4c2283c1b1fe650ef7f"
},
"aarch64-macos": {
"tarball": "https://ziglang.org/builds/zig-macos-aarch64-0.12.1.tar.xz",
"shasum": "6587860dbbc070e1ee069e1a3d18ced83b7ba7a80bf67b2c57caf7c9ce5208b1"
},
"aarch64-windows": {
"tarball": "https://ziglang.org/builds/zig-windows-aarch64-0.12.1.zip",
"shasum": "e1286114a11be4695a6ad5cf0ba6a0e5f489bb3b029a5237de93598133f0c13a"
},
"x86-linux": {
"tarball": "https://ziglang.org/builds/zig-linux-x86-0.12.1.tar.xz",
"shasum": "c36ac019ca0fc3167e50d17e2affd3d072a06c519761737d0639adfdf2dcfddd"
},
"x86-windows": {
"tarball": "https://ziglang.org/builds/zig-windows-x86-0.12.1.zip",
"shasum": "4f0cc9258527e7b8bcf742772b3069122086a5cd857b38a1c08002462ac81f80"
},
"x86_64-linux": {
"tarball": "https://ziglang.org/builds/zig-linux-x86_64-0.12.1.tar.xz",
"shasum": "8860fc9725c2d9297a63008f853e9b11e3c5a2441217f99c1e3104cc6fa4a443"
},
"x86_64-macos": {
"tarball": "https://ziglang.org/builds/zig-macos-x86_64-0.12.1.tar.xz",
"shasum": "68f309c6e431d56eb42648d7fe86e8028a23464d401a467831e27c26f1a8d9c9"
},
"x86_64-windows": {
"tarball": "https://ziglang.org/builds/zig-windows-x86_64-0.12.1.zip",
"shasum": "52459b147c2de4d7c28f6b1a4b3d571c114e96836bf8e31c953a7d2f5e94251c"
}
},
"0.12.0": {
"aarch64-linux": {
"tarball": "https://ziglang.org/download/0.12.0/zig-linux-aarch64-0.12.0.tar.xz",
Expand Down
68 changes: 68 additions & 0 deletions zig/private/versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,72 @@
{
"0.13.0": {
"aarch64-linux": {
"tarball": "https://ziglang.org/download/0.13.0/zig-linux-aarch64-0.13.0.tar.xz",
"shasum": "041ac42323837eb5624068acd8b00cd5777dac4cf91179e8dad7a7e90dd0c556"
},
"aarch64-macos": {
"tarball": "https://ziglang.org/download/0.13.0/zig-macos-aarch64-0.13.0.tar.xz",
"shasum": "46fae219656545dfaf4dce12fb4e8685cec5b51d721beee9389ab4194d43394c"
},
"aarch64-windows": {
"tarball": "https://ziglang.org/download/0.13.0/zig-windows-aarch64-0.13.0.zip",
"shasum": "95ff88427af7ba2b4f312f45d2377ce7a033e5e3c620c8caaa396a9aba20efda"
},
"x86-linux": {
"tarball": "https://ziglang.org/download/0.13.0/zig-linux-x86-0.13.0.tar.xz",
"shasum": "876159cc1e15efb571e61843b39a2327f8925951d48b9a7a03048c36f72180f7"
},
"x86-windows": {
"tarball": "https://ziglang.org/download/0.13.0/zig-windows-x86-0.13.0.zip",
"shasum": "eb3d533c3cf868bff7e74455dc005d18fd836c42e50b27106b31e9fec6dffc4a"
},
"x86_64-linux": {
"tarball": "https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz",
"shasum": "d45312e61ebcc48032b77bc4cf7fd6915c11fa16e4aad116b66c9468211230ea"
},
"x86_64-macos": {
"tarball": "https://ziglang.org/download/0.13.0/zig-macos-x86_64-0.13.0.tar.xz",
"shasum": "8b06ed1091b2269b700b3b07f8e3be3b833000841bae5aa6a09b1a8b4773effd"
},
"x86_64-windows": {
"tarball": "https://ziglang.org/download/0.13.0/zig-windows-x86_64-0.13.0.zip",
"shasum": "d859994725ef9402381e557c60bb57497215682e355204d754ee3df75ee3c158"
}
},
"0.12.1": {
"aarch64-linux": {
"tarball": "https://ziglang.org/builds/zig-linux-aarch64-0.12.1.tar.xz",
"shasum": "27d4fef393e8d8b5f3b1d19f4dd43bfdb469b4ed17bbc4c2283c1b1fe650ef7f"
},
"aarch64-macos": {
"tarball": "https://ziglang.org/builds/zig-macos-aarch64-0.12.1.tar.xz",
"shasum": "6587860dbbc070e1ee069e1a3d18ced83b7ba7a80bf67b2c57caf7c9ce5208b1"
},
"aarch64-windows": {
"tarball": "https://ziglang.org/builds/zig-windows-aarch64-0.12.1.zip",
"shasum": "e1286114a11be4695a6ad5cf0ba6a0e5f489bb3b029a5237de93598133f0c13a"
},
"x86-linux": {
"tarball": "https://ziglang.org/builds/zig-linux-x86-0.12.1.tar.xz",
"shasum": "c36ac019ca0fc3167e50d17e2affd3d072a06c519761737d0639adfdf2dcfddd"
},
"x86-windows": {
"tarball": "https://ziglang.org/builds/zig-windows-x86-0.12.1.zip",
"shasum": "4f0cc9258527e7b8bcf742772b3069122086a5cd857b38a1c08002462ac81f80"
},
"x86_64-linux": {
"tarball": "https://ziglang.org/builds/zig-linux-x86_64-0.12.1.tar.xz",
"shasum": "8860fc9725c2d9297a63008f853e9b11e3c5a2441217f99c1e3104cc6fa4a443"
},
"x86_64-macos": {
"tarball": "https://ziglang.org/builds/zig-macos-x86_64-0.12.1.tar.xz",
"shasum": "68f309c6e431d56eb42648d7fe86e8028a23464d401a467831e27c26f1a8d9c9"
},
"x86_64-windows": {
"tarball": "https://ziglang.org/builds/zig-windows-x86_64-0.12.1.zip",
"shasum": "52459b147c2de4d7c28f6b1a4b3d571c114e96836bf8e31c953a7d2f5e94251c"
}
},
"0.12.0": {
"aarch64-linux": {
"tarball": "https://ziglang.org/download/0.12.0/zig-linux-aarch64-0.12.0.tar.xz",
Expand Down
15 changes: 13 additions & 2 deletions zig/runfiles/src/Directory.zig
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,19 @@ test "Directory init and unmapped lookup" {
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
try tmp.dir.makePath("test.runfiles/my_workspace/some/package");
try tmp.dir.writeFile("test.runfiles/_repo_mapping", "_repo_mapping");
try tmp.dir.writeFile("test.runfiles/my_workspace/some/package/some_file", "some_file");
if (builtin.zig_version.major == 0 and builtin.zig_version.minor < 13) {
try tmp.dir.writeFile("test.runfiles/_repo_mapping", "_repo_mapping");
try tmp.dir.writeFile("test.runfiles/my_workspace/some/package/some_file", "some_file");
} else {
try tmp.dir.writeFile(.{
.sub_path = "test.runfiles/_repo_mapping",
.data = "_repo_mapping",
});
try tmp.dir.writeFile(.{
.sub_path = "test.runfiles/my_workspace/some/package/some_file",
.data = "some_file",
});
}

const cwd_path_absolute = try std.fs.cwd().realpathAlloc(std.testing.allocator, ".");
defer std.testing.allocator.free(cwd_path_absolute);
Expand Down
17 changes: 13 additions & 4 deletions zig/runfiles/src/Manifest.zig
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,19 @@ const HashMapUnmanaged = std.HashMapUnmanaged(
test "RunfilesManifest init unmapped lookup" {
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
try tmp.dir.writeFile("test.runfiles_manifest",
\\my_workspace/some/package/some_file /absolute/path/to/some/package/some_file
\\_repo_mapping /absolute/path/to/_repo_mapping
);
if (builtin.zig_version.major == 0 and builtin.zig_version.minor < 13) {
try tmp.dir.writeFile("test.runfiles_manifest",
\\my_workspace/some/package/some_file /absolute/path/to/some/package/some_file
\\_repo_mapping /absolute/path/to/_repo_mapping
);
} else {
try tmp.dir.writeFile(.{
.sub_path = "test.runfiles_manifest",
.data =
\\my_workspace/some/package/some_file /absolute/path/to/some/package/some_file
\\_repo_mapping /absolute/path/to/_repo_mapping
});
}

const runfiles_path = try tmp.dir.realpathAlloc(std.testing.allocator, "test.runfiles_manifest");
defer std.testing.allocator.free(runfiles_path);
Expand Down
23 changes: 17 additions & 6 deletions zig/runfiles/src/RepoMapping.zig
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,23 @@ const Ctx = struct {
test "RepoMapping init from file" {
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
try tmp.dir.writeFile("_repo_mapping",
\\,my_module,my_workspace
\\,my_protobuf,protobuf~3.19.2
\\,my_workspace,my_workspace
\\protobuf~3.19.2,protobuf,protobuf~3.19.2
);
if (builtin.zig_version.major == 0 and builtin.zig_version.minor < 13) {
try tmp.dir.writeFile("_repo_mapping",
\\,my_module,my_workspace
\\,my_protobuf,protobuf~3.19.2
\\,my_workspace,my_workspace
\\protobuf~3.19.2,protobuf,protobuf~3.19.2
);
} else {
try tmp.dir.writeFile(.{
.sub_path = "_repo_mapping",
.data =
\\,my_module,my_workspace
\\,my_protobuf,protobuf~3.19.2
\\,my_workspace,my_workspace
\\protobuf~3.19.2,protobuf,protobuf~3.19.2
});
}
const mapping_path = try tmp.dir.realpathAlloc(std.testing.allocator, "_repo_mapping");
defer std.testing.allocator.free(mapping_path);
var repo_mapping = try RepoMapping.init(std.testing.allocator, mapping_path);
Expand Down
Loading

0 comments on commit 8aa2b00

Please sign in to comment.