|
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', |
16 | 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 | + 'defines': [ 'ZLIB_IMPLEMENTATION' ], |
| 41 | + 'direct_dependent_settings': { |
| 42 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 43 | + }, |
17 | 44 | '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', |
| 45 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_adler32_simd\\".*?sources = ")', |
| 46 | + ], |
| 47 | + }, # zlib_adler32_simd |
| 48 | + { |
| 49 | + 'target_name': 'zlib_arm_crc32', |
| 50 | + 'type': 'static_library', |
| 51 | + 'conditions': [ |
| 52 | + ['OS!="ios"', { |
| 53 | + 'conditions': [ |
| 54 | + ['OS!="win" and llvm_version=="0.0"', { |
| 55 | + 'cflags': [ '-march=armv8-a+aes+crc' ], |
| 56 | + }], |
| 57 | + ['OS=="android"', { |
| 58 | + 'defines': [ 'ARMV8_OS_ANDROID' ], |
| 59 | + }], |
| 60 | + ['OS=="linux"', { |
| 61 | + 'defines': [ 'ARMV8_OS_LINUX' ], |
| 62 | + }], |
| 63 | + ['OS=="mac"', { |
| 64 | + 'defines': [ 'ARMV8_OS_MACOS' ], |
| 65 | + }], |
| 66 | + ['OS=="win"', { |
| 67 | + 'defines': [ 'ARMV8_OS_WINDOWS' ], |
| 68 | + }], |
| 69 | + ], |
| 70 | + 'defines': [ 'CRC32_ARMV8_CRC32' ], |
| 71 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 72 | + 'direct_dependent_settings': { |
| 73 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 74 | + }, |
| 75 | + 'sources': [ |
| 76 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_arm_crc32\\".*?sources = ")', |
| 77 | + ], |
| 78 | + }], |
| 79 | + ], |
| 80 | + 'defines': [ 'ZLIB_IMPLEMENTATION' ], |
| 81 | + }, # zlib_arm_crc32 |
| 82 | + { |
| 83 | + 'target_name': 'zlib_crc32_simd', |
| 84 | + 'type': 'static_library', |
| 85 | + 'conditions': [ |
| 86 | + ['OS!="win" or llvm_version!="0.0"', { |
| 87 | + 'cflags': [ |
| 88 | + '-msse4.2', |
| 89 | + '-mpclmul', |
| 90 | + ], |
| 91 | + 'xcode_settings': { |
| 92 | + 'OTHER_CFLAGS': [ |
| 93 | + '-msse4.2', |
| 94 | + '-mpclmul', |
| 95 | + ], |
| 96 | + }, |
| 97 | + }] |
46 | 98 | ], |
47 | | - 'include_dirs': [ |
48 | | - '.', |
| 99 | + 'defines': [ |
| 100 | + 'CRC32_SIMD_SSE42_PCLMUL', |
| 101 | + 'ZLIB_IMPLEMENTATION', |
49 | 102 | ], |
| 103 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
50 | 104 | 'direct_dependent_settings': { |
51 | | - 'include_dirs': [ |
52 | | - '.', |
53 | | - ], |
| 105 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 106 | + }, |
| 107 | + 'sources': [ |
| 108 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_crc32_simd\\".*?sources = ")', |
| 109 | + ], |
| 110 | + }, # zlib_crc32_simd |
| 111 | + { |
| 112 | + 'target_name': 'zlib_inflate_chunk_simd', |
| 113 | + 'type': 'static_library', |
| 114 | + 'conditions': [ |
| 115 | + ['target_arch in "ia32 x64" and OS!="ios"', { |
| 116 | + 'defines': [ 'INFLATE_CHUNK_SIMD_SSE2' ], |
| 117 | + 'conditions': [ |
| 118 | + ['target_arch=="x64"', { |
| 119 | + 'defines': [ 'INFLATE_CHUNK_READ_64LE' ], |
| 120 | + }], |
| 121 | + ], |
| 122 | + }], |
| 123 | + ['arm_fpu=="neon"', { |
| 124 | + 'defines': [ 'INFLATE_CHUNK_SIMD_NEON' ], |
| 125 | + 'conditions': [ |
| 126 | + ['target_arch=="arm64"', { |
| 127 | + 'defines': [ 'INFLATE_CHUNK_READ_64LE' ], |
| 128 | + }], |
| 129 | + ], |
| 130 | + }] |
| 131 | + ], |
| 132 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 133 | + 'defines': [ 'ZLIB_IMPLEMENTATION' ], |
| 134 | + 'direct_dependent_settings': { |
| 135 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 136 | + }, |
| 137 | + 'sources': [ |
| 138 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_inflate_chunk_simd\\".*?sources = ")', |
| 139 | + ], |
| 140 | + }, # zlib_inflate_chunk_simd |
| 141 | + { |
| 142 | + 'target_name': 'zlib', |
| 143 | + 'type': 'static_library', |
| 144 | + 'sources': [ |
| 145 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib\\".*?sources = ")', |
| 146 | + ], |
| 147 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 148 | + 'direct_dependent_settings': { |
| 149 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
54 | 150 | }, |
55 | 151 | 'conditions': [ |
56 | 152 | ['OS!="win"', { |
57 | 153 | 'cflags!': [ '-ansi' ], |
58 | 154 | 'cflags': [ '-Wno-implicit-fallthrough' ], |
59 | 155 | 'defines': [ 'HAVE_HIDDEN' ], |
60 | 156 | }], |
61 | | - ['OS=="mac" or OS=="freebsd" or OS=="android"', { |
| 157 | + ['OS=="mac" or OS=="ios" or OS=="freebsd" or OS=="android"', { |
62 | 158 | # Mac, Android and the BSDs don't have fopen64, ftello64, or |
63 | 159 | # fseeko64. We use fopen, ftell, and fseek instead on these |
64 | 160 | # systems. |
65 | 161 | 'defines': [ |
66 | 162 | 'USE_FILE32API' |
67 | 163 | ], |
68 | 164 | }], |
| 165 | + # Incorporate optimizations where possible. |
69 | 166 | ['(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 | | - ], |
| 167 | + 'dependencies': [ 'zlib_inflate_chunk_simd' ], |
| 168 | + 'sources': [ '<(ZLIB_ROOT)/slide_hash_simd.h' ] |
77 | 169 | }, { |
78 | | - 'sources': [ 'inflate.c', ], |
| 170 | + 'defines': [ 'CPU_NO_SIMD' ], |
| 171 | + 'sources': [ '<(ZLIB_ROOT)/inflate.c' ], |
79 | 172 | }], |
80 | | - # Incorporate optimizations where possible |
81 | 173 | ['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' |
94 | | - ], |
95 | | - 'conditions': [ |
96 | | - ['target_arch=="x64"', { |
97 | | - 'defines': [ 'INFLATE_CHUNK_READ_64LE' ], |
98 | | - }], |
99 | | - ['OS=="win"', { |
100 | | - 'defines': [ 'X86_WINDOWS' ] |
101 | | - }, { |
102 | | - 'defines': [ 'X86_NOT_WINDOWS' ] |
103 | | - }] |
| 174 | + 'dependencies': [ |
| 175 | + 'zlib_adler32_simd', |
| 176 | + 'zlib_crc32_simd', |
104 | 177 | ], |
| 178 | + 'defines': [ 'DEFLATE_SLIDE_HASH_SSE2' ], |
105 | 179 | }], |
106 | 180 | ['arm_fpu=="neon"', { |
107 | | - 'defines': [ '__ARM_NEON__' ], |
| 181 | + 'defines': [ |
| 182 | + '__ARM_NEON__', |
| 183 | + 'DEFLATE_SLIDE_HASH_NEON', |
| 184 | + ], |
108 | 185 | 'conditions': [ |
109 | | - ['OS=="win"', { |
110 | | - 'defines': [ |
111 | | - 'ARMV8_OS_WINDOWS', |
112 | | - 'DEFLATE_SLIDE_HASH_NEON', |
113 | | - 'INFLATE_CHUNK_SIMD_NEON' |
114 | | - ] |
115 | | - }, { |
116 | | - 'conditions': [ |
117 | | - ['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 | | - }], |
145 | | - ], |
146 | | - }] |
147 | | - ] |
| 186 | + ['OS!="ios" and OS!="win"', { |
| 187 | + 'dependencies': [ |
| 188 | + 'zlib_adler32_simd', |
| 189 | + 'zlib_arm_crc32', |
| 190 | + ], |
148 | 191 | }], |
149 | 192 | ['target_arch=="arm64"', { |
150 | 193 | 'defines': [ 'INFLATE_CHUNK_READ_64LE' ], |
151 | 194 | }], |
152 | 195 | ], |
153 | 196 | }], |
154 | 197 | ], |
| 198 | + 'defines': [ 'ZLIB_IMPLEMENTATION' ], |
155 | 199 | }, |
156 | 200 | ], |
157 | 201 | }, { |
|
0 commit comments