blob: 789ad62ea20bc291513c34905f4d8e055ee80634 [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
Adenilson Cavalcanti78104f42017-09-29 03:24:525if (current_cpu == "arm" || current_cpu == "arm64") {
6 import("//build/config/arm.gni")
7}
8
[email protected]c6f27f22013-08-21 21:44:599config("zlib_config") {
[email protected]2ed04ae2013-10-07 20:17:1610 include_dirs = [ "." ]
[email protected]c6f27f22013-08-21 21:44:5911}
12
Noel Gordon09b784f2017-09-29 19:44:2513config("zlib_adler32_simd_config") {
14 if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
15 defines = [ "ADLER32_SIMD_SSSE3" ]
16 }
17
18 if (current_cpu == "arm" || current_cpu == "arm64") {
19 if (arm_use_neon) {
20 defines = [ "ADLER32_SIMD_NEON" ]
21 }
22 }
23}
24
25source_set("zlib_adler32_simd") {
26 visibility = [ ":*" ]
27
28 if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
29 sources = [
30 "adler32_simd.c",
31 "adler32_simd.h",
32 ]
33
34 if (!is_win || is_clang) {
35 cflags = [ "-mssse3" ]
36 }
37 }
38
39 if (current_cpu == "arm" || current_cpu == "arm64") {
40 if (arm_use_neon) {
41 sources = [
42 "adler32_simd.c",
43 "adler32_simd.h",
44 ]
45
46 if (!is_debug) {
47 # Use optimize_speed (-O3) to output the _smallest_ code.
48 configs -= [ "//build/config/compiler:default_optimization" ]
49 configs += [ "//build/config/compiler:optimize_speed" ]
50 }
51 }
52 }
53
Noel Gordon09b784f2017-09-29 19:44:2554 public_configs = [ ":zlib_adler32_simd_config" ]
55}
56
Adenilson Cavalcanti28c96232018-02-16 03:41:1457config("zlib_arm_crc32_config") {
58 if (current_cpu == "arm" || current_cpu == "arm64") {
59 # Restrictions:
60 # - Disabled for iPhones, as described in DDI0487C_a_armv8_arm:
61 # "All implementations of the ARMv8.1 architecture are required to
62 # implement the CRC32* instructions. These are optional in ARMv8.0."
63 # - ChromeOS has wrapper scripts that are borking the compiler flags.
64 # - Fuchsia just added a syscall for feature detection.
65 # TODO(cavalcantii): crbug.com/810125.
66 if (!is_ios && !is_chromeos && !is_fuchsia) {
67 defines = [ "CRC32_ARMV8_CRC32" ]
68 if (is_android) {
69 defines += [ "ARMV8_OS_ANDROID" ]
70 } else if (is_linux || is_chromeos) {
71 defines += [ "ARMV8_OS_LINUX" ]
72 }
73 }
74 }
75}
76
77if (current_cpu == "arm" || current_cpu == "arm64") {
78 source_set("zlib_arm_crc32") {
79 visibility = [ ":*" ]
80
81 if (!is_ios && !is_chromeos && !is_fuchsia) {
82 include_dirs = [ "." ]
83
84 if (is_android) {
85 import("//build/config/android/config.gni")
86 if (defined(android_ndk_root) && android_ndk_root != "") {
87 deps = [
88 "//third_party/android_tools:cpu_features",
89 ]
90 }
91 }
92
93 sources = [
94 "arm_features.c",
95 "arm_features.h",
96 "crc32_simd.c",
97 "crc32_simd.h",
98 ]
99
100 if (!is_win || is_clang) {
101 cflags_c = [ "-march=armv8-a+crc" ]
102 }
103
104 if (!is_debug) {
105 configs -= [ "//build/config/compiler:default_optimization" ]
106 configs += [ "//build/config/compiler:optimize_speed" ]
107 }
108 }
109
110 public_configs = [ ":zlib_arm_crc32_config" ]
111 }
112}
113
Noel Gordonc293a3252017-12-08 11:39:34114config("zlib_inflate_chunk_simd_config") {
115 if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
Noel Gordonb7fef392018-02-12 01:46:01116 defines = [ "INFLATE_CHUNK_SIMD_SSE2" ]
117
118 if (current_cpu == "x64") {
119 defines += [ "INFLATE_CHUNK_READ_64LE" ]
120 }
Noel Gordonc293a3252017-12-08 11:39:34121 }
122
123 if (current_cpu == "arm" || current_cpu == "arm64") {
124 if (arm_use_neon) {
125 defines = [ "INFLATE_CHUNK_SIMD_NEON" ]
126 }
127 }
128}
129
130source_set("zlib_inflate_chunk_simd") {
131 visibility = [ ":*" ]
132
133 if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
134 include_dirs = [ "." ]
135
136 sources = [
137 "contrib/optimizations/chunkcopy.h",
138 "contrib/optimizations/inffast_chunk.c",
139 "contrib/optimizations/inffast_chunk.h",
140 "contrib/optimizations/inflate.c",
141 ]
142 }
143
144 if (current_cpu == "arm" || current_cpu == "arm64") {
145 if (arm_use_neon) {
146 include_dirs = [ "." ]
147
148 sources = [
149 "contrib/optimizations/chunkcopy.h",
150 "contrib/optimizations/inffast_chunk.c",
151 "contrib/optimizations/inffast_chunk.h",
152 "contrib/optimizations/inflate.c",
153 ]
154
Noel Gordon53edf03e2017-12-13 03:51:05155 # TODO(772870) back off from -O3 while investigating Android
156 # One perf bot PNG decode regression.
157 # if (!is_debug) {
158 # # Use optimize_speed (-O3) to output the _smallest_ code.
159 # configs -= [ "//build/config/compiler:default_optimization" ]
160 # configs += [ "//build/config/compiler:optimize_speed" ]
161 # }
Noel Gordonc293a3252017-12-08 11:39:34162 }
163 }
164
165 configs -= [ "//build/config/compiler:chromium_code" ]
166 configs += [ "//build/config/compiler:no_chromium_code" ]
167
168 public_configs = [ ":zlib_inflate_chunk_simd_config" ]
169}
170
Noel Gordon65e2abc2018-01-04 01:10:08171config("zlib_crc32_simd_config") {
172 if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
173 defines = [ "CRC32_SIMD_SSE42_PCLMUL" ]
174 }
175}
176
177source_set("zlib_crc32_simd") {
178 visibility = [ ":*" ]
179
180 if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
181 sources = [
182 "crc32_simd.c",
183 "crc32_simd.h",
184 ]
185
186 if (!is_win || is_clang) {
187 cflags = [
188 "-msse4.2",
189 "-mpclmul",
190 ]
191 }
192 }
193
194 public_configs = [ ":zlib_crc32_simd_config" ]
195}
196
robert.bradford02a95e32014-11-05 14:59:34197static_library("zlib_x86_simd") {
Noel Gordon65e2abc2018-01-04 01:10:08198 visibility = [ ":*" ]
199
dpranke43276212015-02-20 02:55:19200 if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
scottmg1c240d272014-12-03 07:28:00201 sources = [
202 "crc_folding.c",
203 "fill_window_sse.c",
204 ]
Noel Gordon65e2abc2018-01-04 01:10:08205
Nico Weberf3b5bb22014-11-18 23:21:17206 if (!is_win || is_clang) {
scottmg1c240d272014-12-03 07:28:00207 cflags = [
208 "-msse4.2",
209 "-mpclmul",
210 ]
Nico Weberf3b5bb22014-11-18 23:21:17211 }
robert.bradford02a95e32014-11-05 14:59:34212 } else {
scottmg1c240d272014-12-03 07:28:00213 sources = [
214 "simd_stub.c",
215 ]
robert.bradford02a95e32014-11-05 14:59:34216 }
dprankede7d0dc2014-11-18 01:54:55217
218 configs -= [ "//build/config/compiler:chromium_code" ]
219 configs += [ "//build/config/compiler:no_chromium_code" ]
robert.bradford02a95e32014-11-05 14:59:34220}
221
brettw6dd952c72015-09-02 17:57:05222config("zlib_warnings") {
tfarinaf7698e02015-11-03 00:49:39223 if (is_clang && !is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
brettw6dd952c72015-09-02 17:57:05224 cflags = [ "-Wno-incompatible-pointer-types" ]
225 }
226}
227
[email protected]6a0f2772013-10-03 17:16:11228static_library("zlib") {
[email protected]6a0f2772013-10-03 17:16:11229 if (!is_win) {
230 # Don't stomp on "libzlib" on other platforms.
231 output_name = "chrome_zlib"
232 }
233
[email protected]c6f27f22013-08-21 21:44:59234 sources = [
235 "adler32.c",
236 "compress.c",
237 "crc32.c",
238 "crc32.h",
239 "deflate.c",
240 "deflate.h",
241 "gzclose.c",
242 "gzguts.h",
243 "gzlib.c",
244 "gzread.c",
245 "gzwrite.c",
246 "infback.c",
247 "inffast.c",
248 "inffast.h",
249 "inffixed.h",
250 "inflate.c",
251 "inflate.h",
252 "inftrees.c",
253 "inftrees.h",
mark6d9a6252017-02-15 06:15:29254 "names.h",
[email protected]c6f27f22013-08-21 21:44:59255 "trees.c",
256 "trees.h",
257 "uncompr.c",
robert.bradford02a95e32014-11-05 14:59:34258 "x86.h",
[email protected]c6f27f22013-08-21 21:44:59259 "zconf.h",
260 "zlib.h",
261 "zutil.c",
262 "zutil.h",
263 ]
264
Boris Sazonove7d9a4642017-11-30 10:01:30265 defines = []
266 deps = []
267
dpranke43276212015-02-20 02:55:19268 if (!is_ios && (current_cpu == "x86" || current_cpu == "x64")) {
Noel Gordon65e2abc2018-01-04 01:10:08269 deps += [ ":zlib_crc32_simd" ]
270
Noel Gordonc293a3252017-12-08 11:39:34271 deps += [ ":zlib_adler32_simd" ]
robert.bradford02a95e32014-11-05 14:59:34272 sources += [ "x86.c" ]
Noel Gordon09b784f2017-09-29 19:44:25273
Noel Gordonc293a3252017-12-08 11:39:34274 deps += [ ":zlib_inflate_chunk_simd" ]
275 sources -= [ "inflate.c" ]
Noel Gordon09b784f2017-09-29 19:44:25276 }
277
278 if (current_cpu == "arm" || current_cpu == "arm64") {
279 if (arm_use_neon) {
280 deps += [ ":zlib_adler32_simd" ]
Noel Gordonc293a3252017-12-08 11:39:34281
Adenilson Cavalcanti28c96232018-02-16 03:41:14282 deps += [ ":zlib_arm_crc32" ]
283
Noel Gordonc293a3252017-12-08 11:39:34284 deps += [ ":zlib_inflate_chunk_simd" ]
285 sources -= [ "inflate.c" ]
Noel Gordon09b784f2017-09-29 19:44:25286 }
robert.bradford02a95e32014-11-05 14:59:34287 }
288
[email protected]bfac2722014-01-17 20:19:45289 configs -= [ "//build/config/compiler:chromium_code" ]
brettw6dd952c72015-09-02 17:57:05290 configs += [
291 "//build/config/compiler:no_chromium_code",
292
293 # Must be after no_chromium_code for warning flags to be ordered correctly.
294 ":zlib_warnings",
295 ]
[email protected]add138e32013-10-04 19:45:41296
Brett Wilsone53895272014-09-23 23:41:46297 public_configs = [ ":zlib_config" ]
Noel Gordon09b784f2017-09-29 19:44:25298
Adenilson Cavalcanti626df312017-10-30 18:39:29299 deps += [ ":zlib_x86_simd" ]
[email protected]c6f27f22013-08-21 21:44:59300}
301
brettw6dd952c72015-09-02 17:57:05302config("minizip_warnings") {
303 visibility = [ ":*" ]
Noel Gordon94793842018-02-12 08:15:47304
brettw6dd952c72015-09-02 17:57:05305 if (is_clang) {
306 # zlib uses `if ((a == b))` for some reason.
307 cflags = [ "-Wno-parentheses-equality" ]
308 }
309}
310
[email protected]c6f27f22013-08-21 21:44:59311static_library("minizip") {
312 sources = [
313 "contrib/minizip/ioapi.c",
314 "contrib/minizip/ioapi.h",
315 "contrib/minizip/iowin32.c",
316 "contrib/minizip/iowin32.h",
317 "contrib/minizip/unzip.c",
318 "contrib/minizip/unzip.h",
319 "contrib/minizip/zip.c",
320 "contrib/minizip/zip.h",
321 ]
322
323 if (!is_win) {
324 sources -= [
325 "contrib/minizip/iowin32.c",
326 "contrib/minizip/iowin32.h",
327 ]
[email protected]ab9ce6e2014-04-17 20:33:19328 }
Noel Gordon94793842018-02-12 08:15:47329
takise33876392017-04-07 05:48:40330 if (is_mac || is_ios || is_android || is_nacl) {
[email protected]c6f27f22013-08-21 21:44:59331 # Mac, Android and the BSDs don't have fopen64, ftello64, or fseeko64. We
332 # use fopen, ftell, and fseek instead on these systems.
333 defines = [ "USE_FILE32API" ]
334 }
335
scottmg1c240d272014-12-03 07:28:00336 deps = [
337 ":zlib",
338 ]
[email protected]c6f27f22013-08-21 21:44:59339
[email protected]bfac2722014-01-17 20:19:45340 configs -= [ "//build/config/compiler:chromium_code" ]
brettw6dd952c72015-09-02 17:57:05341 configs += [
342 "//build/config/compiler:no_chromium_code",
343
344 # Must be after no_chromium_code for warning flags to be ordered correctly.
345 ":minizip_warnings",
346 ]
Noel Gordon09b784f2017-09-29 19:44:25347
Brett Wilsone53895272014-09-23 23:41:46348 public_configs = [ ":zlib_config" ]
[email protected]c6f27f22013-08-21 21:44:59349}
Noel Gordon875ad5e32018-01-21 11:19:12350
351executable("zlib_bench") {
352 include_dirs = [ "." ]
353
354 sources = [
355 "contrib/bench/zlib_bench.cc",
356 ]
357
358 if (!is_debug) {
359 configs -= [ "//build/config/compiler:default_optimization" ]
360 configs += [ "//build/config/compiler:optimize_speed" ]
361 }
362
363 configs -= [ "//build/config/compiler:chromium_code" ]
364 configs += [ "//build/config/compiler:no_chromium_code" ]
365
366 deps = [
Noel Gordonb7fef392018-02-12 01:46:01367 ":zlib",
Noel Gordon94793842018-02-12 08:15:47368 "//build/config:exe_and_shlib_deps",
Noel Gordon875ad5e32018-01-21 11:19:12369 ]
370}