{% set version = "0.14.2" %}
{% set WIN_FLEX_BIZON_VERSION = "2.5.20" %}
{% set LIBEVENT_VERSION = "2.1.8" %}

package:
  name: thrift-split
  version: {{ version }}

source:
  - url: http://archive.apache.org/dist/thrift/{{ version }}/thrift-{{ version }}.tar.gz
    sha256: 4191bfc0b7490e20cc69f9f4dc6e991fbb612d4551aa9eef1dbf7f4c47ce554d
    patches:
      - thrift-0.13.0-windows-fixes.patch  # [win]
  {% if win %}
  - url: https://github.com/lexxmark/winflexbison/releases/download/v{{ WIN_FLEX_BIZON_VERSION }}/win_flex_bison-{{ WIN_FLEX_BIZON_VERSION }}.zip
    folder: thirdparty\dist\winflexbison
  - url: https://github.com/nmathewson/Libevent/archive/release-{{ LIBEVENT_VERSION }}-stable.zip
    folder: thirdparty\src\libevent
  {% endif %}

build:
  number: 1
  run_exports:
    - {{ pin_subpackage("libthrift", max_pin="x.x.x") }}

requirements:
  build:
    - libtool  # [unix]
    - {{ compiler("c") }}
    - {{ compiler("cxx") }}
    - bison           # [unix]
    - cmake
    - flex            # [unix]
    - libtool         # [unix]
    - m4              # [unix]
    - pkg-config      # [unix]
    - make            # [unix]
    - ninja
    - m2-patch        # [win]
  host:
    - boost-cpp
    - libevent        # [unix]
    - openssl
    - zlib
  run:

outputs:
  - name: libthrift
    script: install.sh  # [unix]
    script: install.bat  # [not unix]
    build:
      run_exports:
        - {{ pin_subpackage("libthrift", max_pin="x.x.x") }}
    requirements:
      build:
        - {{ compiler("c") }}
        - {{ compiler("cxx") }}
        - bison           # [unix]
        - cmake
        - flex            # [unix]
        - libtool         # [unix]
        - m4              # [unix]
        - pkg-config      # [unix]
        - make            # [unix]
        - ninja
        - m2-patch        # [win]
      host:
        - boost-cpp
        - libevent        # [unix]
        - openssl
        - zlib
    test:
      commands:
        - test ! -f $PREFIX/bin/thrift                                      # [unix]
        - test ! -f $PREFIX/lib/libthrift.a                                 # [unix]
        - test -f $PREFIX/lib/libthrift${SHLIB_EXT}                         # [unix]
        - test -f $PREFIX/include/thrift/Thrift.h                           # [unix]
        - if not exist %PREFIX%\\Library\\include\\thrift\\Thrift.h exit 1  # [win]
        - if exist %PREFIX%\\Library\\bin\\thrift.exe exit 1                # [win]
        - if not exist %PREFIX%\\Library\\lib\\thriftmd.lib exit 1          # [win]
  - name: thrift-compiler
    script: install.sh  # [unix]
    script: install.bat  # [not unix]
    build:
      run_exports:
        - {{ pin_subpackage("libthrift", max_pin="x.x.x") }}
    requirements:
      build:
        - {{ compiler("c") }}
        - {{ compiler("cxx") }}
        - bison           # [unix]
        - cmake
        - flex            # [unix]
        - libtool         # [unix]
        - m4              # [unix]
        - pkg-config      # [unix]
        - make            # [unix]
        - ninja
        - m2-patch        # [win]
      host:
        - {{ pin_subpackage("libthrift", exact=true) }}
        - boost-cpp
        - libevent        # [unix]
        - openssl
        - zlib
      run:
        - {{ pin_subpackage("libthrift", exact=true) }}
    test:
      commands:
        - test -f $PREFIX/bin/thrift                              # [unix]
        - if not exist %PREFIX%\\Library\\bin\\thrift.exe exit 1  # [win]
  - name: thrift-cpp
    build:
      run_exports:
        - {{ pin_subpackage("libthrift", max_pin="x.x.x") }}
    requirements:
      host:
        - {{ pin_subpackage("libthrift", exact=true) }}
        - {{ pin_subpackage("thrift-compiler", exact=true) }}
      run:
        - {{ pin_subpackage("libthrift", exact=true) }}
        - {{ pin_subpackage("thrift-compiler", exact=true) }}

about:
  home: http://thrift.apache.org
  license: Apache-2.0
  license_file: LICENSE
  summary: >-
    Compiler and C++ libraries and headers for the Apache Thrift RPC system

extra:
  recipe-maintainers:
    - wesm
    - msarahan
    - jakirkham
    - xhochy
