|
4 | 4 |
|
5 | 5 | { |
6 | 6 | 'variables': { |
| 7 | + 'ZLIB_ROOT': '.', |
7 | 8 | 'use_system_zlib%': 0, |
8 | 9 | 'arm_fpu%': '', |
9 | 10 | 'llvm_version%': '0.0', |
|
12 | 13 | ['use_system_zlib==0', { |
13 | 14 | 'targets': [ |
14 | 15 | { |
15 | | - 'target_name': 'zlib', |
| 16 | + 'target_name': 'zlib_adler32_simd', |
| 17 | + 'type': 'static_library', |
| 18 | + 'conditions': [ |
| 19 | + ['target_arch in "ia32 x64" and OS!="ios"', { |
| 20 | + 'defines': [ 'ADLER32_SIMD_SSSE3' ], |
| 21 | + 'conditions': [ |
| 22 | + ['OS=="win"', { |
| 23 | + 'defines': [ 'X86_WINDOWS' ], |
| 24 | + },{ |
| 25 | + 'defines': [ 'X86_NOT_WINDOWS' ], |
| 26 | + }], |
| 27 | + ['OS!="win" or llvm_version!="0.0"', { |
| 28 | + 'cflags': [ '-mssse3' ], |
| 29 | + 'xcode_settings': { |
| 30 | + 'OTHER_CFLAGS': [ '-mssse3' ], |
| 31 | + }, |
| 32 | + }], |
| 33 | + ], |
| 34 | + }], |
| 35 | + ['arm_fpu=="neon"', { |
| 36 | + 'defines': [ 'ADLER32_SIMD_NEON' ], |
| 37 | + }], |
| 38 | + ], |
| 39 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 40 | + 'direct_dependent_settings': { |
| 41 | + 'conditions': [ |
| 42 | + ['target_arch in "ia32 x64" and OS!="ios"', { |
| 43 | + 'defines': [ 'ADLER32_SIMD_SSSE3' ], |
| 44 | + 'conditions': [ |
| 45 | + ['OS=="win"', { |
| 46 | + 'defines': [ 'X86_WINDOWS' ], |
| 47 | + },{ |
| 48 | + 'defines': [ 'X86_NOT_WINDOWS' ], |
| 49 | + }], |
| 50 | + ], |
| 51 | + }], |
| 52 | + ['arm_fpu=="neon"', { |
| 53 | + 'defines': [ 'ADLER32_SIMD_NEON' ], |
| 54 | + }], |
| 55 | + ], |
| 56 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 57 | + }, |
| 58 | + 'sources': [ |
| 59 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_adler32_simd\\".*?sources = ")', |
| 60 | + ], |
| 61 | + }, # zlib_adler32_simd |
| 62 | + { |
| 63 | + 'target_name': 'zlib_arm_crc32', |
16 | 64 | 'type': 'static_library', |
| 65 | + 'conditions': [ |
| 66 | + ['OS!="ios"', { |
| 67 | + 'conditions': [ |
| 68 | + ['OS!="win" and llvm_version=="0.0"', { |
| 69 | + 'cflags': [ '-march=armv8-a+aes+crc' ], |
| 70 | + }], |
| 71 | + ['OS=="android"', { |
| 72 | + 'defines': [ 'ARMV8_OS_ANDROID' ], |
| 73 | + }], |
| 74 | + ['OS=="linux"', { |
| 75 | + 'defines': [ 'ARMV8_OS_LINUX' ], |
| 76 | + }], |
| 77 | + ['OS=="mac"', { |
| 78 | + 'defines': [ 'ARMV8_OS_MACOS' ], |
| 79 | + }], |
| 80 | + ['OS=="win"', { |
| 81 | + 'defines': [ 'ARMV8_OS_WINDOWS' ], |
| 82 | + }], |
| 83 | + ], |
| 84 | + 'defines': [ 'CRC32_ARMV8_CRC32' ], |
| 85 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 86 | + 'direct_dependent_settings': { |
| 87 | + 'defines': [ 'CRC32_ARMV8_CRC32' ], |
| 88 | + 'conditions': [ |
| 89 | + ['OS=="android"', { |
| 90 | + 'defines': [ 'ARMV8_OS_ANDROID' ], |
| 91 | + }], |
| 92 | + ['OS=="linux"', { |
| 93 | + 'defines': [ 'ARMV8_OS_LINUX' ], |
| 94 | + }], |
| 95 | + ['OS=="mac"', { |
| 96 | + 'defines': [ 'ARMV8_OS_MACOS' ], |
| 97 | + }], |
| 98 | + ['OS=="win"', { |
| 99 | + 'defines': [ 'ARMV8_OS_WINDOWS' ], |
| 100 | + }], |
| 101 | + ], |
| 102 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 103 | + }, |
| 104 | + 'sources': [ |
| 105 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_arm_crc32\\".*?sources = ")', |
| 106 | + ], |
| 107 | + }], |
| 108 | + ], |
| 109 | + }, # zlib_arm_crc32 |
| 110 | + { |
| 111 | + 'target_name': 'zlib_crc32_simd', |
| 112 | + 'type': 'static_library', |
| 113 | + 'conditions': [ |
| 114 | + ['OS!="win" or llvm_version!="0.0"', { |
| 115 | + 'cflags': [ |
| 116 | + '-msse4.2', |
| 117 | + '-mpclmul', |
| 118 | + ], |
| 119 | + 'xcode_settings': { |
| 120 | + 'OTHER_CFLAGS': [ |
| 121 | + '-msse4.2', |
| 122 | + '-mpclmul', |
| 123 | + ], |
| 124 | + }, |
| 125 | + }] |
| 126 | + ], |
| 127 | + 'defines': [ 'CRC32_SIMD_SSE42_PCLMUL' ], |
| 128 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 129 | + 'direct_dependent_settings': { |
| 130 | + 'defines': [ 'CRC32_SIMD_SSE42_PCLMUL' ], |
| 131 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 132 | + }, |
17 | 133 | 'sources': [ |
18 | | - 'adler32.c', |
19 | | - 'compress.c', |
20 | | - 'contrib/optimizations/insert_string.h', |
21 | | - 'cpu_features.c', |
22 | | - 'cpu_features.h', |
23 | | - 'crc32.c', |
24 | | - 'crc32.h', |
25 | | - 'deflate.c', |
26 | | - 'deflate.h', |
27 | | - 'gzclose.c', |
28 | | - 'gzguts.h', |
29 | | - 'gzlib.c', |
30 | | - 'gzread.c', |
31 | | - 'gzwrite.c', |
32 | | - 'infback.c', |
33 | | - 'inffast.c', |
34 | | - 'inffast.h', |
35 | | - 'inffixed.h', |
36 | | - 'inflate.h', |
37 | | - 'inftrees.c', |
38 | | - 'inftrees.h', |
39 | | - 'trees.c', |
40 | | - 'trees.h', |
41 | | - 'uncompr.c', |
42 | | - 'zconf.h', |
43 | | - 'zlib.h', |
44 | | - 'zutil.c', |
45 | | - 'zutil.h', |
| 134 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_crc32_simd\\".*?sources = ")', |
46 | 135 | ], |
47 | | - 'include_dirs': [ |
48 | | - '.', |
| 136 | + }, # zlib_crc32_simd |
| 137 | + { |
| 138 | + 'target_name': 'zlib_inflate_chunk_simd', |
| 139 | + 'type': 'static_library', |
| 140 | + 'conditions': [ |
| 141 | + ['target_arch in "ia32 x64" and OS!="ios"', { |
| 142 | + 'defines': [ 'INFLATE_CHUNK_SIMD_SSE2' ], |
| 143 | + 'conditions': [ |
| 144 | + ['target_arch=="x64"', { |
| 145 | + 'defines': [ 'INFLATE_CHUNK_READ_64LE' ], |
| 146 | + }], |
| 147 | + ], |
| 148 | + }], |
| 149 | + ['arm_fpu=="neon"', { |
| 150 | + 'defines': [ 'INFLATE_CHUNK_SIMD_NEON' ], |
| 151 | + 'conditions': [ |
| 152 | + ['target_arch=="arm64"', { |
| 153 | + 'defines': [ 'INFLATE_CHUNK_READ_64LE' ], |
| 154 | + }], |
| 155 | + ], |
| 156 | + }], |
49 | 157 | ], |
| 158 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
50 | 159 | 'direct_dependent_settings': { |
51 | | - 'include_dirs': [ |
52 | | - '.', |
| 160 | + 'conditions': [ |
| 161 | + ['target_arch in "ia32 x64" and OS!="ios"', { |
| 162 | + 'defines': [ 'INFLATE_CHUNK_SIMD_SSE2' ], |
| 163 | + }], |
| 164 | + ['arm_fpu=="neon"', { |
| 165 | + 'defines': [ 'INFLATE_CHUNK_SIMD_NEON' ], |
| 166 | + }], |
53 | 167 | ], |
| 168 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 169 | + }, |
| 170 | + 'sources': [ |
| 171 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_inflate_chunk_simd\\".*?sources = ")', |
| 172 | + ], |
| 173 | + }, # zlib_inflate_chunk_simd |
| 174 | + { |
| 175 | + 'target_name': 'zlib', |
| 176 | + 'type': 'static_library', |
| 177 | + 'sources': [ |
| 178 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib\\".*?sources = ")', |
| 179 | + ], |
| 180 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 181 | + 'direct_dependent_settings': { |
| 182 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
54 | 183 | }, |
55 | 184 | 'conditions': [ |
56 | 185 | ['OS!="win"', { |
57 | 186 | 'cflags!': [ '-ansi' ], |
58 | 187 | 'cflags': [ '-Wno-implicit-fallthrough' ], |
59 | 188 | 'defines': [ 'HAVE_HIDDEN' ], |
60 | 189 | }], |
61 | | - ['OS=="mac" or OS=="freebsd" or OS=="android"', { |
| 190 | + ['OS=="mac" or OS=="ios" or OS=="freebsd" or OS=="android"', { |
62 | 191 | # Mac, Android and the BSDs don't have fopen64, ftello64, or |
63 | 192 | # fseeko64. We use fopen, ftell, and fseek instead on these |
64 | 193 | # systems. |
65 | 194 | 'defines': [ |
66 | 195 | 'USE_FILE32API' |
67 | 196 | ], |
68 | 197 | }], |
| 198 | + # Incorporate optimizations where possible. |
69 | 199 | ['(target_arch in "ia32 x64" and OS!="ios") or arm_fpu=="neon"', { |
70 | | - 'sources': [ |
71 | | - 'contrib/optimizations/chunkcopy.h', |
72 | | - 'contrib/optimizations/inffast_chunk.c', |
73 | | - 'contrib/optimizations/inffast_chunk.h', |
74 | | - 'contrib/optimizations/inflate.c', |
75 | | - 'slide_hash_simd.h' |
76 | | - ], |
| 200 | + 'dependencies': [ 'zlib_inflate_chunk_simd' ], |
| 201 | + 'sources': [ '<(ZLIB_ROOT)/slide_hash_simd.h' ] |
77 | 202 | }, { |
78 | | - 'sources': [ 'inflate.c', ], |
| 203 | + 'defines': [ 'CPU_NO_SIMD' ], |
| 204 | + 'sources': [ '<(ZLIB_ROOT)/inflate.c' ], |
79 | 205 | }], |
80 | | - # Incorporate optimizations where possible |
81 | 206 | ['target_arch in "ia32 x64" and OS!="ios"', { |
82 | | - 'defines': [ |
83 | | - 'ADLER32_SIMD_SSSE3', |
84 | | - 'INFLATE_CHUNK_SIMD_SSE2', |
85 | | - 'CRC32_SIMD_SSE42_PCLMUL', |
86 | | - 'DEFLATE_SLIDE_HASH_SSE2' |
87 | | - ], |
88 | | - 'sources': [ |
89 | | - 'adler32_simd.c', |
90 | | - 'adler32_simd.h', |
91 | | - 'crc32_simd.c', |
92 | | - 'crc32_simd.h', |
93 | | - 'crc_folding.c' |
| 207 | + 'dependencies': [ |
| 208 | + 'zlib_adler32_simd', |
| 209 | + 'zlib_crc32_simd', |
94 | 210 | ], |
| 211 | + 'defines': [ 'DEFLATE_SLIDE_HASH_SSE2' ], |
95 | 212 | 'conditions': [ |
96 | 213 | ['target_arch=="x64"', { |
97 | 214 | 'defines': [ 'INFLATE_CHUNK_READ_64LE' ], |
98 | 215 | }], |
99 | | - ['OS=="win"', { |
100 | | - 'defines': [ 'X86_WINDOWS' ] |
101 | | - }, { |
102 | | - 'defines': [ 'X86_NOT_WINDOWS' ] |
103 | | - }] |
104 | 216 | ], |
105 | 217 | }], |
106 | 218 | ['arm_fpu=="neon"', { |
107 | | - 'defines': [ '__ARM_NEON__' ], |
| 219 | + 'defines': [ |
| 220 | + '__ARM_NEON__', |
| 221 | + 'DEFLATE_SLIDE_HASH_NEON', |
| 222 | + ], |
108 | 223 | 'conditions': [ |
109 | 224 | ['OS=="win"', { |
110 | | - 'defines': [ |
111 | | - 'ARMV8_OS_WINDOWS', |
112 | | - 'DEFLATE_SLIDE_HASH_NEON', |
113 | | - 'INFLATE_CHUNK_SIMD_NEON' |
114 | | - ] |
| 225 | + 'defines': [ 'ARMV8_OS_WINDOWS' ], |
115 | 226 | }, { |
116 | 227 | 'conditions': [ |
117 | 228 | ['OS!="ios"', { |
118 | | - 'defines': [ |
119 | | - 'ADLER32_SIMD_NEON', |
120 | | - 'CRC32_ARMV8_CRC32', |
121 | | - 'DEFLATE_SLIDE_HASH_NEON', |
122 | | - 'INFLATE_CHUNK_SIMD_NEON' |
123 | | - ], |
124 | | - 'sources': [ |
125 | | - 'adler32_simd.c', |
126 | | - 'adler32_simd.h', |
127 | | - 'crc32_simd.c', |
128 | | - 'crc32_simd.h', |
129 | | - ], |
130 | | - 'conditions': [ |
131 | | - ['OS=="android"', { |
132 | | - 'defines': [ 'ARMV8_OS_ANDROID' ], |
133 | | - }], |
134 | | - ['OS=="linux"', { |
135 | | - 'defines': [ 'ARMV8_OS_LINUX' ], |
136 | | - }], |
137 | | - ['OS=="mac"', { |
138 | | - 'defines': [ 'ARMV8_OS_MACOS' ], |
139 | | - }], |
140 | | - ['llvm_version=="0.0"', { |
141 | | - 'cflags': [ |
142 | | - '-march=armv8-a+aes+crc', |
143 | | - ], |
144 | | - }], |
| 229 | + 'dependencies': [ |
| 230 | + 'zlib_adler32_simd', |
| 231 | + 'zlib_arm_crc32', |
145 | 232 | ], |
146 | | - }] |
147 | | - ] |
| 233 | + }], |
| 234 | + ], |
148 | 235 | }], |
149 | 236 | ['target_arch=="arm64"', { |
150 | 237 | 'defines': [ 'INFLATE_CHUNK_READ_64LE' ], |
|
0 commit comments