aboutsummaryrefslogtreecommitdiff
path: root/launcher/BUILD.bazel
blob: 50bd47727e27a2ac2eebe5260cbc527890cf350d (plain)
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("@build_bazel_apple_support//rules:universal_binary.bzl", "universal_binary")

cc_library(
    name = "jazzer_main",
    srcs = ["jazzer_main.cpp"],
    deps = [
        ":jvm_tooling_lib",
        "@com_google_absl//absl/strings",
        "@fmeum_rules_jni//jni:libjvm",
    ],
)

cc_library(
    name = "jvm_tooling_lib",
    srcs = ["jvm_tooling.cpp"],
    hdrs = ["jvm_tooling.h"],
    data = [
        "//src/main/java/com/code_intelligence/jazzer:jazzer_standalone_deploy.jar",
    ],
    linkopts = select({
        "@platforms//os:android": ["-ldl"],
        "//conditions:default": [],
    }),
    deps = [
        "@bazel_tools//tools/cpp/runfiles",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@fmeum_rules_jni//jni",
    ],
)

cc_binary(
    name = "jazzer_single_arch",
    linkstatic = True,
    tags = ["manual"],
    visibility = ["//launcher/android:__pkg__"],
    deps = [":jazzer_main"],
)

# On macOS, builds a binary that supports both x86_64 and arm64.
# On all other platforms, it just symlinks the input binary.
universal_binary(
    name = "jazzer",
    binary = ":jazzer_single_arch",
    visibility = ["//visibility:public"],
)

cc_test(
    name = "jvm_tooling_test",
    size = "small",
    srcs = ["jvm_tooling_test.cpp"],
    data = [
        "//launcher/testdata:fuzz_target_mocks_deploy.jar",
    ],
    env = {
        "JAVA_OPTS": "-Djazzer.hooks=false",
    },
    includes = ["."],
    deps = [
        ":jvm_tooling_lib",
        ":test_main",
        "@bazel_tools//tools/cpp/runfiles",
        "@googletest//:gtest",
    ],
)

cc_test(
    name = "fuzzed_data_provider_test",
    size = "medium",
    srcs = ["fuzzed_data_provider_test.cpp"],
    copts = select({
        "@platforms//os:windows": ["/std:c++17"],
        "//conditions:default": ["-std=c++17"],
    }),
    data = [
        "//launcher/testdata:fuzz_target_mocks_deploy.jar",
    ],
    env = {
        "JAVA_OPTS": "-Djazzer.hooks=false",
    },
    includes = ["."],
    deps = [
        ":jvm_tooling_lib",
        ":test_main",
        "//src/main/native/com/code_intelligence/jazzer/driver:fuzzed_data_provider",
        "@bazel_tools//tools/cpp/runfiles",
        "@googletest//:gtest",
    ],
)

cc_library(
    name = "test_main",
    srcs = ["test_main.cpp"],
    linkstatic = True,
    deps = [
        "@fmeum_rules_jni//jni:libjvm",
        "@googletest//:gtest",
    ],
)