{% set version = "0.15.0" %}
{% 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: d5883566d161f8f6ddd4e21f3a9e3e6b8272799d054820f1c25b11e86718f86b
    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: 0
  # boost is not available for this version on s390x
  skip: True # [s390x]
  run_exports:
    - {{ pin_subpackage("libthrift", max_pin="x.x") }}
  ignore_run_exports:
    - zlib
    - openssl

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

outputs:
  - name: libthrift
    script: install.sh  # [unix]
    script: install.bat  # [not unix]
    build:
      run_exports:
        - {{ pin_subpackage("libthrift", max_pin="x.x") }}
      ignore_run_exports:
        - zlib
        - openssl
    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
      run:
        - openssl
        - zlib
    test:
      commands:
        - test ! -f $PREFIX/bin/thrift                                      # [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") }}
      ignore_run_exports:
        - zlib
        - openssl
        - libevent  # [unix]
        - libthrift
    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") }}
    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
