| load("@bazel_skylib//rules:write_file.bzl", "write_file") |
| load("@com_github_johnynek_bazel_jar_jar//:jar_jar.bzl", "jar_jar") |
| load("@fmeum_rules_jni//jni:defs.bzl", "java_jni_library") |
| load("@rules_jvm_external//:defs.bzl", "javadoc") |
| load("//:maven.bzl", "JAZZER_VERSION") |
| load("//bazel:compat.bzl", "SKIP_ON_WINDOWS") |
| load("//bazel:jar.bzl", "strip_jar") |
| load("//sanitizers:sanitizers.bzl", "SANITIZER_CLASSES") |
| |
| strip_jar( |
| name = "jazzer", |
| out = "jazzer.jar", |
| jar = ":jazzer_shaded", |
| paths_to_strip = [ |
| "module-info.class", |
| ], |
| visibility = ["//visibility:public"], |
| ) |
| |
| java_library( |
| name = "constants", |
| srcs = [":constants_java"], |
| visibility = ["//visibility:public"], |
| ) |
| |
| java_import( |
| name = "jazzer_import", |
| jars = [":jazzer"], |
| visibility = ["//:__subpackages__"], |
| ) |
| |
| jar_jar( |
| name = "jazzer_shaded", |
| input_jar = "jazzer_unshaded_deploy.jar", |
| rules = "jazzer_shade_rules.jarjar", |
| ) |
| |
| DEPLOY_MANIFEST_LINES = [ |
| "Jazzer-Hook-Classes: ", |
| ] + [" {}:".format(c) for c in SANITIZER_CLASSES] |
| |
| java_binary( |
| name = "jazzer_unshaded", |
| # Note: We can't add |
| # //agent/src/main/java/com/code_intelligence/jazzer/runtime:java_bootstrap_unshaded itself as |
| # that would also strip out external dependencies common between Jazzer and its bootstrap jar, |
| # such as e.g. RulesJni, which should be shaded into distinct classes. |
| deploy_env = [ |
| "//agent/src/main/java/com/code_intelligence/jazzer/runtime:jazzer_bootstrap_env", |
| ], |
| deploy_manifest_lines = DEPLOY_MANIFEST_LINES, |
| main_class = "com.code_intelligence.jazzer.Jazzer", |
| visibility = ["//driver/src/main/java/com/code_intelligence/jazzer/junit:__pkg__"], |
| runtime_deps = [":jazzer_lib"], |
| ) |
| |
| # Docs are only generated for the com.code_intelligence.jazzer package. Everything else is not |
| # considered a public interface. |
| javadoc( |
| name = "jazzer-docs", |
| visibility = ["//deploy:__pkg__"], |
| deps = [":jazzer_lib"], |
| ) |
| |
| strip_jar( |
| name = "jazzer-sources", |
| jar = ":jazzer_transitive_sources_deploy-src.jar", |
| paths_to_keep = [ |
| "com/code_intelligence/jazzer/**", |
| "jaz/**", |
| "META-INF/**", |
| ], |
| visibility = ["//deploy:__pkg__"], |
| ) |
| |
| # The _deploy-src.jar for this target includes the sources for the jazzer_bootstrap library. |
| java_binary( |
| name = "jazzer_transitive_sources", |
| deploy_manifest_lines = DEPLOY_MANIFEST_LINES, |
| main_class = "com.code_intelligence.jazzer.Jazzer", |
| runtime_deps = [ |
| ":jazzer_lib", |
| "//agent/src/main/java/com/code_intelligence/jazzer/runtime:jazzer_bootstrap_lib", |
| ], |
| ) |
| |
| java_library( |
| name = "jazzer_lib", |
| srcs = ["Jazzer.java"], |
| visibility = ["//driver/src/main/java/com/code_intelligence/jazzer/junit:__pkg__"], |
| runtime_deps = select({ |
| "@platforms//os:windows": [], |
| "//conditions:default": ["//driver/src/main/native/com/code_intelligence/jazzer:jazzer_preload"], |
| }), |
| deps = [ |
| "//driver/src/main/java/com/code_intelligence/jazzer/driver", |
| "@fmeum_rules_jni//jni/tools/native_loader", |
| ], |
| ) |
| |
| sh_test( |
| name = "jazzer_shading_test", |
| srcs = ["verify_shading.sh"], |
| args = [ |
| "$(rootpath :jazzer)", |
| ], |
| data = [ |
| ":jazzer", |
| "@local_jdk//:bin/jar", |
| ], |
| tags = [ |
| # Coverage instrumentation necessarily adds files to the jar that we |
| # wouldn't want to release and thus causes this test to fail. |
| "no-coverage", |
| ], |
| target_compatible_with = SKIP_ON_WINDOWS, |
| ) |
| |
| write_file( |
| name = "constants_java", |
| out = "Constants.java", |
| content = [ |
| "package com.code_intelligence.jazzer;", |
| "public final class Constants {", |
| " public static final String JAZZER_VERSION = \"%s\";" % JAZZER_VERSION, |
| "}", |
| ], |
| ) |