-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD
99 lines (87 loc) · 2.15 KB
/
BUILD
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
load("//:rules/echo.bzl", "echo")
load("//:rules/assert_no_diffs.bzl", "assert_no_diffs")
load("@pip//:requirements.bzl", "requirement")
# Define the binaries that can power the echo rule. The Java and Python binaries do the same thing
# and have the same command-line API.
java_binary(
name = "EchoJava",
srcs = [
"Echo.java",
],
main_class = "workertest.Echo",
deps = [
"@io_bazel//src/main/protobuf:worker_protocol_java_proto",
"@jcommander//jar",
],
)
py_binary(
name = "echo_py",
srcs = [
"echo.py",
],
main = "echo.py",
deps = [
"//forked:worker_protocol",
requirement("protobuf"),
requirement("six"),
],
)
# Generate some fake input.
genrule(
name = "input",
srcs = [],
outs = ["input.txt"],
cmd = """echo "hello world" > $@""",
)
# Define the actions. 3 pathways per binary (see echo.bzl) x 2 binaries = 6 targets.
echo(
name = "java_non_worker_1",
executable = ":EchoJava",
input = ":input",
)
echo(
name = "java_non_worker_2",
executable = ":EchoJava",
input = ":input",
mnemonic = "oops", # mnemonic doesn't match --strategy in .bazelrc: not executed as worker
use_worker_if_possible = True,
)
echo(
name = "java_worker",
executable = ":EchoJava",
input = ":input",
mnemonic = "EchoWorker",
use_worker_if_possible = True,
)
echo(
name = "python_non_worker_1",
executable = ":echo_py",
input = ":input",
)
echo(
name = "python_non_worker_2",
executable = ":echo_py",
input = ":input",
mnemonic = "oops", # mnemonic doesn't match --strategy in .bazelrc: not executed as worker
use_worker_if_possible = True,
)
echo(
name = "python_worker",
executable = ":echo_py",
input = ":input",
mnemonic = "EchoWorker",
use_worker_if_possible = True,
)
# All of the actions should produce the same output.
assert_no_diffs(
name = "no_diffs",
actual = [
":java_non_worker_1",
":java_non_worker_2",
":java_worker",
":python_non_worker_1",
":python_non_worker_2",
":python_worker",
],
expected = ":input",
)