# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

{
'variables': {
    'conditions': [
      # Define an "os_include" variable that points at the OS-specific generated
      # headers.  These were generated by running the configure script offline.
      ['os_posix == 1 and OS != "mac"', {
        'os_include': 'linux'
      }],
      ['OS=="mac"', {'os_include': 'mac'}],
      ['OS=="win"', {'os_include': 'win32'}],
    ],
    'use_system_libxml%': 0,
  },
  'targets': [
    {
      'target_name': 'snappy',
      'type': 'static_library',
      'include_dirs': [
        '<(os_include)',
        'src',
        '../..',
      ],
      'direct_dependent_settings': {
        'include_dirs': [
          '<(os_include)',
          'src',
        ],
      },
      'sources': [
        'src/snappy-internal.h',
        'src/snappy-sinksource.cc',
        'src/snappy-sinksource.h',
        'src/snappy-stubs-internal.cc',
        'src/snappy-stubs-internal.h',
        'src/snappy.cc',
        'src/snappy.h',
      ],
      'conditions': [
        ['clang == 1', {
          # snappy-stubs-internal.h unapologetically has: using namespace std
          # https://code.google.com/p/snappy/issues/detail?id=70
          'xcode_settings': {
            'WARNING_CFLAGS!': [ '-Wheader-hygiene' ],
          },
          'cflags': [ '-Wno-header-hygiene' ],
        }],
        ['OS=="linux"', {
          'defines': [
            # TODO(tfarina): Only Linux has the generated config.h for now.
            # Generate the config.h in the other platforms: mac, win and enable
            # this for everyone.
            'HAVE_CONFIG_H=1',
          ],
        }],
        ['OS=="win"', {
          # Signed/unsigned comparison
          'msvs_disabled_warnings': [
            # https://code.google.com/p/snappy/issues/detail?id=71
            4018,
            # https://code.google.com/p/snappy/issues/detail?id=75
            4267,
          ],
        }],
      ],
    },
    {
      'target_name': 'snappy_unittest',
      'type': 'executable',
      'defines': [
        'HAVE_CONFIG_H=1',
      ],
      'sources': [
        'src/snappy-test.cc',
        'src/snappy-test.h',
        'src/snappy_unittest.cc',
      ],
      'dependencies': [
        'snappy',
        '../../base/base.gyp:base',
        '../../testing/gtest.gyp:gtest',
        '../../third_party/zlib/zlib.gyp:zlib',
      ],
      'conditions': [
        ['clang == 1', {
          'cflags': [
            '-Wno-return-type',
            '-Wno-header-hygiene'
          ],
        }],
      ],
    },
  ],
}