{% set version = "1.2.1" %}
{% set sha256 = "736aeb64d86566d2236ddffa2865ee5d7a82d26c9016b36218fcc27ea4f09f86" %}

package:
  name: snappy
  version: {{ version }}

source:
  - url: https://github.com/google/snappy/archive/{{ version }}.tar.gz
    sha256: {{ sha256 }}
    patches:
      - patches/fix_win_exports.patch  # [win]  Ensure `snappy_test_support.lib` is built.
      - patches/0001-Omit-Werror-during-compilation.patch
      - patches/0002-Debundle-gtest-and-gmock.patch
      - patches/0004-cmake-add-option-to-enable-disable-RTTI.patch

build:
  number: 0
  run_exports:
    # other than a fluke at 1.1.5 and 1.2.0, it's stable
    #   https://abi-laboratory.pro/tracker/timeline/snappy/
    #   https://github.com/google/snappy/releases
    - {{ pin_subpackage('snappy', max_pin='x') }}
  ignore_run_exports:
    - gtest

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - make  # [unix]
    - cmake
    - git  # [not win]
    - m2-patch  # [win]
    - patch  # [not win]
  host:
    - msinttypes  # [win and vc<14]
    - gtest 1.14 # We run the tests during the build, so we need gtest

test:
  commands:
    - test -e $PREFIX/include/snappy.h               # [unix]
    - test -e $PREFIX/include/snappy-stubs-public.h  # [unix]
    - test -e $PREFIX/lib/libsnappy$SHLIB_EXT        # [unix]
    - test -e $PREFIX/lib/libsnappy.a                # [unix]
    - if not exist %LIBRARY_INC%\snappy.h exit 1               # [win]
    - if not exist %LIBRARY_INC%\snappy-stubs-public.h exit 1  # [win]
    - if not exist %LIBRARY_LIB%\snappy.lib exit 1             # [win]
    - if not exist %LIBRARY_BIN%\snappy.dll exit 1             # [win]
    - if not exist %LIBRARY_LIB%\snappy_static.lib exit 1      # [win]

about:
  home: https://github.com/google/snappy
  license: BSD-3-clause AND CC-BY-3.0 AND MIT AND CC-BY AND Public Domain
  license_file: COPYING
  license_family: BSD
  summary: A fast compressor/decompressor
  description: |
    Snappy is a compression/decompression library. It does not aim for maximum
    compression, or compatibility with any other compression library; instead, it
    aims for very high speeds and reasonable compression. For instance, compared to
    the fastest mode of zlib, Snappy is an order of magnitude faster for most
    inputs, but the resulting compressed files are anywhere from 20% to 100%
    bigger.
  dev_url: https://github.com/google/snappy
  doc_url: https://github.com/google/snappy/tree/master/docs

extra:
  recipe-maintainers:
    - groutr
    - jakirkham
    - wesm
    - xhochy
    - dougalsutherland
    - MaxRis
