xref: /aosp_15_r20/external/libpng/Android.bp (revision a67afe4df73cf47866eedc69947994b8ff839aba)
1// We need to build this for both the device (as a shared library)
2// and the host (as a static library for tools to use).
3
4package {
5    default_applicable_licenses: ["external_libpng_license"],
6}
7
8// Added automatically by a large-scale-change that took the approach of
9// 'apply every license found to every target'. While this makes sure we respect
10// every license restriction, it may not be entirely correct.
11//
12// e.g. GPL in an MIT project might only apply to the contrib/ directory.
13//
14// Please consider splitting the single license below into multiple licenses,
15// taking care not to lose any license_kind information, and overriding the
16// default license using the 'licenses: [...]' property on targets as needed.
17//
18// For unused files, consider creating a 'fileGroup' with "//visibility:private"
19// to attach the license to, and including a comment whether the files may be
20// used in the current project.
21//
22// large-scale-change filtered out the below license kinds as false-positives:
23//   SPDX-license-identifier-GPL
24//   SPDX-license-identifier-GPL-2.0
25//   SPDX-license-identifier-LGPL
26// See: http://go/android-license-faq
27license {
28    name: "external_libpng_license",
29    visibility: [":__subpackages__"],
30    license_kinds: [
31        "SPDX-license-identifier-Apache-2.0",
32        "SPDX-license-identifier-BSD",
33        "SPDX-license-identifier-CC0-1.0",
34        "SPDX-license-identifier-MIT",
35        "SPDX-license-identifier-W3C",
36        "SPDX-license-identifier-Zlib",
37        "legacy_notice",
38        "legacy_unencumbered",
39    ],
40    license_text: [
41        "LICENSE",
42    ],
43}
44
45cc_defaults {
46    name: "libpng-defaults",
47    exclude_srcs: [
48        "example.c",
49        "pngtest.c",
50    ],
51    srcs: ["*.c"],
52    cflags: [
53        "-std=gnu89",
54        "-Wall",
55        "-Werror",
56        "-Wno-unused-parameter",
57    ],
58    arch: {
59        arm: {
60            srcs: ["arm/*"],
61            cflags: ["-O3"],
62        },
63        arm64: {
64            srcs: ["arm/*"],
65            cflags: ["-O3"],
66            exclude_srcs: [
67                "arm/filter_neon.S",
68            ],
69        },
70        x86: {
71            srcs: ["intel/*"],
72            // Disable optimizations because they crash on windows
73            // cflags: ["-DPNG_INTEL_SSE_OPT=1"],
74        },
75        x86_64: {
76            srcs: ["intel/*"],
77            // Disable optimizations because they crash on windows
78            // cflags: ["-DPNG_INTEL_SSE_OPT=1"],
79        },
80    },
81    shared_libs: ["libz"],
82    target: {
83        android_x86: {
84            cflags: ["-DPNG_INTEL_SSE_OPT=1"],
85        },
86        android_x86_64: {
87            cflags: ["-DPNG_INTEL_SSE_OPT=1"],
88        },
89    },
90    export_include_dirs: ["."],
91}
92
93// For the host and device platform
94// =====================================================
95
96cc_library {
97    name: "libpng",
98    vendor_available: true,
99    product_available: true,
100    // TODO(b/153609531): remove when no longer needed.
101    native_bridge_supported: true,
102    recovery_available: true,
103    double_loadable: true,
104    host_supported: true,
105    defaults: ["libpng-defaults"],
106    target: {
107        windows: {
108            enabled: true,
109        },
110    },
111
112    sdk_version: "current",
113    min_sdk_version: "apex_inherit",
114    apex_available: [
115        "com.android.mediaprovider",
116        "//apex_available:platform",
117    ],
118}
119
120// For the device (static) for NDK
121// =====================================================
122
123cc_library_static {
124    name: "libpng_ndk",
125    defaults: ["libpng-defaults"],
126    cflags: ["-ftrapv"],
127
128    shared_libs: ["libz"],
129    sdk_version: "minimum",
130}
131
132// For testing
133// =====================================================
134
135cc_test {
136    host_supported: true,
137    gtest: false,
138    srcs: ["pngtest.c"],
139    name: "pngtest",
140    cflags: [
141        "-Wall",
142        "-Werror",
143    ],
144    shared_libs: [
145        "libpng",
146        "libz",
147    ],
148}
149
150cc_fuzz {
151    name: "libpng_read_fuzzer",
152    host_supported: true,
153
154    static_libs: [
155        "libpng",
156        "libz",
157    ],
158
159    srcs: [
160        "contrib/oss-fuzz/libpng_read_fuzzer.cc",
161    ],
162
163    dictionary: "contrib/oss-fuzz/png.dict",
164
165    corpus: ["contrib/testpngs/*.png"],
166
167    fuzz_config: {
168        cc: [
169            "[email protected]",
170        ],
171        componentid: 87896,
172    },
173}
174