1// Copyright (C) 2016 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package {
16    // See: http://go/android-license-faq
17    // A large-scale-change added 'default_applicable_licenses' to import
18    // all of the 'license_kinds' from "frameworks_base_license"
19    // to get the below license kinds:
20    //   SPDX-license-identifier-Apache-2.0
21    default_applicable_licenses: ["frameworks_base_license"],
22}
23
24cc_library_shared {
25    name: "libjnigraphics",
26
27    cflags: [
28        "-Wall",
29        "-Werror",
30        "-Wunused",
31        "-Wunreachable-code",
32    ],
33
34    srcs: [
35        "imagedecoder.cpp",
36    ],
37
38    shared_libs: [
39        "libhwui",
40        "liblog",
41    ],
42
43    header_libs: [
44        "jni_headers",
45        "libhwui_internal_headers",
46    ],
47
48    static_libs: ["libarect"],
49
50    arch: {
51        arm: {
52            // TODO: This is to work around b/24465209. Remove after root cause is fixed
53            pack_relocations: false,
54            ldflags: ["-Wl,--hash-style=both"],
55        },
56    },
57    host_supported: true,
58    target: {
59        android: {
60            srcs: [
61                "aassetstreamadaptor.cpp",
62                "bitmap.cpp",
63            ],
64            shared_libs: [
65                "libandroid",
66            ],
67            version_script: "libjnigraphics.map.txt",
68        },
69        host: {
70            header_libs: [
71                "libnativewindow_headers",
72            ],
73        },
74    },
75    stubs: {
76        symbol_file: "libjnigraphics.map.txt",
77    },
78}
79
80// The headers module is in frameworks/native/Android.bp.
81ndk_library {
82    name: "libjnigraphics",
83    symbol_file: "libjnigraphics.map.txt",
84    first_version: "9",
85    unversioned_until: "current",
86}
87
88cc_defaults {
89    name: "imagedecoder_fuzzer_defaults",
90    srcs: ["fuzz/fuzz_imagedecoder.cpp"],
91    header_libs: ["jni_headers"],
92    shared_libs: [
93        "libbinder",
94        "libjnigraphics",
95        "libutils",
96    ],
97    static_libs: ["libarect"],
98    fuzz_config: {
99        cc: [
100            "dichenzhang@google.com",
101            "scroggo@google.com",
102        ],
103        asan_options: [
104            "detect_odr_violation=1",
105        ],
106        hwasan_options: [
107            // Image decoders may attempt to allocate a large amount of memory
108            // (especially if the encoded image is large). This doesn't
109            // necessarily mean there is a bug. Set allocator_may_return_null=1
110            // for hwasan so the fuzzer can continue running.
111            "allocator_may_return_null = 1",
112        ],
113    },
114    dictionary: "fuzz/imagedecoder_fuzzer.dict",
115    host_supported: true,
116}
117
118cc_fuzz {
119    name: "imagedecoder_fuzzer",
120    defaults: ["imagedecoder_fuzzer_defaults"],
121    corpus: ["fuzz/corpus/*"],
122}
123
124cc_fuzz {
125    name: "imagedecoder_png_fuzzer",
126    defaults: ["imagedecoder_fuzzer_defaults"],
127    shared_libs: [
128        "libz",
129    ],
130    cflags: [
131        "-DPNG_MUTATOR_DEFINE_LIBFUZZER_CUSTOM_MUTATOR",
132    ],
133}
134