{% set version = "0.11.5" %}
{% set sha_hash = "6d6d57304a56850958e4ce54f3da2ea2b9eb856ccbab61c6cde9cba15d7c9da5" %}
{% set build_number = "1" %}

{% set debug = os.environ.get('PY_INTERP_DEBUG', '') %}
{% if debug != '' %}
  {% set debug = "_dbg" %}
{% endif %}
{% if debug != '' %}
  {% set variant = "cpython_dbg" %}
{% else %}
  {% set variant = "cpython" %}
{% endif %}

package:
  name: lief
  version: {{ version }}

source:
  - url: https://github.com/lief-project/LIEF/archive/{{ version }}.tar.gz
    fn: lief-{{ version }}.tar.gz
    sha256: {{ sha_hash }}
    patches:
      - patches/CMakeLists.txt.patch  # [win]
      - patches/0009-Avoid-deprecated-get_config_var-SO-use-EXT_SUFFIX-lo.patch

build:
  number: {{ build_number }}
  string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ debug }}
  skip: true  # [py<36]

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - pkg-config
    - patch        # [not win]
    - m2-patch     # [win]
    - m2-gcc-libs  # [win]
    - cmake
    - ninja

outputs:
  - name: liblief
    script: build-liblief.sh  # [unix]
    script: bld-liblief.bat   # [win]
    build:
      # string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ debug }}
      run_exports:
        - {{ pin_subpackage('liblief', max_pin='x.x') }}
      missing_dso_whitelist:  # [s390x]
        - $RPATH/ld64.so.1    # [s390x]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - pkg-config
        - cmake
        - ninja
        # - git  # git is necessary for test.
    test:
      files:
        - tests
      script: run_test_liblief.sh
      requires:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - cmake
        - ninja

  - name: py-lief
    script: build-py-lief.sh  # [unix]
    script: bld-py-lief.bat   # [win]
    build:
      # string: py{{ ''.join(python.split('.')[0:2]) }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ debug }}
      run_exports:
        - {{ pin_subpackage('py-lief', max_pin='x.x') }}
      ignore_run_exports:
        - python
      missing_dso_whitelist:  # [s390x]
        - $RPATH/ld64.so.1    # [s390x] Known defect.
    requirements:
      build:
        - ccache
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - pkg-config
        # When making a debug build on Windows, we need to patch CMake downloaded pybind11. Sorry.
        - m2-patch  # [win]
        - m2-gcc-libs  # [win]
        - cmake
        - ninja
      host:
        - {{ pin_subpackage('liblief', exact=True) }}
        # - python {{python}}* *{{variant}}
        - python
        - setuptools >=31.0.0
        - pip
        - wheel
      run:
        - {{ pin_subpackage('liblief', exact=True) }}
        # - python {{python}}* *{{variant}}
        - python
    test:
      requires:
        - {{ compiler('cxx') }}
        - pip
      imports:
        - lief
      commands:
        - pip check

about:
  home: https://lief.quarkslab.com/
  license: Apache-2.0
  license_file: LICENSE
  license_family: Apache
  summary: A cross platform library to parse, modify and abstract ELF, PE and MachO formats.
  description: |
    It turns out that many projects need to parse executable formats and they usually re-implement
    their own parser. Moreover these parsers are usually bound to one language.
    LIEF attempts to fill this void.
  doc_url: https://lief.quarkslab.com/doc/stable/index.html
  doc_source_url: https://github.com/lief-project/LIEF/tree/master/doc
  dev_url: https://github.com/lief-project/LIEF

extra:
  recipe-maintainers:
    - isuruf
    - mingwandroid
    - msarahan
