blob: 1714f62434776b3b0c4bcf6b592325bf91b3fcb9 [file] [log] [blame]
Yue Ganaf3c4122016-12-05 14:36:02 +00001package(
2 default_visibility = ["//visibility:legacy_public"],
3)
4
5licenses(["notice"])
6
7filegroup(
8 name = "bazel-srcs",
9 testonly = 0,
Lukacs Berki03cb3102017-01-10 13:16:29 +000010 srcs = glob(
11 ["**"],
12 exclude = ["BUILD"],
13 ),
Yue Ganaf3c4122016-12-05 14:36:02 +000014 visibility = ["//third_party/bazel:__subpackages__"],
15)
16
17filegroup(
18 name = "srcs",
19 srcs = glob(["**"]),
20)
21
22filegroup(
23 name = "embedded_tools",
24 srcs = [
Lukacs Berki63c9af42017-01-18 12:18:05 +000025 "JacocoCoverage_jarjar_deploy.jar",
Yue Ganaf3c4122016-12-05 14:36:02 +000026 ],
27)
28
29filegroup(
30 name = "jacoco_coverage_runtime",
31 srcs = ["JacocoCoverage_deploy.jar"],
32)
33
34# Bazel custom Jacoco runner used to provide proper initialization and lcov
35# report generation when using offline Jacoco instrumentation.
36# This target should not be used as a dependency (except when writing tests for
37# it).
38#
39# An implicit dependency of all "java_binary" rules.
40java_binary(
41 name = "JacocoCoverage",
42 srcs = [
43 "BranchCoverageDetail.java",
44 "BranchDetailAnalyzer.java",
45 "BranchExp.java",
46 "ClassProbesMapper.java",
47 "CovExp.java",
48 "JacocoCoverageRunner.java",
49 "JacocoLCOVFormatter.java",
50 "MethodProbesMapper.java",
51 "ProbeExp.java",
52 ],
53 deps = [
54 ":bitfield",
Lukacs Berkibde85302017-01-11 12:40:44 +000055 "//third_party/java/jacoco:blaze-agent",
Yue Ganaf3c4122016-12-05 14:36:02 +000056 "//third_party/java/jacoco:core",
57 "//third_party/java/jacoco:report",
58 ],
59)
60
61java_library(
62 name = "bitfield",
63 srcs = [
64 "BitField.java",
65 "IllegalStringException.java",
66 ],
67 deps = [
68 "//third_party:apache_commons_lang",
69 ],
70)
Lukacs Berki63c9af42017-01-18 12:18:05 +000071
72genrule(
73 name = "Jacoco_jarjar",
74 srcs = [
75 ":JacocoCoverage_deploy.jar",
76 ":JacocoCoverage.jarjar",
77 ],
78 outs = ["JacocoCoverage_jarjar_deploy.jar"],
79 cmd = "\n".join([
80 # Bazel 0.4.3 contains two bugs: a quoting bug in the Java cmd.exe
81 # wrapper script that makes it unable to handle $ signs in paths (#2306)
82 # and one that makes it occasionally put $ signs in the output base
83 # (#2342).
84 #
85 # These two collude to make it impossible to run built Java binaries on
86 # Windows if the output base happens to contain a $ sign.
87 #
88 # Thus, don't call jarjar when on Windows. This makes Java coverage not
89 # work if the code under test uses libraries the test runner also does
90 # (e.g. ASM).
91 #
92 # TODO(lberki): Remove this once a Bazel version with a fix to either of
93 # these bugs is out.
Klaus Aehlig9a338502017-01-20 10:04:35 +000094 #
95 # Additionally, there is a hard-coded path to /bin/bash which is wrong on
96 # freebsd; so disable there as well until a fixed version is in there as
97 # well.
98 # TODO(aehlig): fix and remove once a version with the fix is out.
Lukacs Berki88eca6e2017-01-20 15:28:28 +000099 #
100 # We don't invoke jarjar_bin directly because this command is invoked
101 # during bootstrapping when we don't have build-runfiles, thus no
102 # runfiles trees. The Java launcher script looks in the runfiles tree
103 # for the jars (and rightfully so), thus, invoking the binary directly
104 # won't work.
László Csomor1a09e7e2017-03-22 15:40:57 +0000105 "if [[ $$(uname -a) =~ MSYS ]] || [[ $$(uname -a) =~ CYGWIN ]] || [[ $$(uname -a) =~ freebsd ]]; then",
Lukacs Berki63c9af42017-01-18 12:18:05 +0000106 " cp \"$(location :JacocoCoverage_deploy.jar)\" \"$@\";",
107 "else",
Lukacs T. Berki55828e22017-04-18 14:23:19 +0200108 " \"$(JAVA)\" -jar \"$(location //third_party/java/jarjar:jarjar_command_deploy.jar)\" --rules \"$(location :JacocoCoverage.jarjar)\" --output \"$@\" \"$(location :JacocoCoverage_deploy.jar)\"",
Lukacs Berki63c9af42017-01-18 12:18:05 +0000109 "fi",
110 ]),
Lukacs Berki88eca6e2017-01-20 15:28:28 +0000111 tools = [
Lukacs T. Berki55828e22017-04-18 14:23:19 +0200112 "//third_party/java/jarjar:jarjar_command_deploy.jar",
Lukacs Berki88eca6e2017-01-20 15:28:28 +0000113 "//tools/defaults:jdk",
114 ],
Lukacs Berki63c9af42017-01-18 12:18:05 +0000115)