11cb0ef41Sopenharmony_ci# Copyright (c) 2009 The Chromium Authors. All rights reserved.
21cb0ef41Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci# found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci{
61cb0ef41Sopenharmony_ci  'variables': {
71cb0ef41Sopenharmony_ci    'ZLIB_ROOT': '.',
81cb0ef41Sopenharmony_ci    'use_system_zlib%': 0,
91cb0ef41Sopenharmony_ci    'arm_fpu%': '',
101cb0ef41Sopenharmony_ci    'llvm_version%': '0.0',
111cb0ef41Sopenharmony_ci  },
121cb0ef41Sopenharmony_ci  'conditions': [
131cb0ef41Sopenharmony_ci    ['use_system_zlib==0', {
141cb0ef41Sopenharmony_ci      'targets': [
151cb0ef41Sopenharmony_ci        {
161cb0ef41Sopenharmony_ci          'target_name': 'zlib_adler32_simd',
171cb0ef41Sopenharmony_ci          'type': 'static_library',
181cb0ef41Sopenharmony_ci          'conditions': [
191cb0ef41Sopenharmony_ci            ['target_arch in "ia32 x64" and OS!="ios"', {
201cb0ef41Sopenharmony_ci              'defines': [ 'ADLER32_SIMD_SSSE3' ],
211cb0ef41Sopenharmony_ci              'conditions': [
221cb0ef41Sopenharmony_ci                ['OS=="win"', {
231cb0ef41Sopenharmony_ci                  'defines': [ 'X86_WINDOWS' ],
241cb0ef41Sopenharmony_ci                },{
251cb0ef41Sopenharmony_ci                  'defines': [ 'X86_NOT_WINDOWS' ],
261cb0ef41Sopenharmony_ci                }],
271cb0ef41Sopenharmony_ci                ['OS!="win" or llvm_version!="0.0"', {
281cb0ef41Sopenharmony_ci                  'cflags': [ '-mssse3' ],
291cb0ef41Sopenharmony_ci                  'xcode_settings': {
301cb0ef41Sopenharmony_ci                    'OTHER_CFLAGS': [ '-mssse3' ],
311cb0ef41Sopenharmony_ci                  },
321cb0ef41Sopenharmony_ci                }],
331cb0ef41Sopenharmony_ci              ],
341cb0ef41Sopenharmony_ci            }],
351cb0ef41Sopenharmony_ci            ['arm_fpu=="neon"', {
361cb0ef41Sopenharmony_ci              'defines': [ 'ADLER32_SIMD_NEON' ],
371cb0ef41Sopenharmony_ci            }],
381cb0ef41Sopenharmony_ci          ],
391cb0ef41Sopenharmony_ci          'include_dirs': [ '<(ZLIB_ROOT)' ],
401cb0ef41Sopenharmony_ci          'direct_dependent_settings': {
411cb0ef41Sopenharmony_ci            'conditions': [
421cb0ef41Sopenharmony_ci              ['target_arch in "ia32 x64" and OS!="ios"', {
431cb0ef41Sopenharmony_ci                'defines': [ 'ADLER32_SIMD_SSSE3' ],
441cb0ef41Sopenharmony_ci                'conditions': [
451cb0ef41Sopenharmony_ci                  ['OS=="win"', {
461cb0ef41Sopenharmony_ci                    'defines': [ 'X86_WINDOWS' ],
471cb0ef41Sopenharmony_ci                  },{
481cb0ef41Sopenharmony_ci                    'defines': [ 'X86_NOT_WINDOWS' ],
491cb0ef41Sopenharmony_ci                  }],
501cb0ef41Sopenharmony_ci                ],
511cb0ef41Sopenharmony_ci              }],
521cb0ef41Sopenharmony_ci              ['arm_fpu=="neon"', {
531cb0ef41Sopenharmony_ci                'defines': [ 'ADLER32_SIMD_NEON' ],
541cb0ef41Sopenharmony_ci              }],
551cb0ef41Sopenharmony_ci            ],
561cb0ef41Sopenharmony_ci            'include_dirs': [ '<(ZLIB_ROOT)' ],
571cb0ef41Sopenharmony_ci          },
581cb0ef41Sopenharmony_ci          'sources': [
591cb0ef41Sopenharmony_ci            '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_adler32_simd\\".*?sources = ")',
601cb0ef41Sopenharmony_ci          ],
611cb0ef41Sopenharmony_ci        }, # zlib_adler32_simd
621cb0ef41Sopenharmony_ci        {
631cb0ef41Sopenharmony_ci          'target_name': 'zlib_arm_crc32',
641cb0ef41Sopenharmony_ci          'type': 'static_library',
651cb0ef41Sopenharmony_ci          'conditions': [
661cb0ef41Sopenharmony_ci            ['OS!="ios"', {
671cb0ef41Sopenharmony_ci              'conditions': [
681cb0ef41Sopenharmony_ci                ['OS!="win" and llvm_version=="0.0"', {
691cb0ef41Sopenharmony_ci                  'cflags': [ '-march=armv8-a+aes+crc' ],
701cb0ef41Sopenharmony_ci                }],
711cb0ef41Sopenharmony_ci                ['OS=="android"', {
721cb0ef41Sopenharmony_ci                  'defines': [ 'ARMV8_OS_ANDROID' ],
731cb0ef41Sopenharmony_ci                }],
741cb0ef41Sopenharmony_ci                ['OS=="linux"', {
751cb0ef41Sopenharmony_ci                  'defines': [ 'ARMV8_OS_LINUX' ],
761cb0ef41Sopenharmony_ci                }],
771cb0ef41Sopenharmony_ci                ['OS=="mac"', {
781cb0ef41Sopenharmony_ci                  'defines': [ 'ARMV8_OS_MACOS' ],
791cb0ef41Sopenharmony_ci                }],
801cb0ef41Sopenharmony_ci                ['OS=="win"', {
811cb0ef41Sopenharmony_ci                  'defines': [ 'ARMV8_OS_WINDOWS' ],
821cb0ef41Sopenharmony_ci                }],
831cb0ef41Sopenharmony_ci              ],
841cb0ef41Sopenharmony_ci              'defines': [ 'CRC32_ARMV8_CRC32' ],
851cb0ef41Sopenharmony_ci              'include_dirs': [ '<(ZLIB_ROOT)' ],
861cb0ef41Sopenharmony_ci              'direct_dependent_settings': {
871cb0ef41Sopenharmony_ci                'defines': [ 'CRC32_ARMV8_CRC32' ],
881cb0ef41Sopenharmony_ci                'conditions': [
891cb0ef41Sopenharmony_ci                  ['OS=="android"', {
901cb0ef41Sopenharmony_ci                    'defines': [ 'ARMV8_OS_ANDROID' ],
911cb0ef41Sopenharmony_ci                  }],
921cb0ef41Sopenharmony_ci                  ['OS=="linux"', {
931cb0ef41Sopenharmony_ci                    'defines': [ 'ARMV8_OS_LINUX' ],
941cb0ef41Sopenharmony_ci                  }],
951cb0ef41Sopenharmony_ci                  ['OS=="mac"', {
961cb0ef41Sopenharmony_ci                    'defines': [ 'ARMV8_OS_MACOS' ],
971cb0ef41Sopenharmony_ci                  }],
981cb0ef41Sopenharmony_ci                  ['OS=="win"', {
991cb0ef41Sopenharmony_ci                    'defines': [ 'ARMV8_OS_WINDOWS' ],
1001cb0ef41Sopenharmony_ci                  }],
1011cb0ef41Sopenharmony_ci                ],
1021cb0ef41Sopenharmony_ci                'include_dirs': [ '<(ZLIB_ROOT)' ],
1031cb0ef41Sopenharmony_ci              },
1041cb0ef41Sopenharmony_ci              'sources': [
1051cb0ef41Sopenharmony_ci                '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_arm_crc32\\".*?sources = ")',
1061cb0ef41Sopenharmony_ci              ],
1071cb0ef41Sopenharmony_ci            }],
1081cb0ef41Sopenharmony_ci          ],
1091cb0ef41Sopenharmony_ci        }, # zlib_arm_crc32
1101cb0ef41Sopenharmony_ci        {
1111cb0ef41Sopenharmony_ci          'target_name': 'zlib_crc32_simd',
1121cb0ef41Sopenharmony_ci          'type': 'static_library',
1131cb0ef41Sopenharmony_ci          'conditions': [
1141cb0ef41Sopenharmony_ci            ['OS!="win" or llvm_version!="0.0"', {
1151cb0ef41Sopenharmony_ci              'cflags': [
1161cb0ef41Sopenharmony_ci                '-msse4.2',
1171cb0ef41Sopenharmony_ci                '-mpclmul',
1181cb0ef41Sopenharmony_ci              ],
1191cb0ef41Sopenharmony_ci              'xcode_settings': {
1201cb0ef41Sopenharmony_ci                'OTHER_CFLAGS': [
1211cb0ef41Sopenharmony_ci                  '-msse4.2',
1221cb0ef41Sopenharmony_ci                  '-mpclmul',
1231cb0ef41Sopenharmony_ci                ],
1241cb0ef41Sopenharmony_ci              },
1251cb0ef41Sopenharmony_ci            }]
1261cb0ef41Sopenharmony_ci          ],
1271cb0ef41Sopenharmony_ci          'defines': [ 'CRC32_SIMD_SSE42_PCLMUL' ],
1281cb0ef41Sopenharmony_ci          'include_dirs': [ '<(ZLIB_ROOT)' ],
1291cb0ef41Sopenharmony_ci          'direct_dependent_settings': {
1301cb0ef41Sopenharmony_ci            'defines': [ 'CRC32_SIMD_SSE42_PCLMUL' ],
1311cb0ef41Sopenharmony_ci            'include_dirs': [ '<(ZLIB_ROOT)' ],
1321cb0ef41Sopenharmony_ci          },
1331cb0ef41Sopenharmony_ci          'sources': [
1341cb0ef41Sopenharmony_ci            '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_crc32_simd\\".*?sources = ")',
1351cb0ef41Sopenharmony_ci          ],
1361cb0ef41Sopenharmony_ci        }, # zlib_crc32_simd
1371cb0ef41Sopenharmony_ci        {
1381cb0ef41Sopenharmony_ci          'target_name': 'zlib_inflate_chunk_simd',
1391cb0ef41Sopenharmony_ci          'type': 'static_library',
1401cb0ef41Sopenharmony_ci          'conditions': [
1411cb0ef41Sopenharmony_ci            ['target_arch in "ia32 x64" and OS!="ios"', {
1421cb0ef41Sopenharmony_ci              'defines': [ 'INFLATE_CHUNK_SIMD_SSE2' ],
1431cb0ef41Sopenharmony_ci              'conditions': [
1441cb0ef41Sopenharmony_ci                ['target_arch=="x64"', {
1451cb0ef41Sopenharmony_ci                  'defines': [ 'INFLATE_CHUNK_READ_64LE' ],
1461cb0ef41Sopenharmony_ci                }],
1471cb0ef41Sopenharmony_ci              ],
1481cb0ef41Sopenharmony_ci            }],
1491cb0ef41Sopenharmony_ci            ['arm_fpu=="neon"', {
1501cb0ef41Sopenharmony_ci              'defines': [ 'INFLATE_CHUNK_SIMD_NEON' ],
1511cb0ef41Sopenharmony_ci              'conditions': [
1521cb0ef41Sopenharmony_ci                ['target_arch=="arm64"', {
1531cb0ef41Sopenharmony_ci                  'defines': [ 'INFLATE_CHUNK_READ_64LE' ],
1541cb0ef41Sopenharmony_ci                }],
1551cb0ef41Sopenharmony_ci              ],
1561cb0ef41Sopenharmony_ci            }],
1571cb0ef41Sopenharmony_ci          ],
1581cb0ef41Sopenharmony_ci          'include_dirs': [ '<(ZLIB_ROOT)' ],
1591cb0ef41Sopenharmony_ci          'direct_dependent_settings': {
1601cb0ef41Sopenharmony_ci            'conditions': [
1611cb0ef41Sopenharmony_ci              ['target_arch in "ia32 x64" and OS!="ios"', {
1621cb0ef41Sopenharmony_ci                'defines': [ 'INFLATE_CHUNK_SIMD_SSE2' ],
1631cb0ef41Sopenharmony_ci              }],
1641cb0ef41Sopenharmony_ci              ['arm_fpu=="neon"', {
1651cb0ef41Sopenharmony_ci                'defines': [ 'INFLATE_CHUNK_SIMD_NEON' ],
1661cb0ef41Sopenharmony_ci              }],
1671cb0ef41Sopenharmony_ci            ],
1681cb0ef41Sopenharmony_ci            'include_dirs': [ '<(ZLIB_ROOT)' ],
1691cb0ef41Sopenharmony_ci          },
1701cb0ef41Sopenharmony_ci          'sources': [
1711cb0ef41Sopenharmony_ci            '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_inflate_chunk_simd\\".*?sources = ")',
1721cb0ef41Sopenharmony_ci          ],
1731cb0ef41Sopenharmony_ci        }, # zlib_inflate_chunk_simd
1741cb0ef41Sopenharmony_ci        {
1751cb0ef41Sopenharmony_ci          'target_name': 'zlib',
1761cb0ef41Sopenharmony_ci          'type': 'static_library',
1771cb0ef41Sopenharmony_ci          'sources': [
1781cb0ef41Sopenharmony_ci            '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib\\".*?sources = ")',
1791cb0ef41Sopenharmony_ci          ],
1801cb0ef41Sopenharmony_ci          'include_dirs': [ '<(ZLIB_ROOT)' ],
1811cb0ef41Sopenharmony_ci          'direct_dependent_settings': {
1821cb0ef41Sopenharmony_ci            'include_dirs': [ '<(ZLIB_ROOT)' ],
1831cb0ef41Sopenharmony_ci          },
1841cb0ef41Sopenharmony_ci          'conditions': [
1851cb0ef41Sopenharmony_ci            ['OS!="win"', {
1861cb0ef41Sopenharmony_ci              'cflags!': [ '-ansi' ],
1871cb0ef41Sopenharmony_ci              'cflags': [ '-Wno-implicit-fallthrough' ],
1881cb0ef41Sopenharmony_ci              'defines': [ 'HAVE_HIDDEN' ],
1891cb0ef41Sopenharmony_ci            }, {
1901cb0ef41Sopenharmony_ci              'defines': [ 'ZLIB_DLL' ]
1911cb0ef41Sopenharmony_ci            }],
1921cb0ef41Sopenharmony_ci            ['OS=="mac" or OS=="ios" or OS=="freebsd" or OS=="android"', {
1931cb0ef41Sopenharmony_ci              # Mac, Android and the BSDs don't have fopen64, ftello64, or
1941cb0ef41Sopenharmony_ci              # fseeko64. We use fopen, ftell, and fseek instead on these
1951cb0ef41Sopenharmony_ci              # systems.
1961cb0ef41Sopenharmony_ci              'defines': [
1971cb0ef41Sopenharmony_ci                'USE_FILE32API'
1981cb0ef41Sopenharmony_ci              ],
1991cb0ef41Sopenharmony_ci            }],
2001cb0ef41Sopenharmony_ci            # Incorporate optimizations where possible.
2011cb0ef41Sopenharmony_ci            ['(target_arch in "ia32 x64" and OS!="ios") or arm_fpu=="neon"', {
2021cb0ef41Sopenharmony_ci              'dependencies': [ 'zlib_inflate_chunk_simd' ],
2031cb0ef41Sopenharmony_ci              'sources': [ '<(ZLIB_ROOT)/slide_hash_simd.h' ]
2041cb0ef41Sopenharmony_ci            }, {
2051cb0ef41Sopenharmony_ci              'defines': [ 'CPU_NO_SIMD' ],
2061cb0ef41Sopenharmony_ci              'sources': [ '<(ZLIB_ROOT)/inflate.c' ],
2071cb0ef41Sopenharmony_ci            }],
2081cb0ef41Sopenharmony_ci            ['target_arch in "ia32 x64" and OS!="ios"', {
2091cb0ef41Sopenharmony_ci              'dependencies': [
2101cb0ef41Sopenharmony_ci                'zlib_adler32_simd',
2111cb0ef41Sopenharmony_ci                'zlib_crc32_simd',
2121cb0ef41Sopenharmony_ci              ],
2131cb0ef41Sopenharmony_ci              'defines': [ 'DEFLATE_SLIDE_HASH_SSE2' ],
2141cb0ef41Sopenharmony_ci              'conditions': [
2151cb0ef41Sopenharmony_ci                ['target_arch=="x64"', {
2161cb0ef41Sopenharmony_ci                  'defines': [ 'INFLATE_CHUNK_READ_64LE' ],
2171cb0ef41Sopenharmony_ci                }],
2181cb0ef41Sopenharmony_ci              ],
2191cb0ef41Sopenharmony_ci            }],
2201cb0ef41Sopenharmony_ci            ['arm_fpu=="neon"', {
2211cb0ef41Sopenharmony_ci              'defines': [
2221cb0ef41Sopenharmony_ci                '__ARM_NEON__',
2231cb0ef41Sopenharmony_ci                'DEFLATE_SLIDE_HASH_NEON',
2241cb0ef41Sopenharmony_ci              ],
2251cb0ef41Sopenharmony_ci              'conditions': [
2261cb0ef41Sopenharmony_ci                ['OS=="win"', {
2271cb0ef41Sopenharmony_ci                  'defines': [ 'ARMV8_OS_WINDOWS' ],
2281cb0ef41Sopenharmony_ci                }, {
2291cb0ef41Sopenharmony_ci                  'conditions': [
2301cb0ef41Sopenharmony_ci                    ['OS!="ios"', {
2311cb0ef41Sopenharmony_ci                      'dependencies': [
2321cb0ef41Sopenharmony_ci                        'zlib_adler32_simd',
2331cb0ef41Sopenharmony_ci                        'zlib_arm_crc32',
2341cb0ef41Sopenharmony_ci                      ],
2351cb0ef41Sopenharmony_ci                    }],
2361cb0ef41Sopenharmony_ci                  ],
2371cb0ef41Sopenharmony_ci                }],
2381cb0ef41Sopenharmony_ci                ['target_arch=="arm64"', {
2391cb0ef41Sopenharmony_ci                  'defines': [ 'INFLATE_CHUNK_READ_64LE' ],
2401cb0ef41Sopenharmony_ci                }],
2411cb0ef41Sopenharmony_ci              ],
2421cb0ef41Sopenharmony_ci            }],
2431cb0ef41Sopenharmony_ci          ],
2441cb0ef41Sopenharmony_ci        },
2451cb0ef41Sopenharmony_ci      ],
2461cb0ef41Sopenharmony_ci    }, {
2471cb0ef41Sopenharmony_ci      'targets': [
2481cb0ef41Sopenharmony_ci        {
2491cb0ef41Sopenharmony_ci          'target_name': 'zlib',
2501cb0ef41Sopenharmony_ci          'type': 'static_library',
2511cb0ef41Sopenharmony_ci          'direct_dependent_settings': {
2521cb0ef41Sopenharmony_ci            'defines': [
2531cb0ef41Sopenharmony_ci              'USE_SYSTEM_ZLIB',
2541cb0ef41Sopenharmony_ci            ],
2551cb0ef41Sopenharmony_ci          },
2561cb0ef41Sopenharmony_ci          'defines': [
2571cb0ef41Sopenharmony_ci            'USE_SYSTEM_ZLIB',
2581cb0ef41Sopenharmony_ci          ],
2591cb0ef41Sopenharmony_ci          'link_settings': {
2601cb0ef41Sopenharmony_ci            'libraries': [
2611cb0ef41Sopenharmony_ci              '-lz',
2621cb0ef41Sopenharmony_ci            ],
2631cb0ef41Sopenharmony_ci          },
2641cb0ef41Sopenharmony_ci        },
2651cb0ef41Sopenharmony_ci      ],
2661cb0ef41Sopenharmony_ci    }],
2671cb0ef41Sopenharmony_ci  ],
2681cb0ef41Sopenharmony_ci}
269