2019-01-27 18:32:04 -08:00
load ( " @com_github_google_flatbuffers//:build_defs.bzl " , " flatbuffer_library_public " )
2019-03-22 14:30:05 +08:00
load ( " @com_github_checkstyle_java//checkstyle:checkstyle.bzl " , " checkstyle_test " )
2019-04-29 13:02:49 +08:00
load ( " @bazel_common//tools/maven:pom_file.bzl " , " pom_file " )
2019-01-27 18:32:04 -08:00
2019-12-17 02:38:36 -08:00
COPTS = [ " -DRAY_USE_GLOG " ] + select ( {
2020-07-13 15:31:46 -07:00
" @bazel_tools//src/conditions:windows " : [
# TODO(mehrdadn): (How to) support dynamic linking?
" -DRAY_STATIC " ,
] ,
" //conditions:default " : [
] ,
} ) + select ( {
" //:clang-cl " : [
2019-12-17 02:38:36 -08:00
" -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)
2020-07-13 15:31:46 -07:00
] ,
2019-12-17 02:38:36 -08:00
" //conditions:default " : [
] ,
} )
2020-07-02 09:34:24 -07:00
PYX_COPTS = select ( {
2020-07-13 15:31:46 -07:00
" //:msvc-cl " : [
2020-07-02 09:34:24 -07:00
] ,
" //conditions:default " : [
# Ignore this warning since CPython and Cython have issue removing deprecated tp_print on MacOS
" -Wno-deprecated-declarations " ,
] ,
} ) + select ( {
2020-06-05 05:36:10 -07:00
" @bazel_tools//src/conditions:windows " : [
" /FI " + " src/shims/windows/python-nondebug.h " ,
] ,
" //conditions:default " : [
] ,
} )
PYX_SRCS = [ ] + select ( {
" @bazel_tools//src/conditions:windows " : [
" src/shims/windows/python-nondebug.h " ,
] ,
" //conditions:default " : [
] ,
} )
2019-02-11 10:00:06 -08:00
def flatbuffer_py_library ( name , srcs , outs , out_prefix , includes = [ ] , include_paths = [ ] ) :
2019-01-27 18:32:04 -08:00
flatbuffer_library_public (
name = name ,
srcs = srcs ,
outs = outs ,
language_flag = " -p " ,
out_prefix = out_prefix ,
include_paths = include_paths ,
includes = includes ,
)
2019-03-22 14:30:05 +08:00
2019-07-08 22:41:37 +08:00
def define_java_module (
name ,
additional_srcs = [ ] ,
exclude_srcs = [ ] ,
additional_resources = [ ] ,
define_test_lib = False ,
test_deps = [ ] ,
* * kwargs ) :
2020-04-12 17:59:34 +08:00
lib_name = " io_ray_ray_ " + name
2019-05-17 10:56:39 +08:00
pom_file_targets = [ lib_name ]
2019-03-22 14:30:05 +08:00
native . java_library (
2019-05-17 10:56:39 +08:00
name = lib_name ,
2019-07-08 22:41:37 +08:00
srcs = additional_srcs + native . glob (
[ name + " /src/main/java/**/*.java " ] ,
exclude = exclude_srcs ,
) ,
2019-03-22 14:30:05 +08:00
resources = native . glob ( [ name + " /src/main/resources/** " ] ) + additional_resources ,
* * kwargs
)
checkstyle_test (
2020-04-12 17:59:34 +08:00
name = " io_ray_ray_ " + name + " -checkstyle " ,
target = " :io_ray_ray_ " + name ,
2019-03-22 14:30:05 +08:00
config = " //java:checkstyle.xml " ,
suppressions = " //java:checkstyle-suppressions.xml " ,
size = " small " ,
tags = [ " checkstyle " ] ,
)
if define_test_lib :
2020-04-12 17:59:34 +08:00
test_lib_name = " io_ray_ray_ " + name + " _test "
2019-05-17 10:56:39 +08:00
pom_file_targets . append ( test_lib_name )
2019-03-22 14:30:05 +08:00
native . java_library (
2019-05-17 10:56:39 +08:00
name = test_lib_name ,
2019-03-22 14:30:05 +08:00
srcs = native . glob ( [ name + " /src/test/java/**/*.java " ] ) ,
deps = test_deps ,
)
checkstyle_test (
2020-04-12 17:59:34 +08:00
name = " io_ray_ray_ " + name + " _test-checkstyle " ,
target = " :io_ray_ray_ " + name + " _test " ,
2019-03-22 14:30:05 +08:00
config = " //java:checkstyle.xml " ,
suppressions = " //java:checkstyle-suppressions.xml " ,
size = " small " ,
tags = [ " checkstyle " ] ,
)
2019-04-29 13:02:49 +08:00
pom_file (
2020-04-12 17:59:34 +08:00
name = " io_ray_ray_ " + name + " _pom " ,
2019-05-17 10:56:39 +08:00
targets = pom_file_targets ,
2019-04-29 13:02:49 +08:00
template_file = name + " /pom_template.xml " ,
2019-05-16 11:19:31 +08:00
substitutions = {
" {auto_gen_header} " : " <!-- This file is auto-generated by Bazel from pom_template.xml, do not modify it. --> " ,
} ,
2019-04-29 13:02:49 +08:00
)
2020-07-09 09:02:35 -07:00
def copy_to_workspace ( name , srcs , dstdir = " " ) :
if dstdir . startswith ( " / " ) or dstdir . startswith ( " \\ " ) :
fail ( " Subdirectory must be a relative path: " + dstdir )
src_locations = " " . join ( [ " $(locations %s ) " % ( src , ) for src in srcs ] )
native . genrule (
name = name ,
srcs = srcs ,
outs = [ name + " .out " ] ,
# Keep this Bash script equivalent to the batch script below (or take out the batch script)
cmd = r """
mkdir - p - - { dstdir }
for f in { locations } ; do
rm - f - - { dstdir } $ $ { { f ##*/}}
cp - f - - " $$f " { dstdir }
2020-07-11 05:27:56 -07:00
done
date > $ @
2020-07-09 09:02:35 -07:00
""" .format(
locations = src_locations ,
dstdir = " . " + ( " / " + dstdir . replace ( " \\ " , " / " ) ) . rstrip ( " / " ) + " / " ,
) ,
# Keep this batch script equivalent to the Bash script above (or take out the batch script)
2020-07-28 15:34:29 -07:00
cmd_bat = r """
2020-07-09 09:02:35 -07:00
(
if not exist { dstdir } mkdir { dstdir }
) & & (
for % f in ( { locations } ) do @ (
( if exist { dstdir } % ~ nxf del / f / q { dstdir } % ~ nxf ) & &
2020-07-11 05:27:56 -07:00
copy / B / Y % f { dstdir } > NUL
2020-07-09 09:02:35 -07:00
)
2020-07-11 05:27:56 -07:00
) & & > $ @ echo % TIME %
2020-07-09 09:02:35 -07:00
""" .replace( " \r " , " " ).replace( " \n " , " " ).format(
locations = src_locations ,
dstdir = " . " + ( " \\ " + dstdir . replace ( " / " , " \\ " ) ) . rstrip ( " \\ " ) + " \\ " ,
) ,
local = 1 ,
)