Skip to content

Commit

Permalink
chore: Compatibility with zig rules 0.4.0 and newer.
Browse files Browse the repository at this point in the history
They renamed `zig_package` to `zig_module`.
  • Loading branch information
iphydf committed Nov 5, 2024
1 parent 981bb1b commit f5f96d5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.11.0
- run: zig build test
- run: zig build apps

Expand All @@ -30,4 +32,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.11.0
- run: zig fmt --check src/*.zig
10 changes: 6 additions & 4 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
load("@rules_zig//zig:defs.bzl", "zig_binary", "zig_library", "zig_package", "zig_test")
load("@rules_zig//zig:defs.bzl", "zig_binary", "zig_library", "zig_module", "zig_test")
load("//tools/project:build_defs.bzl", "project")

project(license = "gpl3-https")

zig_package(
zig_module(
name = "sodium",
main = "src/sodium.zig",
)

zig_package(
zig_module(
name = "tox",
srcs = [
"src/friend.zig",
Expand All @@ -23,13 +23,14 @@ zig_library(
name = "zig-toxcore-c",
cdeps = [
"//c-toxcore",
"@libsodium",
"@rules_zig//zig/lib:libc",
],
main = "src/tox.zig",
deps = [":tox"],
)

zig_package(
zig_module(
name = "node_info",
srcs = [
"apps/BootNode.zig",
Expand All @@ -46,6 +47,7 @@ zig_package(
name = app,
cdeps = [
"//c-toxcore",
"@libsodium",
"@rules_zig//zig/lib:libc",
],
main = "apps/%s.zig" % app,
Expand Down
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
.@"c-toxcore" = .{
.url = "https://github.com/nodecum/c-toxcore/archive/9f5eb26095e397c161778aad2f2b0d76dfda17ec.tar.gz",
.hash = "12203c61fa1d9e9b8eeb6c7591f68531463d557652fb6ea2df90eeb0a4e03685b998",
.hash = "12209db6943118be4e1152a89b8ddb0096a61b37ae1208a0ce9636bde5cd21b9d81f",
},
},
}
10 changes: 9 additions & 1 deletion src/tox.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ const log = std.log.scoped(.tox);
pub fn versionMajor() u32 {
return c.tox_version_major();
}
test "major version should be 0" {
try std.testing.expectEqual(versionMajor(), 0);
}

/// The minor version number.
/// Incremented when functionality is added without breaking the API or ABI.
/// Set to 0 when the major version number is incremented.
pub fn versionMinor() u32 {
return c.tox_version_minor();
}
test "minor version should not be 0" {
try std.testing.expect(versionMinor() != 0);
}

/// The patch or revision number.
/// Incremented when bugfixes are applied without changing any functionality or
/// API or ABI.
Expand Down Expand Up @@ -744,5 +752,5 @@ test {
}

test "String test" {
// try std.testing.expectEqualStrings("Hi", "Hi");
try std.testing.expectEqualStrings("Hi", "Hi");
}

0 comments on commit f5f96d5

Please sign in to comment.