blob: 2f19a8fe5f6331d013b4dbdeada8d70e896d8ec4 [file] [log] [blame]
[email protected]c6f27f22013-08-21 21:44:591# Copyright (c) 2013 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Chris Blume616f37b2017-10-31 23:18:185import("//testing/libfuzzer/fuzzer_test.gni")
6
Adenilson Cavalcanti78104f42017-09-29 03:24:527if (current_cpu == "arm" || current_cpu == "arm64") {
8 import("//build/config/arm.gni")
9}
10
[email protected]c6f27f22013-08-21 21:44:5911config("zlib_config") {
[email protected]2ed04ae2013-10-07 20:17:1612 include_dirs = [ "." ]
Adenilson Cavalcanti626df312017-10-30 18:39:2913 if (current_cpu == "arm" || current_cpu == "arm64") {
14 if (arm_use_neon) {
15 include_dirs += [ "contrib/optimizations/arm" ]
16 }
17 }
[email protected]c6f27f22013-08-21 21:44:5918}
19
Noel Gordon09b784f2017-09-29 19:44:2520config("zlib_adler32_simd_config") {
21 if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
22 defines = [ "ADLER32_SIMD_SSSE3" ]
23 }
24
25 if (current_cpu == "arm" || current_cpu == "arm64") {
26 if (arm_use_neon) {
27 defines = [ "ADLER32_SIMD_NEON" ]
28 }
29 }
30}
31
32source_set("zlib_adler32_simd") {
33 visibility = [ ":*" ]
34
35 if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
36 sources = [
37 "adler32_simd.c",
38 "adler32_simd.h",
39 ]
40
41 if (!is_win || is_clang) {
42 cflags = [ "-mssse3" ]
43 }
44 }
45
46 if (current_cpu == "arm" || current_cpu == "arm64") {
47 if (arm_use_neon) {
48 sources = [
49 "adler32_simd.c",
50 "adler32_simd.h",
51 ]
52
53 if (!is_debug) {
54 # Use optimize_speed (-O3) to output the _smallest_ code.
55 configs -= [ "//build/config/compiler:default_optimization" ]
56 configs += [ "//build/config/compiler:optimize_speed" ]
57 }
58 }
59 }
60
61 configs -= [ "//build/config/compiler:chromium_code" ]
62 configs += [ "//build/config/compiler:no_chromium_code" ]
63
64 public_configs = [ ":zlib_adler32_simd_config" ]
65}
66
robert.bradford02a95e32014-11-05 14:59:3467static_library("zlib_x86_simd") {
dpranke43276212015-02-20 02:55:1968 if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
scottmg1c240d272014-12-03 07:28:0069 sources = [
70 "crc_folding.c",
71 "fill_window_sse.c",
72 ]
Nico Weberf3b5bb22014-11-18 23:21:1773 if (!is_win || is_clang) {
scottmg1c240d272014-12-03 07:28:0074 cflags = [
75 "-msse4.2",
76 "-mpclmul",
77 ]
Nico Weberf3b5bb22014-11-18 23:21:1778 }
robert.bradford02a95e32014-11-05 14:59:3479 } else {
scottmg1c240d272014-12-03 07:28:0080 sources = [
81 "simd_stub.c",
82 ]
robert.bradford02a95e32014-11-05 14:59:3483 }
dprankede7d0dc2014-11-18 01:54:5584
85 configs -= [ "//build/config/compiler:chromium_code" ]
86 configs += [ "//build/config/compiler:no_chromium_code" ]
robert.bradford02a95e32014-11-05 14:59:3487}
88
brettw6dd952c72015-09-02 17:57:0589config("zlib_warnings") {
tfarinaf7698e02015-11-03 00:49:3990 if (is_clang && !is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
brettw6dd952c72015-09-02 17:57:0591 cflags = [ "-Wno-incompatible-pointer-types" ]
92 }
93}
94
[email protected]6a0f2772013-10-03 17:16:1195static_library("zlib") {
[email protected]6a0f2772013-10-03 17:16:1196 if (!is_win) {
97 # Don't stomp on "libzlib" on other platforms.
98 output_name = "chrome_zlib"
99 }
100
[email protected]c6f27f22013-08-21 21:44:59101 sources = [
102 "adler32.c",
103 "compress.c",
104 "crc32.c",
105 "crc32.h",
106 "deflate.c",
107 "deflate.h",
108 "gzclose.c",
109 "gzguts.h",
110 "gzlib.c",
111 "gzread.c",
112 "gzwrite.c",
113 "infback.c",
114 "inffast.c",
115 "inffast.h",
116 "inffixed.h",
117 "inflate.c",
118 "inflate.h",
119 "inftrees.c",
120 "inftrees.h",
mark6d9a6252017-02-15 06:15:29121 "names.h",
[email protected]c6f27f22013-08-21 21:44:59122 "trees.c",
123 "trees.h",
124 "uncompr.c",
robert.bradford02a95e32014-11-05 14:59:34125 "x86.h",
[email protected]c6f27f22013-08-21 21:44:59126 "zconf.h",
127 "zlib.h",
128 "zutil.c",
129 "zutil.h",
130 ]
131
Adenilson Cavalcanti78104f42017-09-29 03:24:52132 if (current_cpu == "arm" || current_cpu == "arm64") {
133 if (arm_use_neon) {
Adenilson Cavalcanti0bb110402017-11-03 17:49:46134 sources -= [ "inflate.c" ]
Adenilson Cavalcanti78104f42017-09-29 03:24:52135 sources += [
Adenilson Cavalcanti626df312017-10-30 18:39:29136 "contrib/optimizations/arm/chunkcopy_arm.h",
137 "contrib/optimizations/chunkcopy.h",
138 "contrib/optimizations/inffast_chunky.c",
Adenilson Cavalcanti0bb110402017-11-03 17:49:46139 "contrib/optimizations/inffast_chunky.h",
Adenilson Cavalcanti626df312017-10-30 18:39:29140 "contrib/optimizations/inflate.c",
Adenilson Cavalcanti78104f42017-09-29 03:24:52141 ]
142 }
143 }
144
Boris Sazonove7d9a4642017-11-30 10:01:30145 defines = []
146 deps = []
147
dpranke43276212015-02-20 02:55:19148 if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
robert.bradford02a95e32014-11-05 14:59:34149 sources += [ "x86.c" ]
Noel Gordon09b784f2017-09-29 19:44:25150
151 deps += [ ":zlib_adler32_simd" ]
152 }
153
154 if (current_cpu == "arm" || current_cpu == "arm64") {
155 if (arm_use_neon) {
156 deps += [ ":zlib_adler32_simd" ]
Noel Gordon09b784f2017-09-29 19:44:25157 }
robert.bradford02a95e32014-11-05 14:59:34158 }
159
[email protected]bfac2722014-01-17 20:19:45160 configs -= [ "//build/config/compiler:chromium_code" ]
brettw6dd952c72015-09-02 17:57:05161 configs += [
162 "//build/config/compiler:no_chromium_code",
163
164 # Must be after no_chromium_code for warning flags to be ordered correctly.
165 ":zlib_warnings",
166 ]
[email protected]add138e32013-10-04 19:45:41167
Brett Wilsone53895272014-09-23 23:41:46168 public_configs = [ ":zlib_config" ]
Noel Gordon09b784f2017-09-29 19:44:25169
Adenilson Cavalcanti626df312017-10-30 18:39:29170 deps += [ ":zlib_x86_simd" ]
[email protected]c6f27f22013-08-21 21:44:59171}
172
Chris Blume616f37b2017-10-31 23:18:18173fuzzer_test("zlib_uncompress_fuzzer") {
174 sources = [
Chris Blumee08208b2017-11-02 03:16:18175 "contrib/tests/fuzzers/uncompress_fuzzer.cc",
Chris Blume616f37b2017-10-31 23:18:18176 ]
177 deps = [
178 ":zlib",
179 ]
180}
181
Chris Blume1d1fe9212017-11-02 02:12:31182fuzzer_test("zlib_inflate_fuzzer") {
183 sources = [
184 "contrib/tests/fuzzers/inflate_fuzzer.cc",
185 ]
186 deps = [
187 ":zlib",
188 ]
189}
190
Chris Blume425d4cd2017-11-03 21:34:03191fuzzer_test("zlib_deflate_set_dictionary_fuzzer") {
192 sources = [
193 "contrib/tests/fuzzers/deflate_set_dictionary_fuzzer.cc",
194 ]
195 deps = [
196 ":zlib",
197 ]
198}
199
Chris Blume66ca6402017-11-04 11:12:55200fuzzer_test("zlib_deflate_fuzzer") {
201 sources = [
202 "contrib/tests/fuzzers/deflate_fuzzer.cc",
203 ]
204 deps = [
205 ":zlib",
206 ]
207}
208
brettw6dd952c72015-09-02 17:57:05209config("minizip_warnings") {
210 visibility = [ ":*" ]
211 if (is_clang) {
212 # zlib uses `if ((a == b))` for some reason.
213 cflags = [ "-Wno-parentheses-equality" ]
214 }
215}
216
[email protected]c6f27f22013-08-21 21:44:59217static_library("minizip") {
218 sources = [
219 "contrib/minizip/ioapi.c",
220 "contrib/minizip/ioapi.h",
221 "contrib/minizip/iowin32.c",
222 "contrib/minizip/iowin32.h",
223 "contrib/minizip/unzip.c",
224 "contrib/minizip/unzip.h",
225 "contrib/minizip/zip.c",
226 "contrib/minizip/zip.h",
227 ]
228
229 if (!is_win) {
230 sources -= [
231 "contrib/minizip/iowin32.c",
232 "contrib/minizip/iowin32.h",
233 ]
[email protected]ab9ce6e2014-04-17 20:33:19234 }
takise33876392017-04-07 05:48:40235 if (is_mac || is_ios || is_android || is_nacl) {
[email protected]c6f27f22013-08-21 21:44:59236 # Mac, Android and the BSDs don't have fopen64, ftello64, or fseeko64. We
237 # use fopen, ftell, and fseek instead on these systems.
238 defines = [ "USE_FILE32API" ]
239 }
240
scottmg1c240d272014-12-03 07:28:00241 deps = [
242 ":zlib",
243 ]
[email protected]c6f27f22013-08-21 21:44:59244
[email protected]bfac2722014-01-17 20:19:45245 configs -= [ "//build/config/compiler:chromium_code" ]
brettw6dd952c72015-09-02 17:57:05246 configs += [
247 "//build/config/compiler:no_chromium_code",
248
249 # Must be after no_chromium_code for warning flags to be ordered correctly.
250 ":minizip_warnings",
251 ]
Noel Gordon09b784f2017-09-29 19:44:25252
Brett Wilsone53895272014-09-23 23:41:46253 public_configs = [ ":zlib_config" ]
[email protected]c6f27f22013-08-21 21:44:59254}