forked from tensorflow/minigo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminigo.bzl
More file actions
69 lines (64 loc) · 2.5 KB
/
Copy pathminigo.bzl
File metadata and controls
69 lines (64 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Defines the preprocessor macro MINIGO_BOARD_SIZE=9 for all minigo_cc_*
# build targets when bazel build is invoked with --define=board_size=9.
# Defines the preprocessor macro MINIGO_BOARD_SIZE=19 for all minigo_cc_*
# build targets when bazel build is invoked with --define=board_size=19.
def _board_size_copts():
return select({
"//cc/config:minigo9": ["-DMINIGO_BOARD_SIZE=9"],
"//cc/config:minigo19": ["-DMINIGO_BOARD_SIZE=19"],
})
# Generates a cc_binary target that defines MINIGO_BOARD_SIZE.
def minigo_cc_binary(name, copts=[], **kwargs):
native.cc_binary(
name = name,
copts = _board_size_copts() + copts,
**kwargs)
# Generates a cc_library target that defines MINIGO_BOARD_SIZE.
def minigo_cc_library(name, copts=[], **kwargs):
native.cc_library(
name = name,
copts = _board_size_copts() + copts,
**kwargs)
# Generates a cc_test target that defines MINIGO_BOARD_SIZE.
def minigo_cc_test(name, size="small", copts=[], **kwargs):
native.cc_test(
name = name,
size = size,
copts = _board_size_copts() + copts,
**kwargs)
# Generates a cc_test target that defines MINIGO_BOARD_SIZE when bazel test is
# invoked with --define=board_size=9.
# Generates an empty test stub if the board_size is not defined or set to 19.
# this should be used when writing unit tests that require a 9x9 board.
def minigo_cc_test_9_only(name, srcs, size="small", deps=[], copts=[], **kwargs):
native.cc_test(
name = name,
size = size,
srcs = select({
"//cc/config:minigo9": srcs,
"//conditions:default": [],
}),
deps = select({
"//cc/config:minigo9": deps,
"//conditions:default": ["@com_google_googletest//:gtest_main"],
}),
copts = _board_size_copts() + copts,
**kwargs)
# Generates a cc_test target that defines MINIGO_BOARD_SIZE when bazel test is
# invoked with --define=board_size=19.
# Generates an empty test stub if the board_size is not defined or set to 9.
# This should be used when writing unit tests that require a 19x19 board.
def minigo_cc_test_19_only(name, srcs, size="small", deps=[], copts=[], **kwargs):
native.cc_test(
name = name,
size = size,
srcs = select({
"//cc/config:minigo19": srcs,
"//conditions:default": [],
}),
deps = select({
"//cc/config:minigo19": deps,
"//conditions:default": ["@com_google_googletest//:gtest_main"],
}),
copts = _board_size_copts() + copts,
**kwargs)