Skip to content

Commit

Permalink
Add bazel build for JNI code (#3918)
Browse files Browse the repository at this point in the history
* Add bazel build for JNI code

* clean

* Add plasma client JNI build process

* refine

* clean linux part

* Add Java Library

* Remove java library

* Generate dylib after build using genrule
  • Loading branch information
guoyuhong authored and pcmoritz committed Feb 4, 2019
1 parent e1c68a0 commit add8ae7
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
50 changes: 47 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,45 @@ pyx_library(
deps = ["//:raylet_lib"]
)

cc_binary(
name = "raylet_library_java.so",
srcs = [
"@bazel_tools//tools/jdk:current_java_runtime",
"src/ray/raylet/lib/java/org_ray_runtime_raylet_RayletClientImpl.h",
"src/ray/raylet/lib/java/org_ray_runtime_raylet_RayletClientImpl.cc",
"src/ray/id.h",
"src/ray/raylet/raylet_client.h",
"src/ray/util/logging.h"
],
includes = [
"src",
"external/local_jdk/include"] + select({
"@bazel_tools//src/conditions:darwin": ["external/local_jdk/include/darwin"],
"//conditions:default": ["external/local_jdk/include/linux"]
}),
linkshared = 1,
linkstatic = 1,
deps = ["@plasma//:plasma_client",
"//:raylet_lib"],
)

genrule(
name = "raylet-jni-darwin-compat",
srcs = [":raylet_library_java.so"],
outs = ["raylet_library_java.dylib"],
cmd = "cp $< $@",
output_to_bindir = 1,
)

filegroup(
name = "raylet_library_java",
visibility = ["//visibility:public"],
srcs = select({
"@bazel_tools//src/conditions:darwin": [":raylet_library_java.dylib"],
"//conditions:default": [":raylet_library_java.so"],
})
)

flatbuffer_py_library(
name = "python_gcs_fbs",
srcs = [
Expand Down Expand Up @@ -460,7 +499,9 @@ genrule(
"//:ray_redis_module",
"//:raylet",
"//:raylet_monitor",
"@plasma//:plasma_store_server"
"@plasma//:plasma_store_server",
"@plasma//:plasma_client_java",
"//:raylet_library_java",
],
outs = ["ray_pkg"],
cmd = """
Expand All @@ -476,6 +517,9 @@ genrule(
mkdir -p python/ray/core/src/plasma &&
cp $(location @plasma//:plasma_store_server) python/ray/core/src/plasma/ &&
cp $(location //:raylet) python/ray/core/src/ray/raylet/ &&
mv python $(location ray_pkg)
""",
mv python $(location ray_pkg) &&
mkdir -p $(location ray_pkg)/java_lib &&
cp $(location @plasma//:plasma_client_java) $(location ray_pkg)/java_lib &&
cp $(location //:raylet_library_java) $(location ray_pkg)/java_lib
"""
)
35 changes: 35 additions & 0 deletions bazel/BUILD.plasma
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,41 @@ cc_library(
strip_include_prefix = "cpp/src",
)

cc_binary(
name = "plasma_client_java.so",
srcs = [
"@bazel_tools//tools/jdk:current_java_runtime",
"cpp/src/plasma/lib/java/org_apache_arrow_plasma_PlasmaClientJNI.cc",
"cpp/src/plasma/lib/java/org_apache_arrow_plasma_PlasmaClientJNI.h"
],
includes = [
"cpp/src",
"../../external/local_jdk/include"] + select({
"@bazel_tools//src/conditions:darwin": ["../../external/local_jdk/include/darwin"],
"//conditions:default": ["../../external/local_jdk/include/linux"]
}),
linkshared = 1,
linkstatic = 1,
deps = [":plasma_client"],
)

genrule(
name = "plasma-jni-darwin-compat",
srcs = [":plasma_client_java.so"],
outs = ["plasma_client_java.dylib"],
cmd = "cp $< $@",
output_to_bindir = 1,
)

filegroup(
name = "plasma_client_java",
visibility = ["//visibility:public"],
srcs = select({
"@bazel_tools//src/conditions:darwin": [":plasma_client_java.dylib"],
"//conditions:default": [":plasma_client_java.so"],
})
)

cc_library(
name = "plasma_lib",
hdrs = [
Expand Down

0 comments on commit add8ae7

Please sign in to comment.