Yue Gan | af3c412 | 2016-12-05 14:36:02 +0000 | [diff] [blame] | 1 | package( |
| 2 | default_visibility = ["//visibility:legacy_public"], |
| 3 | ) |
| 4 | |
| 5 | licenses(["notice"]) |
| 6 | |
| 7 | filegroup( |
| 8 | name = "bazel-srcs", |
| 9 | testonly = 0, |
Lukacs Berki | 03cb310 | 2017-01-10 13:16:29 +0000 | [diff] [blame] | 10 | srcs = glob( |
| 11 | ["**"], |
| 12 | exclude = ["BUILD"], |
| 13 | ), |
Yue Gan | af3c412 | 2016-12-05 14:36:02 +0000 | [diff] [blame] | 14 | visibility = ["//third_party/bazel:__subpackages__"], |
| 15 | ) |
| 16 | |
| 17 | filegroup( |
| 18 | name = "srcs", |
| 19 | srcs = glob(["**"]), |
| 20 | ) |
| 21 | |
| 22 | filegroup( |
| 23 | name = "embedded_tools", |
| 24 | srcs = [ |
Lukacs Berki | 63c9af4 | 2017-01-18 12:18:05 +0000 | [diff] [blame] | 25 | "JacocoCoverage_jarjar_deploy.jar", |
Yue Gan | af3c412 | 2016-12-05 14:36:02 +0000 | [diff] [blame] | 26 | ], |
| 27 | ) |
| 28 | |
| 29 | filegroup( |
| 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. |
| 40 | java_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 Berki | bde8530 | 2017-01-11 12:40:44 +0000 | [diff] [blame] | 55 | "//third_party/java/jacoco:blaze-agent", |
Yue Gan | af3c412 | 2016-12-05 14:36:02 +0000 | [diff] [blame] | 56 | "//third_party/java/jacoco:core", |
| 57 | "//third_party/java/jacoco:report", |
| 58 | ], |
| 59 | ) |
| 60 | |
| 61 | java_library( |
| 62 | name = "bitfield", |
| 63 | srcs = [ |
| 64 | "BitField.java", |
| 65 | "IllegalStringException.java", |
| 66 | ], |
| 67 | deps = [ |
| 68 | "//third_party:apache_commons_lang", |
| 69 | ], |
| 70 | ) |
Lukacs Berki | 63c9af4 | 2017-01-18 12:18:05 +0000 | [diff] [blame] | 71 | |
| 72 | genrule( |
| 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 Aehlig | 9a33850 | 2017-01-20 10:04:35 +0000 | [diff] [blame] | 94 | # |
| 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 Berki | 88eca6e | 2017-01-20 15:28:28 +0000 | [diff] [blame] | 99 | # |
| 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ó Csomor | 1a09e7e | 2017-03-22 15:40:57 +0000 | [diff] [blame] | 105 | "if [[ $$(uname -a) =~ MSYS ]] || [[ $$(uname -a) =~ CYGWIN ]] || [[ $$(uname -a) =~ freebsd ]]; then", |
Lukacs Berki | 63c9af4 | 2017-01-18 12:18:05 +0000 | [diff] [blame] | 106 | " cp \"$(location :JacocoCoverage_deploy.jar)\" \"$@\";", |
| 107 | "else", |
Lukacs T. Berki | 55828e2 | 2017-04-18 14:23:19 +0200 | [diff] [blame^] | 108 | " \"$(JAVA)\" -jar \"$(location //third_party/java/jarjar:jarjar_command_deploy.jar)\" --rules \"$(location :JacocoCoverage.jarjar)\" --output \"$@\" \"$(location :JacocoCoverage_deploy.jar)\"", |
Lukacs Berki | 63c9af4 | 2017-01-18 12:18:05 +0000 | [diff] [blame] | 109 | "fi", |
| 110 | ]), |
Lukacs Berki | 88eca6e | 2017-01-20 15:28:28 +0000 | [diff] [blame] | 111 | tools = [ |
Lukacs T. Berki | 55828e2 | 2017-04-18 14:23:19 +0200 | [diff] [blame^] | 112 | "//third_party/java/jarjar:jarjar_command_deploy.jar", |
Lukacs Berki | 88eca6e | 2017-01-20 15:28:28 +0000 | [diff] [blame] | 113 | "//tools/defaults:jdk", |
| 114 | ], |
Lukacs Berki | 63c9af4 | 2017-01-18 12:18:05 +0000 | [diff] [blame] | 115 | ) |