2019-12-10 20:33:24 +08:00
|
|
|
# Bazel build
|
|
|
|
# C/C++ documentation: https://docs.bazel.build/versions/master/be/c-cpp.html
|
|
|
|
|
|
|
|
load("@rules_proto_grpc//python:defs.bzl", "python_proto_compile")
|
2019-12-17 02:38:36 -08:00
|
|
|
load("//bazel:ray.bzl", "COPTS")
|
2019-12-10 20:33:24 +08:00
|
|
|
|
|
|
|
proto_library(
|
|
|
|
name = "streaming_proto",
|
|
|
|
srcs = ["src/protobuf/streaming.proto"],
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
|
|
|
proto_library(
|
|
|
|
name = "streaming_queue_proto",
|
|
|
|
srcs = ["src/protobuf/streaming_queue.proto"],
|
|
|
|
)
|
|
|
|
|
2020-02-25 10:33:33 +08:00
|
|
|
proto_library(
|
|
|
|
name = "remote_call_proto",
|
|
|
|
srcs = ["src/protobuf/remote_call.proto"],
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = ["streaming_proto"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_proto_library(
|
|
|
|
name = "streaming_cc_proto",
|
|
|
|
deps = [":streaming_proto"],
|
|
|
|
)
|
|
|
|
|
2019-12-10 20:33:24 +08:00
|
|
|
cc_proto_library(
|
|
|
|
name = "streaming_queue_cc_proto",
|
|
|
|
deps = ["streaming_queue_proto"],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Use `linkshared` to ensure ray related symbols are not packed into streaming libs
|
|
|
|
# to avoid duplicate symbols. In runtime we expose ray related symbols, which can
|
|
|
|
# be linked into streaming libs by dynamic linker. See bazel rule `//:_raylet`
|
|
|
|
cc_binary(
|
|
|
|
name = "ray_util.so",
|
2019-12-17 02:38:36 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
linkshared = 1,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = ["//:ray_util"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "ray_common.so",
|
2019-12-17 02:38:36 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
linkshared = 1,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = ["//:ray_common"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "core_worker_lib.so",
|
2019-12-17 02:38:36 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
linkshared = 1,
|
|
|
|
deps = ["//:core_worker_lib"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "streaming_util",
|
|
|
|
srcs = glob([
|
|
|
|
"src/util/*.cc",
|
|
|
|
]),
|
|
|
|
hdrs = glob([
|
|
|
|
"src/util/*.h",
|
|
|
|
]),
|
2019-12-17 02:38:36 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
includes = [
|
|
|
|
"src",
|
|
|
|
],
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
"ray_util.so",
|
|
|
|
"@boost//:any",
|
|
|
|
"@com_google_googletest//:gtest",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "streaming_config",
|
|
|
|
srcs = glob([
|
|
|
|
"src/config/*.cc",
|
|
|
|
]),
|
|
|
|
hdrs = glob([
|
|
|
|
"src/config/*.h",
|
|
|
|
]),
|
2019-12-17 02:38:36 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
deps = [
|
|
|
|
"ray_common.so",
|
|
|
|
":streaming_cc_proto",
|
|
|
|
":streaming_util",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "streaming_message",
|
|
|
|
srcs = glob([
|
|
|
|
"src/message/*.cc",
|
|
|
|
]),
|
|
|
|
hdrs = glob([
|
|
|
|
"src/message/*.h",
|
|
|
|
]),
|
2019-12-17 02:38:36 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
deps = [
|
|
|
|
"ray_common.so",
|
|
|
|
":streaming_config",
|
|
|
|
":streaming_util",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "streaming_queue",
|
|
|
|
srcs = glob([
|
|
|
|
"src/queue/*.cc",
|
|
|
|
]),
|
|
|
|
hdrs = glob([
|
|
|
|
"src/queue/*.h",
|
|
|
|
]),
|
2019-12-17 02:38:36 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
deps = [
|
|
|
|
"ray_common.so",
|
|
|
|
"ray_util.so",
|
|
|
|
":streaming_config",
|
|
|
|
":streaming_message",
|
|
|
|
":streaming_queue_cc_proto",
|
|
|
|
":streaming_util",
|
|
|
|
"@boost//:asio",
|
|
|
|
"@boost//:thread",
|
2020-02-27 15:14:10 -08:00
|
|
|
] + select({
|
|
|
|
"@bazel_tools//src/conditions:windows": [
|
|
|
|
# TODO(mehrdadn): This is to resolve symbols on Windows for now. Should remove this later. (See d7f8d18.)
|
|
|
|
"//:core_worker_lib",
|
|
|
|
],
|
|
|
|
"//conditions:default": [
|
|
|
|
"core_worker_lib.so",
|
|
|
|
],
|
|
|
|
}),
|
2019-12-10 20:33:24 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "streaming_lib",
|
|
|
|
srcs = glob([
|
|
|
|
"src/*.cc",
|
|
|
|
]),
|
|
|
|
hdrs = glob([
|
|
|
|
"src/*.h",
|
|
|
|
"src/queue/*.h",
|
|
|
|
"src/test/*.h",
|
|
|
|
]),
|
2019-12-17 02:38:36 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
includes = ["src"],
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
"ray_common.so",
|
|
|
|
"ray_util.so",
|
|
|
|
":streaming_config",
|
|
|
|
":streaming_message",
|
|
|
|
":streaming_queue",
|
|
|
|
":streaming_util",
|
|
|
|
"@boost//:circular_buffer",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
test_common_deps = [
|
|
|
|
":streaming_lib",
|
|
|
|
"//:ray_common",
|
|
|
|
"//:ray_util",
|
|
|
|
"//:core_worker_lib",
|
|
|
|
]
|
|
|
|
|
|
|
|
# streaming queue mock actor binary
|
|
|
|
cc_binary(
|
|
|
|
name = "streaming_test_worker",
|
|
|
|
srcs = glob(["src/test/*.h"]) + [
|
|
|
|
"src/test/mock_actor.cc",
|
|
|
|
],
|
2019-12-17 02:38:36 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
includes = [
|
|
|
|
"streaming/src/test",
|
|
|
|
],
|
|
|
|
deps = test_common_deps,
|
|
|
|
)
|
|
|
|
|
|
|
|
# use src/test/run_streaming_queue_test.sh to run this test
|
|
|
|
cc_binary(
|
|
|
|
name = "streaming_queue_tests",
|
|
|
|
srcs = glob(["src/test/*.h"]) + [
|
|
|
|
"src/test/streaming_queue_tests.cc",
|
|
|
|
],
|
2020-02-11 16:49:33 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
deps = test_common_deps,
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "streaming_message_ring_buffer_tests",
|
|
|
|
srcs = [
|
|
|
|
"src/test/ring_buffer_tests.cc",
|
|
|
|
],
|
2020-02-11 16:49:33 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
includes = [
|
|
|
|
"streaming/src/test",
|
|
|
|
],
|
|
|
|
deps = test_common_deps,
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "streaming_message_serialization_tests",
|
|
|
|
srcs = [
|
|
|
|
"src/test/message_serialization_tests.cc",
|
|
|
|
],
|
2020-02-11 16:49:33 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
deps = test_common_deps,
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "streaming_mock_transfer",
|
|
|
|
srcs = [
|
|
|
|
"src/test/mock_transfer_tests.cc",
|
|
|
|
],
|
2020-02-11 16:49:33 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
deps = test_common_deps,
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "streaming_util_tests",
|
|
|
|
srcs = [
|
|
|
|
"src/test/streaming_util_tests.cc",
|
|
|
|
],
|
2020-02-11 16:49:33 -08:00
|
|
|
copts = COPTS,
|
2019-12-10 20:33:24 +08:00
|
|
|
deps = test_common_deps,
|
|
|
|
)
|
|
|
|
|
2020-02-11 22:24:45 +08:00
|
|
|
cc_test(
|
|
|
|
name = "event_service_tests",
|
|
|
|
srcs = [
|
|
|
|
"src/test/event_service_tests.cc",
|
|
|
|
],
|
|
|
|
deps = test_common_deps,
|
|
|
|
)
|
|
|
|
|
2019-12-10 20:33:24 +08:00
|
|
|
python_proto_compile(
|
|
|
|
name = "streaming_py_proto",
|
|
|
|
deps = ["//streaming:streaming_proto"],
|
|
|
|
)
|
|
|
|
|
2020-02-25 10:33:33 +08:00
|
|
|
python_proto_compile(
|
|
|
|
name = "remote_call_py_proto",
|
|
|
|
deps = ["//streaming:remote_call_proto"],
|
|
|
|
)
|
|
|
|
|
|
|
|
filegroup(
|
|
|
|
name = "all_py_proto",
|
|
|
|
srcs = [
|
|
|
|
":remote_call_py_proto",
|
|
|
|
":streaming_py_proto",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-12-10 20:33:24 +08:00
|
|
|
genrule(
|
|
|
|
name = "copy_streaming_py_proto",
|
|
|
|
srcs = [
|
2020-02-25 10:33:33 +08:00
|
|
|
":all_py_proto",
|
2019-12-10 20:33:24 +08:00
|
|
|
],
|
|
|
|
outs = [
|
|
|
|
"copy_streaming_py_proto.out",
|
|
|
|
],
|
|
|
|
cmd = """
|
|
|
|
set -e
|
2020-02-11 16:49:33 -08:00
|
|
|
WORK_DIR="$$(pwd)"
|
2019-12-10 20:33:24 +08:00
|
|
|
# Copy generated files.
|
2020-02-11 16:49:33 -08:00
|
|
|
GENERATED_DIR="$$WORK_DIR/streaming/python/generated"
|
|
|
|
rm -rf "$$GENERATED_DIR"
|
|
|
|
mkdir -p "$$GENERATED_DIR"
|
|
|
|
touch "$$GENERATED_DIR/__init__.py"
|
2020-02-25 10:33:33 +08:00
|
|
|
for f in $(locations //streaming:all_py_proto); do
|
|
|
|
cp -f "$$f" "$$GENERATED_DIR"
|
2019-12-10 20:33:24 +08:00
|
|
|
done
|
2020-02-25 10:33:33 +08:00
|
|
|
sed -i -E 's/from streaming.src.protobuf/from ./' "$$GENERATED_DIR/remote_call_pb2.py"
|
2020-02-11 16:49:33 -08:00
|
|
|
date > $@
|
2019-12-10 20:33:24 +08:00
|
|
|
""",
|
|
|
|
local = 1,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
2019-12-22 10:56:05 +08:00
|
|
|
|
|
|
|
# Streaming java
|
|
|
|
genrule(
|
|
|
|
name = "copy_jni_h",
|
|
|
|
srcs = ["@bazel_tools//tools/jdk:jni_header"],
|
|
|
|
outs = ["jni.h"],
|
|
|
|
cmd = "cp -f $< $@",
|
|
|
|
)
|
|
|
|
|
|
|
|
genrule(
|
|
|
|
name = "copy_jni_md_h",
|
|
|
|
srcs = select({
|
|
|
|
"@bazel_tools//src/conditions:windows": ["@bazel_tools//tools/jdk:jni_md_header-windows"],
|
|
|
|
"@bazel_tools//src/conditions:darwin": ["@bazel_tools//tools/jdk:jni_md_header-darwin"],
|
|
|
|
"//conditions:default": ["@bazel_tools//tools/jdk:jni_md_header-linux"],
|
|
|
|
}),
|
|
|
|
outs = ["jni_md.h"],
|
|
|
|
cmd = "cp -f $< $@",
|
2020-02-11 16:49:33 -08:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "jni",
|
|
|
|
hdrs = [
|
|
|
|
":jni.h",
|
|
|
|
":jni_md.h",
|
|
|
|
],
|
|
|
|
copts = COPTS,
|
|
|
|
includes = [
|
|
|
|
".", # needed for `include <jni.h>`
|
|
|
|
],
|
|
|
|
visibility = ["//visibility:public"],
|
2019-12-22 10:56:05 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "libstreaming_java.so",
|
|
|
|
srcs = glob([
|
|
|
|
"src/lib/java/*.cc",
|
|
|
|
"src/lib/java/*.h",
|
2020-02-11 16:49:33 -08:00
|
|
|
]),
|
|
|
|
copts = COPTS,
|
2019-12-22 10:56:05 +08:00
|
|
|
includes = [
|
|
|
|
"src",
|
|
|
|
],
|
|
|
|
linkshared = 1,
|
|
|
|
linkstatic = 1,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
2020-02-11 16:49:33 -08:00
|
|
|
":jni",
|
2019-12-22 10:56:05 +08:00
|
|
|
":streaming_lib",
|
|
|
|
],
|
|
|
|
)
|