{% 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: https://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
    sha256: 8d751f31eb8d79251d809f37bb0d853d72f58a21c5f672d5e31f35b4d97b31fe
    folder: thirdparty\dist\winflexbison
  - url: https://github.com/nmathewson/Libevent/archive/release-{{ LIBEVENT_VERSION }}-stable.zip
    sha256: 70158101eab7ed44fd9cc34e7f247b3cae91a8e4490745d9d6eb7edc184e4d96
    folder: thirdparty\src\libevent
  {% endif %}

build:
  number: 2
  run_exports:
    - {{ pin_subpackage("libthrift", max_pin="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 {{ boost_cpp }}
    - libevent 2.1.12  # [unix]
    - openssl {{ openssl }}
    - zlib {{ zlib }}

outputs:
  - name: libthrift
    script: install.sh  # [unix]
    script: install.bat  # [not unix]
    build:
      run_exports:
        - {{ pin_subpackage("libthrift", max_pin="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 {{ boost_cpp }}
        - libevent 2.1.12  # [unix]
        - openssl {{ openssl }}
        - zlib {{ zlib }}
      run:
        - openssl  # exact pin handled through openssl run_exports
        - zlib
        - libevent
        - boost-cpp >={{ boost_cpp }}
    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") }}
    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 {{ boost_cpp }}
        - libevent 2.1.12  # [unix]
        - openssl {{ openssl }}
        - zlib {{ 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", max_pin="x.x.x") }}
        - {{ pin_subpackage("thrift-compiler", max_pin="x.x.x") }}
      run:
        - {{ pin_subpackage("libthrift", max_pin="x.x.x") }}
        - {{ pin_subpackage("thrift-compiler", max_pin="x.x.x") }}

about:
  home: https://thrift.apache.org
  license: Apache-2.0
  license_family: Apache
  license_file: LICENSE
  summary: >-
    Compiler and C++ libraries and headers for the Apache Thrift RPC system
  description: >-
    Compiler and C++ libraries and headers for the Apache Thrift RPC system
  doc_url: https://thrift.apache.org/docs/
  dev_url: https://github.com/apache/thrift

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