123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- # Bazel build
- # C/C++ documentation: https://docs.bazel.build/versions/master/be/c-cpp.html
- load("//bazel:ray.bzl", "COPTS")
- cc_binary(
- name = "libray_api.so",
- copts = COPTS,
- linkopts = select({
- "@bazel_tools//src/conditions:darwin": [
- #TODO(larry): Hide the symbols when we make it work on mac.
- ],
- "@bazel_tools//src/conditions:windows": [
- #TODO(larry): Hide the symbols when we make it work on Windows.
- ],
- "//conditions:default": [
- "-Wl,--version-script,$(location :symbols/ray_api_exported_symbols_linux.lds)",
- ],
- }),
- linkshared = 1,
- linkstatic = 1,
- visibility = ["//visibility:public"],
- deps = [
- ":ray_api_lib",
- ":symbols/ray_api_exported_symbols_linux.lds",
- ],
- )
- cc_library(
- name = "ray_api_lib",
- srcs = glob([
- "src/ray/api.cc",
- "src/ray/api/*.cc",
- "src/ray/api/*.h",
- "src/ray/app/*.cc",
- "src/ray/app/*.h",
- "src/ray/runtime/*.cc",
- "src/ray/runtime/*.h",
- "src/ray/runtime/**/*.cc",
- "src/ray/runtime/**/*.h",
- "src/ray/runtime/task/*.cc",
- "src/ray/runtime/task/*.h",
- "src/ray/util/*.cc",
- "src/ray/util/*.h",
- "src/ray/*.cc",
- "src/ray/*.h",
- ]),
- hdrs = glob([
- "include/ray/*.h",
- "include/ray/**/*.h",
- "include/ray/**/**/*.h",
- ]),
- copts = COPTS,
- linkopts = ["-ldl"],
- linkstatic = True,
- strip_include_prefix = "include",
- visibility = ["//visibility:public"],
- deps = [
- "//:core_worker_lib",
- "//:global_state_accessor_lib",
- "//:ray_common",
- "//:ray_util",
- "@boost//:callable_traits",
- "@boost//:dll",
- "@com_google_absl//absl/flags:flag",
- "@com_google_absl//absl/flags:parse",
- "@msgpack",
- "@nlohmann_json",
- ],
- alwayslink = True,
- )
- cc_library(
- name = "ray_cpp_lib",
- srcs = [
- "libray_api.so",
- ],
- hdrs = glob([
- "include/ray/*.h",
- "include/ray/**/*.h",
- "include/ray/**/**/*.h",
- ]),
- strip_include_prefix = "include",
- visibility = ["//visibility:public"],
- )
- cc_binary(
- name = "default_worker",
- srcs = glob([
- "src/ray/worker/default_worker.cc",
- ]),
- copts = COPTS,
- linkstatic = True,
- deps = select({
- "@bazel_tools//src/conditions:windows": [
- # TODO(SongGuyang): Change to use dynamic library
- # "ray_cpp_lib" when we make it work on Windows.
- "ray_api_lib",
- ],
- "//conditions:default": [
- "ray_cpp_lib",
- "@boost//:callable_traits",
- "@boost//:optional",
- "@msgpack",
- "@nlohmann_json",
- ],
- }),
- )
- genrule(
- name = "ray_cpp_pkg",
- srcs = [
- "default_worker",
- "libray_api.so",
- ],
- outs = ["ray_cpp_pkg.out"],
- cmd = """
- WORK_DIR="$$(pwd)" &&
- PY_CPP_DIR="$$WORK_DIR/python/ray/cpp" &&
- rm -rf $$PY_CPP_DIR &&
- BOOST_DIR="$$PY_CPP_DIR/include/boost/" &&
- mkdir -p "$$BOOST_DIR" &&
- mkdir -p "$$PY_CPP_DIR/lib/" &&
- cp -f $(location default_worker) "$$PY_CPP_DIR/" &&
- cp -f -r $$WORK_DIR/external/msgpack/include/* "$$PY_CPP_DIR/include" &&
- cp -f -r $$WORK_DIR/external/nlohmann_json/single_include/* "$$PY_CPP_DIR/include" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/archive" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/assert" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/bind" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/callable_traits" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/concept" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/config" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/container" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/container_hash" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/core" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/detail" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/dll" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/exception" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/filesystem" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/functional" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/io" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/iterator" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/lexical_cast" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/move" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/mpl" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/optional" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/parameter" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/preprocessor" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/system" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/type_traits" "$$BOOST_DIR" &&
- cp -f -r "$$WORK_DIR/external/boost/boost/utility" "$$BOOST_DIR" &&
- cp -f -r $$WORK_DIR/external/boost/boost/*.hpp "$$BOOST_DIR" &&
- cp -f $(locations libray_api.so) "$$PY_CPP_DIR/lib/" &&
- cp -f -r "$$WORK_DIR/cpp/include/ray" "$$PY_CPP_DIR/include" &&
- THIRDPARTY_DIR="$$WORK_DIR/cpp/example/thirdparty" &&
- rm -rf $$THIRDPARTY_DIR &&
- mkdir $$THIRDPARTY_DIR &&
- cp -f -r "$$PY_CPP_DIR/include" $$THIRDPARTY_DIR &&
- cp -f -r "$$PY_CPP_DIR/lib" $$THIRDPARTY_DIR &&
- cp -f -r "$$WORK_DIR/cpp/example" "$$PY_CPP_DIR" &&
- echo "$$WORK_DIR" > $@
- """,
- local = 1,
- visibility = ["//visibility:public"],
- )
- # test
- cc_test(
- name = "api_test",
- srcs = glob([
- "src/ray/test/*.cc",
- ]),
- copts = COPTS,
- linkstatic = True,
- tags = ["team:core"],
- deps = [
- "ray_api_lib",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "cluster_mode_test",
- srcs = glob(
- [
- "src/ray/test/cluster/*.cc",
- "src/ray/test/cluster/*.h",
- ],
- exclude = [
- "src/ray/test/cluster/cluster_mode_xlang_test.cc",
- ],
- ),
- args = [
- "--ray_code_search_path=$(location plus.so):$(location counter.so):cpp/src/ray/test/cluster",
- "--ray_head_args '--include-dashboard false'",
- ],
- copts = COPTS,
- data = [
- "counter.so",
- "plus.so",
- "ray_cpp_pkg",
- "src/ray/test/cluster/test_cross_language_invocation.py",
- ],
- linkstatic = True,
- tags = ["team:core"],
- deps = [
- "ray_api_lib",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "cluster_mode_xlang_test",
- srcs = glob([
- "src/ray/test/cluster/cluster_mode_xlang_test.cc",
- "src/ray/test/cluster/*.h",
- ]),
- args = [
- "--ray_code_search_path=$(location //java:libio_ray_ray_test.jar)",
- "--ray_head_args '--include-dashboard false'",
- ],
- copts = COPTS,
- data = [
- "ray_cpp_pkg",
- "//java:libio_ray_ray_test.jar",
- ],
- linkstatic = True,
- tags = ["team:core"],
- deps = [
- "ray_api_lib",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_binary(
- name = "plus.so",
- testonly = True,
- srcs = [
- "src/ray/test/cluster/plus.cc",
- "src/ray/test/cluster/plus.h",
- ],
- copts = COPTS,
- linkopts = ["-shared"],
- linkstatic = True,
- # NOTE(WangTaoTheTonic): For java x-lang tests. See //java:all_tests
- # and `CrossLanguageInvocationTest.java`.
- visibility = ["//java:__subpackages__"],
- deps = [
- "ray_cpp_lib",
- "@boost//:callable_traits",
- "@boost//:optional",
- "@msgpack",
- "@nlohmann_json",
- ],
- )
- cc_binary(
- name = "counter.so",
- testonly = True,
- srcs = [
- "src/ray/test/cluster/counter.cc",
- "src/ray/test/cluster/counter.h",
- ],
- copts = COPTS,
- linkopts = ["-shared"],
- linkstatic = True,
- # NOTE(WangTaoTheTonic): For java x-lang tests. See //java:all_tests
- # and `CrossLanguageInvocationTest.java`.
- visibility = ["//java:__subpackages__"],
- deps = [
- "ray_cpp_lib",
- "@boost//:callable_traits",
- "@boost//:optional",
- "@msgpack",
- "@nlohmann_json",
- ],
- )
- cc_test(
- name = "simple_kv_store",
- srcs = glob([
- "src/ray/test/examples/simple_kv_store.cc",
- ]),
- args = [
- "--ray_code_search_path=$(location simple_kv_store.so)",
- "--ray_head_args '--include-dashboard false'",
- ],
- copts = COPTS,
- data = [
- "simple_kv_store.so",
- ],
- linkstatic = True,
- tags = ["team:core"],
- deps = [
- "ray_api_lib",
- ],
- )
- cc_binary(
- name = "simple_kv_store.so",
- testonly = True,
- srcs = glob([
- "src/ray/test/examples/simple_kv_store.cc",
- ]),
- copts = COPTS,
- linkopts = ["-shared"],
- linkstatic = True,
- deps = [
- "ray_cpp_lib",
- "@boost//:callable_traits",
- "@boost//:optional",
- "@msgpack",
- "@nlohmann_json",
- ],
- )
- cc_binary(
- name = "simple_job",
- srcs = [
- "src/ray/test/examples/simple_job.cc",
- ],
- copts = COPTS,
- data = [
- "simple_job.so",
- ],
- linkstatic = True,
- tags = ["team:core"],
- deps = [
- ":ray_api_lib",
- ],
- )
- cc_binary(
- name = "simple_job.so",
- srcs = [
- "src/ray/test/examples/simple_job.cc",
- ],
- copts = COPTS,
- linkopts = ["-shared"],
- linkstatic = True,
- deps = [
- "ray_cpp_lib",
- "@boost//:callable_traits",
- "@boost//:optional",
- "@msgpack",
- "@nlohmann_json",
- ],
- )
- load("//bazel:python.bzl", "py_test_module_list")
- py_test_module_list(
- size = "medium",
- extra_srcs = [],
- files = [
- "test_python_call_cpp.py",
- ],
- tags = [
- "exclusive",
- "medium_size_python_tests",
- "team:core",
- ],
- deps = [],
- )
- py_test(
- name = "test_submit_cpp_job",
- size = "medium",
- srcs = ["test_submit_cpp_job.py"],
- data = [
- "simple_job",
- "simple_job.so",
- ],
- env = {
- "SIMPLE_DRIVER_SO_PATH": "$(location simple_job.so)",
- "SIMPLE_DRIVER_MAIN_PATH": "$(location simple_job)",
- },
- tags = ["team:core"],
- )
|