Enable Bazel debug/release Zig builds and add stdx.time.Duration.hz and stdx.math.roundeven utilities.
This commit is contained in:
parent
aacbf2ee04
commit
59f99c4501
@ -20,7 +20,7 @@ bazel_dep(name = "rules_proto", version = "7.1.0")
|
||||
bazel_dep(name = "rules_python", version = "0.40.0")
|
||||
bazel_dep(name = "rules_rust", version = "0.60.0")
|
||||
bazel_dep(name = "rules_uv", version = "0.65.0")
|
||||
bazel_dep(name = "rules_zig", version = "20250314.0-b9739c6")
|
||||
bazel_dep(name = "rules_zig", version = "20250519.0-233b207")
|
||||
bazel_dep(name = "sentencepiece", version = "20240618.0-d7ace0a")
|
||||
bazel_dep(name = "toolchains_protoc", version = "0.3.7")
|
||||
bazel_dep(name = "with_cfg.bzl", version = "0.9.1")
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
|
||||
load("@rules_cc//cc:cc_test.bzl", "cc_test")
|
||||
load("@rules_zig//zig:defs.bzl", "BINARY_KIND", "zig_binary")
|
||||
|
||||
def zig_cc_binary(
|
||||
@ -14,12 +16,11 @@ def zig_cc_binary(
|
||||
name = "{}_lib".format(name),
|
||||
kind = BINARY_KIND.static_lib,
|
||||
copts = copts + ["-lc", "-fcompiler-rt"],
|
||||
deps = deps + [
|
||||
"@rules_zig//zig/lib:libc",
|
||||
],
|
||||
deps = deps,
|
||||
visibility = visibility,
|
||||
**kwargs
|
||||
)
|
||||
native.cc_binary(
|
||||
cc_binary(
|
||||
name = name,
|
||||
args = args,
|
||||
env = env,
|
||||
@ -48,9 +49,10 @@ def zig_cc_test(
|
||||
deps = deps + [
|
||||
"@rules_zig//zig/lib:libc",
|
||||
],
|
||||
visibility = visibility,
|
||||
**kwargs
|
||||
)
|
||||
native.cc_test(
|
||||
cc_test(
|
||||
name = name,
|
||||
env = env,
|
||||
data = data,
|
||||
|
||||
@ -15,3 +15,9 @@ pub inline fn intCast(comptime T: type, x: anytype) T {
|
||||
else => @intFromFloat(x),
|
||||
};
|
||||
}
|
||||
|
||||
pub inline fn roundeven(x: anytype) @TypeOf(x) {
|
||||
return struct {
|
||||
extern fn @"llvm.roundeven"(@TypeOf(x)) @TypeOf(x);
|
||||
}.@"llvm.roundeven"(x);
|
||||
}
|
||||
|
||||
@ -7,6 +7,10 @@ pub const Duration = struct {
|
||||
return .{ .ns = self.ns / rhs };
|
||||
}
|
||||
|
||||
pub fn hz(self: Duration) u64 {
|
||||
return (1 * std.time.ns_per_s) / self.ns;
|
||||
}
|
||||
|
||||
pub fn format(
|
||||
self: Duration,
|
||||
comptime fmt: []const u8,
|
||||
|
||||
68
third_party/modules/rules_zig/20250519.0-233b207/MODULE.bazel
vendored
Normal file
68
third_party/modules/rules_zig/20250519.0-233b207/MODULE.bazel
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
module(
|
||||
name = "rules_zig",
|
||||
version = "20250519.0-233b207",
|
||||
compatibility_level = 1,
|
||||
)
|
||||
|
||||
bazel_dep(name = "aspect_bazel_lib", version = "2.8.1")
|
||||
bazel_dep(name = "bazel_skylib", version = "1.7.1")
|
||||
bazel_dep(name = "platforms", version = "0.0.10")
|
||||
|
||||
zig = use_extension("//zig:extensions.bzl", "zig")
|
||||
zig.index(file = "//zig/private:versions.json")
|
||||
use_repo(zig, "zig_toolchains")
|
||||
|
||||
register_toolchains("@rules_zig//zig/target:all")
|
||||
|
||||
register_toolchains("@zig_toolchains//:all")
|
||||
|
||||
zig_dev = use_extension(
|
||||
"//zig:extensions.bzl",
|
||||
"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")
|
||||
|
||||
bazel_dep(name = "rules_cc", version = "0.0.9")
|
||||
bazel_dep(name = "stardoc", version = "0.7.0", dev_dependency = True, repo_name = "io_bazel_stardoc")
|
||||
bazel_dep(name = "gazelle", version = "0.38.0", dev_dependency = True, repo_name = "bazel_gazelle")
|
||||
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.7.1", dev_dependency = True)
|
||||
bazel_dep(
|
||||
name = "buildifier_prebuilt",
|
||||
version = "7.3.1",
|
||||
dev_dependency = True,
|
||||
)
|
||||
bazel_dep(name = "rules_multirun", version = "0.9.0", dev_dependency = True)
|
||||
bazel_dep(name = "rules_python", version = "0.35.0", dev_dependency = True)
|
||||
bazel_dep(
|
||||
name = "rules_bazel_integration_test",
|
||||
version = "0.25.0",
|
||||
dev_dependency = True,
|
||||
)
|
||||
|
||||
bazel_binaries = use_extension(
|
||||
"@rules_bazel_integration_test//:extensions.bzl",
|
||||
"bazel_binaries",
|
||||
dev_dependency = True,
|
||||
)
|
||||
|
||||
# NOTE: Keep in sync with WORKSPACE.
|
||||
bazel_binaries.download(version_file = "//:.bazelversion")
|
||||
bazel_binaries.download(version = "7.0.0")
|
||||
use_repo(
|
||||
bazel_binaries,
|
||||
"bazel_binaries",
|
||||
"bazel_binaries_bazelisk",
|
||||
"build_bazel_bazel_.bazelversion",
|
||||
"build_bazel_bazel_7_0_0",
|
||||
)
|
||||
|
||||
# TODO[AH] Should be an implicit transitive dependency through rules_bazel_integration_test.
|
||||
# However, if we do not include it explicitly, then the runfiles resolution for
|
||||
# cgrindel_bazel_starlib/shlib/lib/message.sh fails in
|
||||
# rules_bazel_integration_test/tools/update_deleted_packages.sh when invoked
|
||||
# through the rules_multirun target //util:update.
|
||||
bazel_dep(name = "cgrindel_bazel_starlib", version = "0.21.0", dev_dependency = True)
|
||||
5
third_party/modules/rules_zig/20250519.0-233b207/source.json
vendored
Normal file
5
third_party/modules/rules_zig/20250519.0-233b207/source.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"strip_prefix": "rules_zig-233b207499826715a3bf1a6eeea6e3052ed49542",
|
||||
"url": "https://github.com/zml/rules_zig/archive/233b207499826715a3bf1a6eeea6e3052ed49542.tar.gz",
|
||||
"integrity": "sha256-4gloFoSMPkWCV0Jxikqs1UkfOgQL+NmoXMMnVhtgVvg="
|
||||
}
|
||||
3
third_party/modules/rules_zig/metadata.json
vendored
3
third_party/modules/rules_zig/metadata.json
vendored
@ -15,7 +15,8 @@
|
||||
"20240909.0-37f17ff",
|
||||
"20240912.0-41bfe84",
|
||||
"20240913.0-1957d05",
|
||||
"20250314.0-b9739c6"
|
||||
"20250314.0-b9739c6",
|
||||
"20250519.0-233b207"
|
||||
],
|
||||
"yanked_versions": {}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user