Skip to content

Commit

Permalink
Introduce Bazel flag and config setting to disable copy_file_range
Browse files Browse the repository at this point in the history
This allows changing this behavior from a dependent Bazel workspace much easier and will only invalidate the cache of this target (and dependencies) when changed.
In contrast setting `cops` globally would invalidate all cache.

PiperOrigin-RevId: 679644291
  • Loading branch information
Compression Team authored and QrczakMK committed Sep 27, 2024
1 parent 6e1eb8f commit cdfb25a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ bazel_dep(
version = "2.1.0",
repo_name = "absl_py",
)
bazel_dep(
name = "bazel_skylib",
version = "1.7.1",
)
bazel_dep(
name = "boringssl",
version = "0.0.0-20240530-2db0eb3",
Expand Down
16 changes: 16 additions & 0 deletions riegeli/bytes/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

package(
default_visibility = ["//visibility:public"],
features = ["header_modules"],
)

licenses(["notice"])

bool_flag(
name = "use_copy_file_range",
build_setting_default = True,
)

config_setting(
name = "disable_copy_file_range",
flag_values = {":use_copy_file_range": "False"},
)

cc_library(
name = "reader",
hdrs = ["reader.h"],
Expand Down Expand Up @@ -1074,6 +1086,10 @@ cc_library(
"//conditions:default": ["fd_writer.h"],
}),
hdrs = ["fd_reader.h"],
defines = select({
"//riegeli/bytes:disable_copy_file_range": ["RIEGELI_DISABLE_COPY_FILE_RANGE"],
"//conditions:default": [],
}),
# fd_reader.cc has #define before #include to influence what the included
# files provide.
features = ["-use_header_modules"],
Expand Down

0 comments on commit cdfb25a

Please sign in to comment.