1load("@build_bazel_apple_support//rules:universal_binary.bzl", "universal_binary") 2 3cc_library( 4 name = "jazzer_main", 5 srcs = ["jazzer_main.cpp"], 6 deps = [ 7 ":jvm_tooling_lib", 8 "@com_google_absl//absl/strings", 9 "@fmeum_rules_jni//jni:libjvm", 10 ], 11) 12 13cc_library( 14 name = "jvm_tooling_lib", 15 srcs = ["jvm_tooling.cpp"], 16 hdrs = ["jvm_tooling.h"], 17 data = [ 18 "//src/main/java/com/code_intelligence/jazzer:jazzer_standalone_deploy.jar", 19 ], 20 linkopts = select({ 21 "@platforms//os:android": ["-ldl"], 22 "//conditions:default": [], 23 }), 24 deps = [ 25 "@bazel_tools//tools/cpp/runfiles", 26 "@com_google_absl//absl/strings", 27 "@com_google_absl//absl/strings:str_format", 28 "@fmeum_rules_jni//jni", 29 ], 30) 31 32cc_binary( 33 name = "jazzer_single_arch", 34 linkstatic = True, 35 tags = ["manual"], 36 visibility = ["//launcher/android:__pkg__"], 37 deps = [":jazzer_main"], 38) 39 40# On macOS, builds a binary that supports both x86_64 and arm64. 41# On all other platforms, it just symlinks the input binary. 42universal_binary( 43 name = "jazzer", 44 binary = ":jazzer_single_arch", 45 visibility = ["//visibility:public"], 46) 47 48cc_test( 49 name = "jvm_tooling_test", 50 size = "small", 51 srcs = ["jvm_tooling_test.cpp"], 52 data = [ 53 "//launcher/testdata:fuzz_target_mocks_deploy.jar", 54 ], 55 env = { 56 "JAVA_OPTS": "-Djazzer.hooks=false", 57 }, 58 includes = ["."], 59 deps = [ 60 ":jvm_tooling_lib", 61 ":test_main", 62 "@bazel_tools//tools/cpp/runfiles", 63 "@googletest//:gtest", 64 ], 65) 66 67cc_test( 68 name = "fuzzed_data_provider_test", 69 size = "medium", 70 srcs = ["fuzzed_data_provider_test.cpp"], 71 copts = select({ 72 "@platforms//os:windows": ["/std:c++17"], 73 "//conditions:default": ["-std=c++17"], 74 }), 75 data = [ 76 "//launcher/testdata:fuzz_target_mocks_deploy.jar", 77 ], 78 env = { 79 "JAVA_OPTS": "-Djazzer.hooks=false", 80 }, 81 includes = ["."], 82 deps = [ 83 ":jvm_tooling_lib", 84 ":test_main", 85 "//src/main/native/com/code_intelligence/jazzer/driver:fuzzed_data_provider", 86 "@bazel_tools//tools/cpp/runfiles", 87 "@googletest//:gtest", 88 ], 89) 90 91cc_library( 92 name = "test_main", 93 srcs = ["test_main.cpp"], 94 linkstatic = True, 95 deps = [ 96 "@fmeum_rules_jni//jni:libjvm", 97 "@googletest//:gtest", 98 ], 99) 100