2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-25 11:32:33 +00:00
bazel-lib/tools/common/BUILD.bazel
Peter Lobsinger 3c121a9cd9
perf: use darwin's clonefile syscall (#893)
* perf: use darwin's clonefile syscall

This saves time and disk-space when copying files around on the same
device. File clones (aka reflinks) share backing disk blocks; they
differ from hardlinks in that inodes are not shared and the contents are
copy-on-write.

The Go standard library (as of v1.22) arranges to do a similar thing for file
copies on Linux (see: https://cs.opensource.google/go/go/+/refs/tags/go1.22.6:src/os/zero_copy_linux.go;l=53).
Unfortunately, Mac OS' more limited API is less amenable to that form of
transparent wrapping.

* Assign to named return params and use naked returns
2024-08-08 16:29:47 -07:00

23 lines
619 B
Python

load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "common",
srcs = [
"clonefile_darwin.go",
"clonefile_stub.go",
"copy.go",
"file.go",
],
importpath = "github.com/aspect-build/bazel-lib/tools/common",
visibility = ["//visibility:public"],
deps = select({
"@io_bazel_rules_go//go/platform:darwin": [
"@org_golang_x_sys//unix:go_default_library",
],
"@io_bazel_rules_go//go/platform:ios": [
"@org_golang_x_sys//unix:go_default_library",
],
"//conditions:default": [],
}),
)