chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:17:40 +08:00
commit f1825c8ceb
10096 changed files with 2364182 additions and 0 deletions
+113
View File
@@ -0,0 +1,113 @@
load("@python3_10//:defs.bzl", python310 = "interpreter")
load("@py_deps_py310//:requirements.bzl", ci_require = "requirement")
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_runtime", "py_runtime_pair")
exports_files([
"pytest_wrapper.py",
"default_doctest_pytest_plugin.py",
])
py_binary(
name = "pyzip",
srcs = ["pyzip.py"],
visibility = ["//visibility:public"],
)
py_library(
name = "gen_extract",
srcs = ["gen_extract.py"],
deps = [
ci_require("bazel-runfiles"),
],
visibility = ["//visibility:public"],
)
config_setting(
name = "is_linux",
constraint_values = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
)
config_setting(
name = "linux_x86_64_config",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
)
config_setting(
name = "linux_arm64_config",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
)
config_setting(
name = "osx_x86_64_config",
constraint_values = [
"@platforms//os:osx",
"@platforms//cpu:x86_64",
],
)
config_setting(
name = "osx_arm64_config",
constraint_values = [
"@platforms//os:osx",
"@platforms//cpu:arm64",
],
)
config_setting(
name = "windows_x86_64_config",
constraint_values = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
)
# Hermetic python environment, currently only used for CI infra and scripts.
py_runtime(
name = "py310_runtime",
interpreter = python310,
python_version = "PY3",
visibility = ["//visibility:private"],
)
py_runtime_pair(
name = "py310_runtime_pair",
py2_runtime = None,
py3_runtime = ":py310_runtime",
visibility = ["//visibility:private"],
)
toolchain(
name = "py310_toolchain",
exec_compatible_with = [":py310"],
toolchain = ":py310_runtime_pair",
toolchain_type = "@bazel_tools//tools/python:toolchain_type",
)
constraint_setting(name = "python_version")
constraint_value(
name = "py310",
constraint_setting = ":python_version",
visibility = ["//visibility:public"],
)
platform(
name = "py310_platform",
constraint_values = [":py310"],
parents = ["@local_config_platform//:host"],
visibility = ["//visibility:private"],
)
alias(
name = "py3",
actual = ":py310",
visibility = ["//visibility:public"],
)
+35
View File
@@ -0,0 +1,35 @@
"""Dependency labels for the CI driver closure (see //ci/ray_ci/deps:aliases.bzl).
TODO(elliot-barn): Remove this Windows-specific dep machinery once the Windows CI
system Python is upgraded to 3.10. At that point the driver deps can be bundled
from the hermetic py set on Windows like every other platform, so this list, the
select() in //ci/ray_ci/deps:aliases.bzl, the //ci/raydepsets ci_windows_depset,
and the agent-side pip install in ci/ray_ci/windows/install_tools.sh all go away.
"""
WINDOWS_DRIVER_DEPS = [
"aioboto3",
"anyscale",
"aws-requests-auth",
"azure-identity",
"azure-storage-blob",
"bazel-runfiles",
"boto3",
"botocore",
"click",
"freezegun",
"google-cloud-storage",
"jinja2",
"msal",
"pybuildkite",
"pytest",
"pyyaml",
"requests",
"responses",
]
def normalize_dep(name):
return name.lower().replace("-", "_").replace(".", "_")
def ci_require(name):
return "//ci/ray_ci/deps:" + normalize_dep(name)
+30
View File
@@ -0,0 +1,30 @@
# Adapted from grpc/third_party/cython.BUILD
# Adapted with modifications from tensorflow/third_party/cython.BUILD
py_library(
name="cython_lib",
srcs=glob(
["Cython/**/*.py"],
exclude=[
"**/Tests/*.py",
],
) + ["cython.py"],
data=glob([
"Cython/**/*.pyx",
"Cython/Utility/*.*",
"Cython/Includes/**/*.pxd",
]),
srcs_version="PY2AND3",
visibility=["//visibility:public"],
)
# May not be named "cython", since that conflicts with Cython/ on OSX
py_binary(
name="cython_binary",
srcs=["cython.py"],
main="cython.py",
srcs_version="PY2AND3",
visibility=["//visibility:public"],
deps=["cython_lib"],
)
+10
View File
@@ -0,0 +1,10 @@
"""This file is injected for all doctest targets in the repo by default."""
import pytest
import ray
@pytest.fixture(autouse=True, scope="module")
def shutdown_ray():
ray.shutdown()
yield
+38
View File
@@ -0,0 +1,38 @@
import os
import shutil
import subprocess
from typing import List, Optional
import runfiles
def gen_extract(
zip_files: List[str],
clear_dir_first: Optional[List[str]] = None,
sub_dir: str = "python",
):
r = runfiles.Create()
_repo_name = "io_ray"
root_dir = os.environ.get("BUILD_WORKSPACE_DIRECTORY")
if not root_dir:
raise ValueError(
"BUILD_WORKSPACE_DIRECTORY not set; please run this script from 'bazelisk run'"
)
if sub_dir:
extract_dir = os.path.join(root_dir, sub_dir)
else:
extract_dir = root_dir
if clear_dir_first:
for d in clear_dir_first:
shutil.rmtree(os.path.join(extract_dir, d), ignore_errors=True)
for zip_file in zip_files:
zip_path = r.Rlocation(_repo_name + "/" + zip_file)
if not zip_path:
raise ValueError(f"Zip file {zip_file} not found")
# Uses unzip; python zipfile does not restore the file permissions correctly.
subprocess.check_call(["unzip", "-q", "-o", zip_path, "-d", extract_dir])
+65
View File
@@ -0,0 +1,65 @@
COPTS = ["-DUSE_SSL=1"] + select({
"@platforms//os:windows": [
"-D_CRT_DECLARE_NONSTDC_NAMES=0", # don't define off_t, to avoid conflicts
"-D_WIN32",
"-DOPENSSL_IS_BORINGSSL",
"-DWIN32_LEAN_AND_MEAN"
],
"//conditions:default": [
],
}) + select({
"@//:msvc-cl": [
],
"//conditions:default": [
# Old versions of GCC (e.g. 4.9.2) can fail to compile Redis's C without this.
"-std=c99",
],
})
LOPTS = select({
"@platforms//os:windows": [
"-DefaultLib:" + "Crypt32.lib",
],
"//conditions:default": [
],
})
# This library is for internal hiredis use, because hiredis assumes a
# different include prefix for itself than external libraries do.
cc_library(
name = "_hiredis",
hdrs = [
"dict.c",
],
copts = COPTS,
)
cc_library(
name = "hiredis",
srcs = glob(
[
"*.c",
"*.h",
],
exclude =
[
"test.c",
],
),
hdrs = glob([
"*.h",
"adapters/*.h",
]),
includes = [
".",
],
copts = COPTS,
linkopts = LOPTS,
include_prefix = "hiredis",
deps = [
":_hiredis",
"@boringssl//:ssl",
"@boringssl//:crypto"
],
visibility = ["//visibility:public"],
)
+32
View File
@@ -0,0 +1,32 @@
load("@rules_foreign_cc//foreign_cc:configure.bzl", "configure_make")
load("@io_ray//bazel:ray.bzl", "filter_files_with_suffix")
filegroup(
name = "all",
srcs = glob(["**"]),
)
configure_make(
name = "libjemalloc",
lib_source = ":all",
linkopts = ["-ldl"],
copts = ["-fPIC"],
args = ["-j"],
out_shared_libs = ["libjemalloc.so"],
# See https://salsa.debian.org/debian/jemalloc/-/blob/c0a88c37a551be7d12e4863435365c9a6a51525f/debian/rules#L8-23
# for why we are setting "--with-lg-page" on non x86 hardware here.
configure_options = ["--disable-static", "--enable-prof", "--enable-prof-libunwind"] +
select({
"@platforms//cpu:x86_64": [],
"//conditions:default": ["--with-lg-page=16"],
}),
visibility = ["//visibility:public"],
)
filter_files_with_suffix(
name = "shared",
srcs = ["@jemalloc//:libjemalloc"],
suffix = ".so",
visibility = ["//visibility:public"],
)
+46
View File
@@ -0,0 +1,46 @@
filegroup(
name = "msgpack_hdrs",
srcs = glob([
"include/**/*.h",
"include/**/*.hpp",
]),
visibility = ["//visibility:public"],
)
# This library is for internal use, because the library assumes a
# different include prefix for itself than external libraries do.
cc_library(
name = "_msgpack",
hdrs = [":msgpack_hdrs"],
strip_include_prefix = "include",
)
cc_library(
name = "msgpack",
srcs = [
"src/objectc.c",
"src/unpack.c",
"src/version.c",
"src/vrefbuffer.c",
"src/zone.c",
],
hdrs = [
"include/msgpack.h",
"include/msgpack.hpp",
],
includes = [
"include/",
],
strip_include_prefix = "include",
copts = select({
"@platforms//os:windows": [],
# Ray doesn't control third-party libraries' implementation, simply ignores certain warning errors.
"//conditions:default": [
"-Wno-shadow",
],
}),
deps = [
":_msgpack",
],
visibility = ["//visibility:public"],
)
+15
View File
@@ -0,0 +1,15 @@
filegroup(
name = "nlohmann_json_hdrs",
srcs = glob([
"single_include/**/*.hpp",
]),
visibility = ["//visibility:public"],
)
cc_library(
name = "nlohmann_json",
hdrs = [":nlohmann_json_hdrs"],
includes = ["single_include"],
visibility = ["//visibility:public"],
alwayslink = 1,
)
+10
View File
@@ -0,0 +1,10 @@
import sys
import pytest
if __name__ == "__main__":
exit_code = pytest.main(sys.argv[1:])
if exit_code is pytest.ExitCode.NO_TESTS_COLLECTED:
exit_code = pytest.ExitCode.OK
sys.exit(exit_code)
+135
View File
@@ -0,0 +1,135 @@
load("@bazel_skylib//lib:paths.bzl", "paths")
# py_test_module_list creates a py_test target for each
# Python file in `files`
def _convert_target_to_import_path(t):
"""Get a Python import path for the provided bazel file target."""
if not t.startswith("//"):
fail("Must be an absolute target starting in '//'.")
if not t.endswith(".py"):
fail("Must end in '.py'.")
# 1) Strip known prefix and suffix (validated above).
t = t[len("//"):-len(".py")]
# 2) Normalize separators to '/'.
t = t.replace(":", "/")
# 3) Replace '/' with '.' to form an import path.
return t.replace("/", ".")
def doctest_each(files, gpu = False, deps=[], srcs=[], data=[], args=[], size="medium", tags=[], pytest_plugin_file="//bazel:default_doctest_pytest_plugin.py", **kwargs):
# Unlike the `doctest` macro, `doctest_each` runs `pytest` on each file separately.
# This is useful to run tests in parallel and more clearly report the test results.
for file in files:
doctest(
files = [file],
gpu = gpu,
name = paths.split_extension(file)[0],
deps = deps,
srcs = srcs,
data = data,
args = args,
size = size,
tags = tags,
pytest_plugin_file = pytest_plugin_file,
**kwargs
)
def doctest(files, gpu = False, name="doctest", deps=[], srcs=[], data=[], args=[], size="medium", tags=[], pytest_plugin_file="//bazel:default_doctest_pytest_plugin.py", **kwargs):
# NOTE: If you run `pytest` on `__init__.py`, it tries to test all files in that
# package. We don't want that, so we exclude it from the list of input files.
files = native.glob(include=files, exclude=["__init__.py"])
if gpu:
name += "[gpu]"
tags = tags + ["gpu"]
else:
tags = tags + ["cpu"]
native.py_test(
name = name,
srcs = ["//bazel:pytest_wrapper.py"] + srcs,
main = "//bazel:pytest_wrapper.py",
size = size,
args = [
"--doctest-modules",
"--doctest-glob='*.md'",
"--disable-warnings",
"-v",
# Don't pick up the global pytest.ini for doctests.
"-c", "NO_PYTEST_CONFIG",
# Pass the provided pytest plugin as a Python import path.
"-p", _convert_target_to_import_path(pytest_plugin_file),
] + args + ["$(location :%s)" % file for file in files],
data = [pytest_plugin_file] + files + data,
python_version = "PY3",
srcs_version = "PY3",
tags = ["doctest"] + tags,
deps = ["//:ray_lib"] + deps,
**kwargs
)
def py_test_module_list(files, size, deps, extra_srcs=[], name_suffix="", **kwargs):
for file in files:
# remove .py
name = paths.split_extension(file)[0] + name_suffix
if name == file:
basename = basename + "_test"
native.py_test(
name = name,
size = size,
main = file,
srcs = extra_srcs + [file],
deps = deps,
**kwargs
)
def py_test_run_all_subdirectory(include, exclude, extra_srcs, **kwargs):
for file in native.glob(include = include, exclude = exclude, allow_empty=False):
basename = paths.split_extension(file)[0]
if basename == file:
basename = basename + "_test"
native.py_test(
name = basename,
srcs = extra_srcs + [file],
**kwargs
)
# Runs all included notebooks as py_test targets, by first converting them to .py files with "test_myst_doc.py".
def py_test_run_all_notebooks(include, exclude, allow_empty=False, **kwargs):
for file in native.glob(include = include, exclude = exclude, allow_empty=allow_empty):
print(file)
basename = paths.split_extension(file)[0]
if basename == file:
basename = basename + "_test"
native.py_test(
name = basename,
main = "test_myst_doc.py",
srcs = ["//doc:test_myst_doc.py"],
# --find-recursively will look for file in all
# directories inside cwd recursively if it cannot
# find it right away. This allows to deal with
# mismatches between `name` and `data` args.
args = ["--find-recursively", "--path", file],
**kwargs
)
def py_test_module_list_with_env_variants(files, env_variants, size="medium", **kwargs):
"""Create multiple py_test_module_list targets with different environment variable configurations.
Args:
files: List of test files to run
env_variants: Dict where keys are variant names and values are dicts containing
'env' and 'name_suffix' keys
size: Test size
**kwargs: Additional arguments passed to py_test_module_list
"""
for variant_name, variant_config in env_variants.items():
py_test_module_list(
size = size,
files = files,
env = variant_config.get("env", {}),
name_suffix = variant_config.get("name_suffix", "_{}".format(variant_name)),
**kwargs
)
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
# This script is used to zip a directory into a zip file.
# It only uses python standard library, so it can be portable and used in bazel.
import os
import os.path
import sys
import zipfile
# Everything in the zip file is stored with this timestamp.
# This makes the zip file building deterministic and reproducible.
_TIMESTAMP = (2020, 1, 1, 0, 0, 0)
_UNIX_DIR_BIT = 0o040000
_MSDOS_DIR_BIT = 0x10
_DIR_BIT = (_UNIX_DIR_BIT << 16) | _MSDOS_DIR_BIT | (0o755 << 16)
_FILE_BIT = (0o100000 << 16) | (0o644 << 16)
def zip_dir(dir_path: str, output_zip_path: str):
with zipfile.ZipFile(output_zip_path, "w") as output:
for root, _, files in os.walk(dir_path):
if root != dir_path:
dir_zip_path = os.path.relpath(root, dir_path)
dir_zip_info = zipfile.ZipInfo(dir_zip_path + "/", date_time=_TIMESTAMP)
dir_zip_info.external_attr |= _DIR_BIT
dir_zip_info.flag_bits |= 0x800 # UTF-8 encoded file name.
output.writestr(dir_zip_info, "", compress_type=zipfile.ZIP_STORED)
for f in files:
file_path = os.path.join(root, f)
zip_path = os.path.relpath(file_path, dir_path)
zip_info = zipfile.ZipInfo(zip_path, date_time=_TIMESTAMP)
zip_info.flag_bits |= 0x800 # UTF-8 encoded file name.
zip_info.external_attr |= _FILE_BIT
with open(file_path, "rb") as f:
content = f.read()
output.writestr(zip_info, content, compress_type=zipfile.ZIP_STORED)
if __name__ == "__main__":
zip_dir(sys.argv[1], sys.argv[2])
+22
View File
@@ -0,0 +1,22 @@
licenses(["notice"])
package(default_visibility = ["//visibility:public"])
filegroup(
name = "license",
srcs = ["license.txt"],
)
cc_library(
name = "rapidjson",
hdrs = glob([
"include/rapidjson/*.h",
"include/rapidjson/*/*.h",
]),
copts = [
"-Wno-non-virtual-dtor",
"-Wno-unused-variable",
"-Wno-implicit-fallthrough",
],
includes = ["include"],
)
+195
View File
@@ -0,0 +1,195 @@
load("@bazel_common//tools/maven:pom_file.bzl", "pom_file")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_library_public")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
COPTS_TESTS = select({
"//:opt": ["-DBAZEL_OPT"],
"//conditions:default": [],
}) + select({
"@platforms//os:windows": [
# TODO(mehrdadn): (How to) support dynamic linking?
"-DRAY_STATIC",
# Prevent Windows.h from including WinSock.h, which conflicts with
# WinSock2.h used by Boost.Asio.
"-DWIN32_LEAN_AND_MEAN",
],
"//conditions:default": [
"-Wunused-result",
"-Wconversion-null",
"-Wno-misleading-indentation",
"-Wimplicit-fallthrough",
],
}) + select({
"//:clang-cl": [
"-Wno-builtin-macro-redefined", # To get rid of warnings caused by deterministic build macros (e.g. #define __DATE__ "redacted")
"-Wno-microsoft-unqualified-friend", # This shouldn't normally be enabled, but otherwise we get: google/protobuf/map_field.h: warning: unqualified friend declaration referring to type outside of the nearest enclosing namespace is a Microsoft extension; add a nested name specifier (for: friend class DynamicMessage)
],
"//conditions:default": [],
})
COPTS = COPTS_TESTS + select({
"@platforms//os:windows": [""],
"//conditions:default": ["-Wshadow"],
})
PYX_COPTS = select({
"//:msvc-cl": [],
"//conditions:default": [
# Ignore this warning since CPython and Cython have issue removing deprecated tp_print on MacOS
"-Wno-deprecated-declarations",
"-Wno-shadow",
"-Wno-implicit-fallthrough",
],
}) + select({
"@platforms//os:windows": [
"/FI" + "src/shims/windows/python-nondebug.h",
],
"//conditions:default": [],
})
PYX_SRCS = [] + select({
"@platforms//os:windows": [
"src/shims/windows/python-nondebug.h",
],
"//conditions:default": [],
})
def flatbuffer_py_library(name, srcs, outs, out_prefix, includes = [], include_paths = []):
flatbuffer_library_public(
name = name,
srcs = srcs,
outs = outs,
language_flag = "-p",
out_prefix = out_prefix,
include_paths = include_paths,
includes = includes,
)
def define_java_module(
name,
additional_srcs = [],
exclude_srcs = [],
additional_resources = [],
define_test_lib = False,
test_deps = [],
**kwargs):
"""
Defines a ray Java module with a pom file.
Args:
name: The base name of the module.
additional_srcs: Additional source files to include in the module.
exclude_srcs: Source files to exclude from the module.
additional_resources: Additional resources to include in the module.
define_test_lib: Whether to define a test library for the module.
test_deps: Dependencies for the test library; only used if define_test_lib is True.
**kwargs: Additional arguments to pass to the java_library rule.
"""
lib_name = "io_ray_ray_" + name
pom_file_targets = [lib_name]
native.java_library(
name = lib_name,
srcs = additional_srcs + native.glob(
[name + "/src/main/java/**/*.java"],
exclude = exclude_srcs,
),
resources = native.glob([name + "/src/main/resources/**"]) + additional_resources,
**kwargs
)
if define_test_lib:
test_lib_name = "io_ray_ray_" + name + "_test"
pom_file_targets.append(test_lib_name)
native.java_library(
name = test_lib_name,
srcs = native.glob([name + "/src/test/java/**/*.java"]),
deps = test_deps,
)
pom_file(
name = "io_ray_ray_" + name + "_pom",
targets = pom_file_targets,
template_file = name + "/pom_template.xml",
substitutions = {
"{auto_gen_header}": "<!-- This file is auto-generated by Bazel from pom_template.xml, do not modify it. -->",
},
)
def native_java_library(module_name, name, native_library_name):
"""Copy native library file to different path based on operating systems"""
copy_file(
name = name + "_darwin",
src = native_library_name,
out = module_name + "/src/main/resources/native/darwin/lib{}.dylib".format(name),
)
copy_file(
name = name + "_linux",
src = native_library_name,
out = module_name + "/src/main/resources/native/linux/lib{}.so".format(name),
)
native.filegroup(
name = name,
srcs = select({
"@platforms//os:osx": [name + "_darwin"],
"@platforms//os:windows": [],
"//conditions:default": [name + "_linux"],
}),
visibility = ["//visibility:public"],
)
def ray_cc_library(name, strip_include_prefix = "/src", copts = [], visibility = ["//visibility:public"], **kwargs):
cc_library(
name = name,
strip_include_prefix = strip_include_prefix,
copts = COPTS + copts,
visibility = visibility,
**kwargs
)
def ray_cc_test(name, deps = [], linkopts = [], copts = [], use_ray_gtest_main = True, **kwargs):
# By default, all `ray_cc_test` targets use `ray_gtest_main`.
# Some tests might need bespoke setup logic, so let them skip this dependency.
if use_ray_gtest_main:
deps = deps + ["//src/ray/common:ray_gtest_main"]
cc_test(
name = name,
deps = deps,
copts = COPTS_TESTS + copts,
linkopts = linkopts + ["-pie"],
**kwargs
)
def ray_cc_binary(name, linkopts = [], copts = [], **kwargs):
cc_binary(
name = name,
copts = COPTS + copts,
linkopts = linkopts + ["-pie"],
**kwargs
)
def _filter_files_with_suffix_impl(ctx):
suffix = ctx.attr.suffix
filtered_files = [f for f in ctx.files.srcs if f.basename.endswith(suffix)]
print(filtered_files)
return [
DefaultInfo(
files = depset(filtered_files),
),
]
filter_files_with_suffix = rule(
implementation = _filter_files_with_suffix_impl,
attrs = {
"srcs": attr.label_list(allow_files = True),
"suffix": attr.string(),
},
)
# It will be passed to the FlatBuffers compiler when defining flatbuffer_cc_library
FLATC_ARGS = [
"--gen-object-api",
"--gen-mutable",
"--scoped-enums",
]
+24
View File
@@ -0,0 +1,24 @@
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
load("@io_ray//java:dependencies.bzl", "gen_java_deps")
load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
load("@com_github_jupp0r_prometheus_cpp//bazel:repositories.bzl", "prometheus_cpp_repositories")
load("@com_github_grpc_grpc//third_party/py:python_configure.bzl", "python_configure")
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_toolchains")
load("@com_github_johnynek_bazel_jar_jar//:jar_jar.bzl", "jar_jar_repositories")
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
load("@rules_foreign_cc_thirdparty//openssl:openssl_setup.bzl", "openssl_setup")
def ray_deps_build_all():
bazel_skylib_workspace()
gen_java_deps()
boost_deps()
prometheus_cpp_repositories()
python_configure(name = "local_config_python")
grpc_deps()
rules_proto_grpc_toolchains()
jar_jar_repositories()
rules_foreign_cc_dependencies()
openssl_setup()
+474
View File
@@ -0,0 +1,474 @@
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
def urlsplit(url):
""" Splits a URL like "https://example.com/a/b?c=d&e#f" into a tuple:
("https", ["example", "com"], ["a", "b"], ["c=d", "e"], "f")
A trailing slash will result in a correspondingly empty final path component.
"""
split_on_anchor = url.split("#", 1)
split_on_query = split_on_anchor[0].split("?", 1)
split_on_scheme = split_on_query[0].split("://", 1)
if len(split_on_scheme) <= 1: # Scheme is optional
split_on_scheme = [None] + split_on_scheme[:1]
split_on_path = split_on_scheme[1].split("/")
return {
"scheme": split_on_scheme[0],
"netloc": split_on_path[0].split("."),
"path": split_on_path[1:],
"query": split_on_query[1].split("&") if len(split_on_query) > 1 else None,
"fragment": split_on_anchor[1] if len(split_on_anchor) > 1 else None,
}
def auto_http_archive(
*,
name = None,
url = None,
urls = True,
build_file = None,
build_file_content = None,
strip_prefix = True,
**kwargs):
""" Intelligently choose mirrors based on the given URL for the download.
Either url or urls is required.
If name == None , it is auto-deduced, but this is NOT recommended.
If urls == True , mirrors are automatically chosen.
If build_file == True , it is auto-deduced.
If strip_prefix == True , it is auto-deduced.
"""
DOUBLE_SUFFIXES_LOWERCASE = [("tar", "bz2"), ("tar", "gz"), ("tar", "xz")]
mirror_prefixes = ["https://mirror.bazel.build/", "https://storage.googleapis.com/bazel-mirror"]
canonical_url = url if url != None else urls[0]
url_parts = urlsplit(canonical_url)
url_except_scheme = (canonical_url.replace(url_parts["scheme"] + "://", "") if url_parts["scheme"] != None else canonical_url)
url_path_parts = url_parts["path"]
url_filename = url_path_parts[-1]
url_filename_parts = (url_filename.rsplit(".", 2) if (tuple(url_filename.lower().rsplit(".", 2)[-2:]) in
DOUBLE_SUFFIXES_LOWERCASE) else url_filename.rsplit(".", 1))
is_github = url_parts["netloc"] == ["github", "com"]
if name == None: # Deduce "com_github_user_project_name" from "https://github.com/user/project-name/..."
name = "_".join(url_parts["netloc"][::-1] + url_path_parts[:2]).replace("-", "_")
# auto appending ray project namespace prefix for 3rd party library reusing.
if build_file == True:
build_file = "@io_ray//%s:%s" % ("bazel", name + ".BUILD")
if urls == True:
prefer_url_over_mirrors = is_github
urls = [
mirror_prefix + url_except_scheme
for mirror_prefix in mirror_prefixes
if not canonical_url.startswith(mirror_prefix)
]
urls.insert(0 if prefer_url_over_mirrors else len(urls), canonical_url)
else:
print("No implicit mirrors used for %s because urls were explicitly provided" % name)
if strip_prefix == True:
prefix_without_v = url_filename_parts[0]
if prefix_without_v.startswith("v") and prefix_without_v[1:2].isdigit():
# GitHub automatically strips a leading 'v' in version numbers
prefix_without_v = prefix_without_v[1:]
strip_prefix = (url_path_parts[1] + "-" + prefix_without_v if is_github and url_path_parts[2:3] == ["archive"] else url_filename_parts[0])
return http_archive(
name = name,
url = url,
urls = urls,
build_file = build_file,
build_file_content = build_file_content,
strip_prefix = strip_prefix,
**kwargs
)
def ray_deps_setup():
# Override build_bazel_rules_apple and build_bazel_apple_support before
# grpc_deps() runs. gRPC's rules_apple 1.1.3 uses apple_common.multi_arch_split
# which was removed in Bazel 7. rules_apple 3.2.1 is compatible with Bazel 6/7/8
# but requires apple_support >= 1.11.1 (for the configs/ package layout).
auto_http_archive(
name = "build_bazel_rules_apple",
sha256 = "9c4f1e1ec4fdfeac5bddb07fa0e872c398e3d8eb0ac596af9c463f9123ace292",
url = "https://github.com/bazelbuild/rules_apple/releases/download/3.2.1/rules_apple.3.2.1.tar.gz",
strip_prefix = "",
)
auto_http_archive(
name = "build_bazel_apple_support",
sha256 = "cf4d63f39c7ba9059f70e995bf5fe1019267d3f77379c2028561a5d7645ef67c",
url = "https://github.com/bazelbuild/apple_support/releases/download/1.11.1/apple_support.1.11.1.tar.gz",
strip_prefix = "",
patches = [
# In Bazel 7, local_config_apple_cc calls is_xcode_at_least_version
# during analysis. On CI machines with only Xcode CLT (no full Xcode
# app) xcode_config.xcode_version() returns None, causing a hard
# failure. Return False instead so the feature is disabled gracefully.
"//thirdparty/patches:build-bazel-apple-support-xcode.patch",
],
patch_args = ["-p1"],
)
# Explicitly bring in protobuf dependency to work around
# https://github.com/ray-project/ray/issues/14117
# This is copied from grpc's bazel/grpc_deps.bzl
#
# Pinned grpc version: v23.4
auto_http_archive(
name = "com_google_protobuf",
sha256 = "76a33e2136f23971ce46c72fd697cd94dc9f73d56ab23b753c3e16854c90ddfd",
url = "https://github.com/protocolbuffers/protobuf/archive/2c5fa078d8e86e5f4bd34e6f4c9ea9e8d7d4d44a.tar.gz",
patches = [
"@com_github_grpc_grpc//third_party:protobuf.patch",
"//thirdparty/patches:protobuf-bazel7.patch",
],
patch_args = ["-p1"],
)
# NOTE(lingxuan.zlx): 3rd party dependencies could be accessed, so it suggests
# all of http/git_repository should add prefix for patches defined in ray directory.
auto_http_archive(
name = "com_github_antirez_redis",
build_file = "@io_ray//bazel:redis.BUILD",
patch_args = ["-p1"],
url = "https://github.com/redis/redis/archive/refs/tags/7.2.3.tar.gz",
sha256 = "afd656dbc18a886f9a1cc08a550bf5eb89de0d431e713eba3ae243391fb008a6",
patches = [
"@io_ray//thirdparty/patches:redis-quiet.patch",
],
workspace_file_content = 'workspace(name = "com_github_antirez_redis")',
)
auto_http_archive(
name = "com_github_redis_hiredis",
build_file = "@io_ray//bazel:hiredis.BUILD",
url = "https://github.com/redis/hiredis/archive/60e5075d4ac77424809f855ba3e398df7aacefe8.tar.gz",
sha256 = "b6d6f799b7714d85316f9ebfb76a35a78744f42ea3b6774289d882d13a2f0383",
patches = [
"@io_ray//thirdparty/patches:hiredis-windows-msvc.patch",
],
)
auto_http_archive(
name = "com_github_spdlog",
build_file = "@io_ray//bazel:spdlog.BUILD",
url = "https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.zip",
sha256 = "b74274c32c8be5dba70b7006c1d41b7d3e5ff0dff8390c8b6390c1189424e094",
# spdlog rotation filename format conflict with ray, update the format.
patches = [
"@io_ray//thirdparty/patches:spdlog-rotation-file-format.patch",
],
patch_args = ["-p1"],
)
auto_http_archive(
name = "com_github_tporadowski_redis_bin",
build_file = "@io_ray//bazel:redis.BUILD",
strip_prefix = None,
url = "https://github.com/tporadowski/redis/releases/download/v5.0.9/Redis-x64-5.0.9.zip",
sha256 = "b09565b22b50c505a5faa86a7e40b6683afb22f3c17c5e6a5e35fc9b7c03f4c2",
)
# RocksDB is the embedded storage backend for GCS fault tolerance
# (REP-64). It is built minimally via rules_foreign_cc's cmake() rule;
# see bazel/rocksdb.BUILD for the build configuration.
#
# Version constraint: pin to a RocksDB release that supports C++17.
# RocksDB 10.7.0 (Sep 2025) raised the minimum to C++20 for both the
# library and any code including its headers (GCC >= 11, Clang >= 10,
# MSVC >= 2019). Ray's .bazelrc sets `-std=c++17`, so bumping past
# 10.6.2 requires a coordinated C++20 migration across Ray. v10.6.2
# is the latest C++17-compatible release; keep it until/unless Ray
# itself moves to C++20.
auto_http_archive(
name = "com_github_facebook_rocksdb",
build_file = "@io_ray//bazel:rocksdb.BUILD",
url = "https://github.com/facebook/rocksdb/archive/refs/tags/v10.6.2.tar.gz",
sha256 = "14c619b8a10f994aa6061bd12182b20270c4c27c2f3d9cb4376d57f3cd1c5d7f",
)
auto_http_archive(
name = "rules_jvm_external",
url = "https://github.com/bazelbuild/rules_jvm_external/archive/2.10.tar.gz",
sha256 = "5c1b22eab26807d5286ada7392d796cbc8425d3ef9a57d114b79c5f8ef8aca7c",
)
auto_http_archive(
name = "bazel_common",
url = "https://github.com/google/bazel-common/archive/084aadd3b854cad5d5e754a7e7d958ac531e6801.tar.gz",
sha256 = "a6e372118bc961b182a3a86344c0385b6b509882929c6b12dc03bb5084c775d5",
)
auto_http_archive(
name = "bazel_skylib",
sha256 = "9f38886a40548c6e96c106b752f242130ee11aaa068a56ba7e56f4511f33e4f2",
url = "https://github.com/bazelbuild/bazel-skylib/releases/download/1.6.1/bazel-skylib-1.6.1.tar.gz",
strip_prefix = None
)
# Declare org_lzma_lzma before com_github_nelhage_rules_boost so that
# boost_deps()'s maybe() skips it and uses this declaration instead.
# Using a local build_file forces content-based cache invalidation:
# changing org_lzma_lzma.BUILD.bazel triggers re-setup on all machines,
# including Windows CI with persistent output bases where patching
# rules_boost's BUILD.lzma would not propagate (build_file label strings
# are used for fingerprinting, not file contents of external-repo labels).
auto_http_archive(
name = "org_lzma_lzma",
sha256 = "06327c2ddc81e126a6d9a78b0be5014b976a2c0832f492dcfc4755d7facf6d33",
strip_prefix = "xz-5.2.7",
urls = [
"https://cfhcable.dl.sourceforge.net/project/lzmautils/xz-5.2.7.tar.gz",
"https://superb-sea2.dl.sourceforge.net/project/lzmautils/xz-5.2.7.tar.gz",
"https://ayera.dl.sourceforge.net/project/lzmautils/xz-5.2.7.tar.gz",
"https://astuteinternet.dl.sourceforge.net/project/lzmautils/xz-5.2.7.tar.gz",
],
build_file = "//thirdparty/patches:org_lzma_lzma.BUILD.bazel",
)
auto_http_archive(
name = "com_github_nelhage_rules_boost",
# If you update the Boost version, remember to update the 'boost' rule.
url = "https://github.com/nelhage/rules_boost/archive/57c99395e15720e287471d79178d36a85b64d6f6.tar.gz",
sha256 = "490d11425393eed068966a4990ead1ff07c658f823fd982fddac67006ccc44ab",
patches = [
"//thirdparty/patches:boost-headers.patch",
],
patch_args = ["-p1"],
)
auto_http_archive(
name = "com_github_google_flatbuffers",
url = "https://github.com/google/flatbuffers/archive/refs/tags/v25.2.10.tar.gz",
sha256 = "b9c2df49707c57a48fc0923d52b8c73beb72d675f9d44b2211e4569be40a7421",
)
auto_http_archive(
name = "com_google_googletest",
url = "https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz",
sha256 = "8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7",
)
auto_http_archive(
name = "com_github_gflags_gflags",
url = "https://github.com/gflags/gflags/archive/e171aa2d15ed9eb17054558e0b3a6a413bb01067.tar.gz",
sha256 = "b20f58e7f210ceb0e768eb1476073d0748af9b19dfbbf53f4fd16e3fb49c5ac8",
)
auto_http_archive(
name = "cython",
build_file = True,
url = "https://github.com/cython/cython/archive/refs/tags/3.0.12.tar.gz",
sha256 = "a156fff948c2013f2c8c398612c018e2b52314fdf0228af8fbdb5585e13699c2",
patches = [
# Use python3 rather than python. macos does not have python installed
# by default, and hermetic strict action does not work as python cannot
# be found under /usr/bin or any systeme PATH in bazel sandbox.
#
# This patch can be removed after the following change is included.
# https://github.com/cython/cython/pull/7053
"//thirdparty/patches:cython.patch",
],
)
auto_http_archive(
name = "com_github_johnynek_bazel_jar_jar",
url = "https://github.com/johnynek/bazel_jar_jar/archive/171f268569384c57c19474b04aebe574d85fde0d.tar.gz",
sha256 = "97c5f862482a05f385bd8f9d28a9bbf684b0cf3fae93112ee96f3fb04d34b193",
)
auto_http_archive(
name = "io_opencensus_cpp",
url = "https://github.com/census-instrumentation/opencensus-cpp/archive/5e5f2632c84e2230fb7ccb8e336f603d2ec6aa1b.zip",
sha256 = "1b88d6663f05c6a56c1604eb2afad22831d5f28a76f6fab8f37187f1e4ace425",
patches = [
"@io_ray//thirdparty/patches:opencensus-cpp-harvest-interval.patch",
"@io_ray//thirdparty/patches:opencensus-cpp-shutdown-api.patch",
],
patch_args = ["-p1"],
)
# WARNING: Upgrading the OTEL version caused a major regression in actor creation/task throughput.
# Verify that this regression is fixed before upgrading the below two OTEL versions.
auto_http_archive(
name = "io_opentelemetry_cpp",
url = "https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.19.0.zip",
sha256 = "8ef0a63f4959d5dfc3d8190d62229ef018ce41eef36e1f3198312d47ab2de05a",
# Enable mTLS support for OTLP gRPC exporter.
# This is required because Ray's gRPC servers require client certificates when TLS is enabled.
# See https://github.com/ray-project/ray/issues/59968
patches = [
"@io_ray//thirdparty/patches:opentelemetry-cpp-enable-mtls.patch",
],
patch_args = ["-p1"],
)
auto_http_archive(
name = "com_github_opentelemetry_proto",
url = "https://github.com/open-telemetry/opentelemetry-proto/archive/refs/tags/v1.2.0.zip",
build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD",
sha256 = "b3cf4fefa4eaea43879ade612639fa7029c624c1b959f019d553b86ad8e01e82",
)
# OpenCensus depends on Abseil so we have to explicitly pull it in.
# This is how diamond dependencies are prevented.
#
# TODO(owner): Upgrade abseil to latest version after protobuf updated, which requires to upgrade `rules_cc` first.
auto_http_archive(
name = "com_google_absl",
sha256 = "987ce98f02eefbaf930d6e38ab16aa05737234d7afbab2d5c4ea7adbe50c28ed",
url = "https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.tar.gz",
patches = [
# TODO (israbbani): #55430 Separate the compiler flags and remove this patch
"@io_ray//thirdparty/patches:abseil-cpp-shadow.patch",
],
)
# OpenCensus depends on jupp0r/prometheus-cpp
auto_http_archive(
name = "com_github_jupp0r_prometheus_cpp",
url = "https://github.com/jupp0r/prometheus-cpp/archive/60eaa4ea47b16751a8e8740b05fe70914c68a480.tar.gz",
sha256 = "ec825b802487ac18b0d98e2e8b7961487b12562f8f82e424521d0a891d9e1373",
patches = [
"@io_ray//thirdparty/patches:prometheus-windows-headers.patch",
# https://github.com/jupp0r/prometheus-cpp/pull/225
"@io_ray//thirdparty/patches:prometheus-windows-zlib.patch",
"@io_ray//thirdparty/patches:prometheus-windows-pollfd.patch",
"@io_ray//thirdparty/patches:prometheus-zlib-fdopen.patch",
],
)
auto_http_archive(
name = "com_github_grpc_grpc",
# NOTE: If you update this, also update @boringssl's hash.
url = "https://github.com/grpc/grpc/archive/refs/tags/v1.58.0.tar.gz",
sha256 = "ec64fdab22726d50fc056474dd29401d914cc616f53ab8f2fe4866772881d581",
patches = [
"@io_ray//thirdparty/patches:grpc-cython-copts.patch",
# Work around bazelbuild/bazel#21592: with layering_check and
# non-sandbox/local spawn, clang can record transitive *.cppmap files
# in .d files, which Bazel then reports as undeclared direct deps.
# Fixed in Bazel 7.3.0. LLVM used the same workaround by disabling
# layering_check in Bazel overlays (llvm/llvm-project@5bba176).
"@io_ray//thirdparty/patches:grpc-disable-layering-check.patch",
"@io_ray//thirdparty/patches:grpc-zlib-fdopen.patch",
"@io_ray//thirdparty/patches:grpc-configurable-thread-count.patch",
"@io_ray//thirdparty/patches:grpc-nextresult-cancelled-init.patch",
],
)
auto_http_archive(
name = "openssl",
strip_prefix = "openssl-1.1.1f",
sha256 = "186c6bfe6ecfba7a5b48c47f8a1673d0f3b0e5ba2e25602dd23b629975da3f35",
urls = [
"https://openssl.org/source/old/1.1.1/openssl-1.1.1f.tar.gz",
],
build_file = "@rules_foreign_cc_thirdparty//openssl:BUILD.openssl.bazel",
)
auto_http_archive(
name = "rules_foreign_cc",
sha256 = "2a4d07cd64b0719b39a7c12218a3e507672b82a97b98c6a89d38565894cf7c51",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/refs/tags/0.9.0.tar.gz",
)
# Using shallow_since allows the rule to clone down fewer commits.
# Reference: https://bazel.build/rules/lib/repo/git
git_repository(
name = "rules_perl",
remote = "https://github.com/bazelbuild/rules_perl.git",
commit = "022b8daf2bb4836ac7a50e4a1d8ea056a3e1e403",
shallow_since = "1663780239 -0700",
)
auto_http_archive(
name = "rules_foreign_cc_thirdparty",
sha256 = "2a4d07cd64b0719b39a7c12218a3e507672b82a97b98c6a89d38565894cf7c51",
strip_prefix = "rules_foreign_cc-0.9.0/examples/third_party",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/refs/tags/0.9.0.tar.gz",
)
auto_http_archive(
# This rule is used by @com_github_grpc_grpc, and using a GitHub mirror
# provides a deterministic archive hash for caching. Explanation here:
# https://github.com/grpc/grpc/blob/1ff1feaa83e071d87c07827b0a317ffac673794f/bazel/grpc_deps.bzl#L189
# Ensure this rule matches the rule used by grpc's bazel/grpc_deps.bzl
name = "boringssl",
sha256 = "b21994a857a7aa6d5256ffe355c735ad4c286de44c6c81dfc04edc41a8feaeef",
url = "https://github.com/google/boringssl/archive/2ff4b968a7e0cfee66d9f151cb95635b43dc1d5b.tar.gz",
)
# The protobuf version we use to auto generate python and java code.
# This can be different from the protobuf version that Ray core uses internally.
# Generally this should be a lower version since protobuf guarantees that
# code generated by protoc of version X can be used with protobuf library of version >= X.
# So the version here effectively determines the lower bound of python/java
# protobuf library that Ray supports.
auto_http_archive(
name = "com_google_protobuf_rules_proto_grpc",
url = "https://github.com/protocolbuffers/protobuf/archive/v3.20.3.tar.gz",
sha256 = "9c0fd39c7a08dff543c643f0f4baf081988129a411b977a07c46221793605638",
)
auto_http_archive(
name = "rules_proto_grpc",
url = "https://github.com/rules-proto-grpc/rules_proto_grpc/archive/a74fef39c5fe636580083545f76d1eab74f6450d.tar.gz",
sha256 = "2f6606151ec042e23396f07de9e7dcf6ca9a5db1d2b09f0cc93a7fc7f4008d1b",
repo_mapping = {
"@com_google_protobuf": "@com_google_protobuf_rules_proto_grpc",
},
)
auto_http_archive(
name = "msgpack",
build_file = True,
url = "https://github.com/msgpack/msgpack-c/archive/8085ab8721090a447cf98bb802d1406ad7afe420.tar.gz",
sha256 = "83c37c9ad926bbee68d564d9f53c6cbb057c1f755c264043ddd87d89e36d15bb",
patches = [
"@io_ray//thirdparty/patches:msgpack-windows-iovec.patch",
# TODO (israbbani): #55430 Separate the compiler flags and remove this patch
"@io_ray//thirdparty/patches:msgpack-shadow.patch",
],
)
auto_http_archive(
name = "io_opencensus_proto",
strip_prefix = "opencensus-proto-0.3.0/src",
url = "https://github.com/census-instrumentation/opencensus-proto/archive/v0.3.0.tar.gz",
sha256 = "b7e13f0b4259e80c3070b583c2f39e53153085a6918718b1c710caf7037572b0",
)
auto_http_archive(
name = "nlohmann_json",
url = "https://github.com/nlohmann/json/archive/v3.9.1.tar.gz",
sha256 = "4cf0df69731494668bdd6460ed8cb269b68de9c19ad8c27abc24cd72605b2d5b",
build_file = "@io_ray//bazel:nlohmann_json.BUILD",
)
auto_http_archive(
name = "rapidjson",
url = "https://github.com/Tencent/rapidjson/archive/v1.1.0.zip",
build_file = True,
sha256 = "8e00c38829d6785a2dfb951bb87c6974fa07dfe488aa5b25deec4b8bc0f6a3ab",
)
# Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
auto_http_archive(
name = "hedron_compile_commands",
# Replace the commit hash in both places (below) with the latest, rather than using the stale one here.
# Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/2e8b7654fa10c44b9937453fa4974ed2229d5366.tar.gz",
# When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..."
sha256 = "7fbbbc05c112c44e9b406612e6a7a7f4789a6918d7aacefef4c35c105286930c",
)
auto_http_archive(
name = "jemalloc",
url = "https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2",
build_file = "@io_ray//bazel:jemalloc.BUILD",
sha256 = "2db82d1e7119df3e71b7640219b6dfe84789bc0537983c3b7ac4f7189aecfeaa",
strip_prefix = "jemalloc-5.3.0",
)
+80
View File
@@ -0,0 +1,80 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "make")
exports_files(
[
"redis-server.exe",
"redis-cli.exe",
],
visibility = ["//visibility:public"],
)
filegroup(
name = "all_srcs",
srcs = glob(
include = ["**"],
exclude = ["*.bazel"],
),
)
make(
name = "redis",
args = [
"BUILD_TLS=yes",
"-s",
],
copts = [
"-DLUA_USE_MKSTEMP",
"-Wno-pragmas",
"-Wno-empty-body",
"-fPIC",
],
visibility = ["//visibility:public"],
lib_source = ":all_srcs",
deps = [
"@openssl//:openssl",
],
out_binaries = [
"redis-server",
"redis-cli"
]
)
genrule_cmd = select({
"@platforms//os:osx": """
unset CC LDFLAGS CXX CXXFLAGS
tmpdir="redis.tmp"
p=$(location Makefile)
cp -p -L -R -- "$${p%/*}" "$${tmpdir}"
chmod +x "$${tmpdir}"/deps/jemalloc/configure
parallel="$$(getconf _NPROCESSORS_ONLN || echo 1)"
make -s -C "$${tmpdir}" -j"$${parallel}" V=0 CFLAGS="$${CFLAGS-} -DLUA_USE_MKSTEMP -Wno-pragmas -Wno-empty-body"
mv "$${tmpdir}"/src/redis-server $(location redis-server)
chmod +x $(location redis-server)
mv "$${tmpdir}"/src/redis-cli $(location redis-cli)
chmod +x $(location redis-cli)
rm -r -f -- "$${tmpdir}"
""",
"//conditions:default": """
cp $(RULEDIR)/redis/bin/redis-server $(location redis-server)
cp $(RULEDIR)/redis/bin/redis-cli $(location redis-cli)
"""
})
genrule_srcs = select({
"@platforms//os:osx": glob(["**"]),
"//conditions:default": [":redis"],
})
genrule(
name = "bin",
srcs = genrule_srcs,
outs = [
"redis-server",
"redis-cli",
],
cmd = genrule_cmd,
visibility = ["//visibility:public"],
tags = ["local"],
)
+56
View File
@@ -0,0 +1,56 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
filegroup(
name = "all_srcs",
srcs = glob(
include = ["**"],
exclude = ["*.bazel"],
),
)
cmake(
name = "rocksdb",
cache_entries = {
# Static-only build. No shared lib, no shell tools, no benchmarks,
# no tests — librocksdb.a is the only artifact GCS links against.
"ROCKSDB_BUILD_SHARED": "OFF",
"WITH_TESTS": "OFF",
"WITH_BENCHMARK_TOOLS": "OFF",
"WITH_TOOLS": "OFF",
"WITH_CORE_TOOLS": "OFF",
"WITH_TRACE_TOOLS": "OFF",
"WITH_EXAMPLES": "OFF",
"WITH_GFLAGS": "OFF",
# No compression deps for the initial cut — the REP's tuning
# table calls for LZ4 on cold levels, which can be enabled in a
# follow-up once the link footprint is measured against the
# tradeoff.
"WITH_SNAPPY": "OFF",
"WITH_LZ4": "OFF",
"WITH_ZSTD": "OFF",
"WITH_ZLIB": "OFF",
"WITH_BZ2": "OFF",
# Ray vendors its own jemalloc; mixing them is out of scope here.
"WITH_JEMALLOC": "OFF",
"WITH_LIBURING": "OFF",
"WITH_NUMA": "OFF",
"WITH_TBB": "OFF",
# CMake's GNUInstallDirs picks lib64/ on 64-bit Linux but lib/ on
# macOS/BSD. Pinning to lib/ keeps the out_static_libs path
# portable across platforms.
"CMAKE_INSTALL_LIBDIR": "lib",
"PORTABLE": "ON",
"FAIL_ON_WARNINGS": "OFF",
"USE_RTTI": "1",
"ROCKSDB_INSTALL_ON_WINDOWS": "OFF",
"WITH_RUNTIME_DEBUG": "OFF",
},
generate_args = ["-G Ninja"],
lib_source = ":all_srcs",
out_static_libs = ["librocksdb.a"],
visibility = ["//visibility:public"],
)
+23
View File
@@ -0,0 +1,23 @@
COPTS = ["-DSPDLOG_COMPILED_LIB"]
cc_library(
name = "spdlog",
srcs = glob([
"src/*.cpp",
]),
hdrs = glob([
"include/spdlog/*.h",
"include/spdlog/cfg/*.h",
"include/spdlog/details/*.h",
"include/spdlog/fmt/*.h",
"include/spdlog/fmt/bundled/*.h",
"include/spdlog/sinks/*.h",
]),
includes = [
"include/",
],
strip_include_prefix = 'include',
copts = COPTS,
deps = [
],
visibility = ["//visibility:public"],
)
+19
View File
@@ -0,0 +1,19 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
cc_library(
name = "example_lib",
srcs = ["example.cc"],
hdrs = ["example.h"],
visibility = ["//visibility:public"],
)
cc_test(
name = "example_test",
size = "small",
srcs = ["example_test.cc"],
tags = ["team:ci"],
deps = [
":example_lib",
"@com_google_googletest//:gtest_main",
],
)
+9
View File
@@ -0,0 +1,9 @@
#include "example.h"
int SumMapValues(const std::unordered_map<int, int> &map) {
int sum = 0;
for (const auto &[_, val] : map) {
sum += val;
}
return sum;
}
+9
View File
@@ -0,0 +1,9 @@
#ifndef __EXAMPLE_H__
#define __EXAMPLE_H__
#include <unordered_map>
// Function to calculate the sum of values in an unordered_map
int SumMapValues(const std::unordered_map<int, int> &map);
#endif // __EXAMPLE_H__
+10
View File
@@ -0,0 +1,10 @@
#include "example.h"
#include <gtest/gtest.h>
#include <unordered_map>
TEST(SumMapTest, HandlesEmptyMap) {
std::unordered_map<int, int> empty_map;
EXPECT_EQ(SumMapValues(empty_map), 0);
}
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
set -euo pipefail
if [[ "${USER:-}" =~ "@" ]]; then
echo "ERROR: \$USER ('${USER:-}') contains invalid char '@'" >&2
exit 1
fi
if [[ "${HOME:-}" =~ "@" ]]; then
echo "ERROR: \$HOME ('${HOME:-}') contains invalid char '@'" >&2
exit 1
fi