Skip to content

Commit

Permalink
Build Raylet with Bazel (#3806)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcmoritz authored and robertnishihara committed Jan 20, 2019
1 parent aad48ee commit 0dad4e6
Show file tree
Hide file tree
Showing 6 changed files with 445 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ matrix:
script:
- ./java/test.sh

# Test Bazel build
- rm -rf build
- ./.travis/install-bazel.sh
- bazel build ...

- os: linux
dist: trusty
env: LINT=1 PYTHONWARNINGS=ignore
Expand Down
23 changes: 23 additions & 0 deletions .travis/install-bazel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Cause the script to exit if a single command fails
set -e

platform="unknown"
unamestr="$(uname)"
if [[ "$unamestr" == "Linux" ]]; then
echo "Platform is linux."
platform="linux"
elif [[ "$unamestr" == "Darwin" ]]; then
echo "Platform is macosx."
platform="darwin"
else
echo "Unrecognized platform."
exit 1
fi

URL="https://github.com/bazelbuild/bazel/releases/download/0.21.0/bazel-0.21.0-installer-${platform}-x86_64.sh"
wget -O install.sh $URL
chmod +x install.sh
./install.sh --user
rm -f install.sh
306 changes: 306 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,306 @@
# Bazel build
# C/C++ documentation: https://docs.bazel.build/versions/master/be/c-cpp.html

load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")

cc_binary(
name = "raylet",
srcs = ["src/ray/raylet/main.cc"],
deps = [
":ray_util",
":raylet_lib",
],
)

cc_binary(
name = "raylet_monitor",
srcs = [
"src/ray/raylet/monitor.cc",
"src/ray/raylet/monitor.h",
"src/ray/raylet/monitor_main.cc",
],
deps = [
":gcs",
":ray_util",
],
)

cc_library(
name = "raylet_lib",
srcs = glob([
"src/ray/raylet/*.cc"
], exclude = [
"src/ray/raylet/mock_gcs_client.cc",
"src/ray/raylet/monitor_main.cc",
"src/ray/raylet/*_test.cc",
]),
hdrs = glob([
"src/ray/raylet/*.h",
]),
deps = [
":gcs",
":gcs_fbs",
":node_manager_fbs",
":object_manager",
":ray_common",
":ray_util",
"@boost//:asio",
"@plasma",
"@com_google_googletest//:gtest",
],
)

cc_test(
name = "lineage_cache_test",
srcs = ["src/ray/raylet/lineage_cache_test.cc"],
deps = [
"@com_google_googletest//:gtest_main",
":node_manager_fbs",
":raylet_lib",
],
)

cc_test(
name = "reconstruction_policy_test",
srcs = ["src/ray/raylet/reconstruction_policy_test.cc"],
deps = [
"@com_google_googletest//:gtest_main",
":node_manager_fbs",
":object_manager",
":raylet_lib"
],
)

cc_test(
name = "worker_pool_test",
srcs = ["src/ray/raylet/worker_pool_test.cc"],
deps = [
"@com_google_googletest//:gtest_main",
":raylet_lib",
],
)

cc_test(
name = "logging_test",
srcs = ["src/ray/util/logging_test.cc"],
deps = [
"@com_google_googletest//:gtest_main",
":ray_util",
],
)

cc_test(
name = "task_dependency_manager_test",
srcs = ["src/ray/raylet/task_dependency_manager_test.cc"],
deps = [
"@com_google_googletest//:gtest_main",
":raylet_lib"
],
)

cc_test(
name = "task_test",
srcs = ["src/ray/raylet/task_test.cc"],
deps = [
"@com_google_googletest//:gtest_main",
":raylet_lib",
],
)

cc_library(
name = "object_manager",
srcs = glob([
"src/ray/object_manager/*.cc",
]),
hdrs = glob([
"src/ray/object_manager/*.h",
]),
includes = [
"src",
],
deps = [
":gcs",
":object_manager_fbs",
":ray_common",
":ray_util",
"@boost//:asio",
"@plasma"
],
)

cc_binary(
name = "object_manager_test",
testonly = 1,
srcs = ["src/ray/object_manager/test/object_manager_test.cc"],
deps = [
"@com_google_googletest//:gtest_main",
":object_manager",
],
)

cc_binary(
name = "object_manager_stress_test",
testonly = 1,
srcs = ["src/ray/object_manager/test/object_manager_stress_test.cc"],
deps = [
"@com_google_googletest//:gtest_main",
":object_manager",
],
)

cc_library(
name = "ray_util",
srcs = glob([
"src/ray/*.cc",
"src/ray/util/*.cc",
], exclude = [
"src/ray/util/logging_test.cc",
"src/ray/util/signal_test.cc"
]),
hdrs = glob([
"src/ray/*.h",
"src/ray/util/*.h",
]),
includes = [
"src",
],
deps = [
"@plasma",
":sha256"
]
)

cc_library(
name = "ray_common",
srcs = [
"src/ray/common/client_connection.cc",
"src/ray/common/common_protocol.cc"
],
hdrs = [
"src/ray/common/client_connection.h",
"src/ray/common/common_protocol.h"
],
includes = [
"src/ray/gcs/format",
],
deps = [
":gcs_fbs",
":node_manager_fbs",
":ray_util",
"@boost//:asio",
],
)

cc_library(
name = "sha256",
srcs = [
"src/ray/thirdparty/sha256.c",
],
hdrs = [
"src/ray/thirdparty/sha256.h",
],
includes = ["src/ray/thirdparty"],
)

cc_library(
name = "hiredis",
srcs = glob([
"src/ray/thirdparty/ae/ae.c",
"src/ray/thirdparty/hiredis/*.c",
], exclude = [
"src/ray/thirdparty/hiredis/test.c"
]),
hdrs = glob([
"src/ray/thirdparty/ae/*.h",
"src/ray/thirdparty/hiredis/*.h",
"src/ray/thirdparty/hiredis/adapters/*.h",
"src/ray/thirdparty/hiredis/dict.c",
"src/ray/thirdparty/ae/ae_kqueue.c",
"src/ray/thirdparty/ae/ae_epoll.c",
]),
includes = [
"src/ray/thirdparty/hiredis",
"src/ray/thirdparty/ae",
],
)

cc_library(
name = "gcs",
srcs = glob([
"src/ray/gcs/*.cc"
], exclude = [
"src/ray/gcs/*_test.cc"
]),
hdrs = glob([
"src/ray/gcs/*.h",
"src/ray/gcs/format/*.h",
]),
includes = [
"src/ray/gcs/format",
],
deps = [
":gcs_fbs",
":node_manager_fbs",
":ray_util",
":ray_common",
":hiredis",
"@boost//:asio",
],
)

cc_binary(
name = "gcs_client_test",
testonly = 1,
srcs = ["src/ray/gcs/client_test.cc"],
deps = [
":gcs",
"@com_google_googletest//:gtest_main",
],
)

cc_binary(
name = "asio_test",
testonly = 1,
srcs = ["src/ray/gcs/asio_test.cc"],
deps = [
":gcs",
"@com_google_googletest//:gtest_main",
":ray_util",
],
)

FLATC_ARGS = [
"--gen-object-api",
"--gen-mutable",
"--scoped-enums",
]

flatbuffer_cc_library(
name = "gcs_fbs",
srcs = ["src/ray/gcs/format/gcs.fbs"],
flatc_args = FLATC_ARGS,
out_prefix = "src/ray/gcs/format/",
)

flatbuffer_cc_library(
name = "common_fbs",
srcs = ["@plasma//:cpp/src/plasma/format/common.fbs"],
flatc_args = FLATC_ARGS,
out_prefix = "src/ray/common/"
)

flatbuffer_cc_library(
name = "node_manager_fbs",
srcs = ["src/ray/raylet/format/node_manager.fbs"],
flatc_args = FLATC_ARGS,
include_paths = ["src/ray/gcs/format"],
includes = [":gcs_fbs_includes"],
out_prefix = "src/ray/raylet/format/",
)

flatbuffer_cc_library(
name = "object_manager_fbs",
srcs = ["src/ray/object_manager/format/object_manager.fbs"],
flatc_args = FLATC_ARGS,
out_prefix = "src/ray/object_manager/format/",
)
29 changes: 29 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository")

git_repository(
name = "com_github_nelhage_rules_boost",
commit = "6d6fd834281cb8f8e758dd9ad76df86304bf1869",
remote = "https://github.com/nelhage/rules_boost",
)

load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
boost_deps()

git_repository(
name = "com_github_google_flatbuffers",
remote = "https://github.com/google/flatbuffers.git",
commit = "63d51afd1196336a7d1f56a988091ef05deb1c62",
)

git_repository(
name = "com_google_googletest",
remote = "https://github.com/google/googletest",
commit = "3306848f697568aacf4bcca330f6bdd5ce671899",
)

new_git_repository(
name = "plasma",
build_file = "@//bazel:BUILD.plasma",
remote = "https://github.com/ray-project/arrow",
commit = "1e4f867eb1dc31107331ab1defdffb94467f31dc",
)
Empty file added bazel/BUILD
Empty file.
Loading

0 comments on commit 0dad4e6

Please sign in to comment.