{% set name = "brotli" %}
{% set version = "1.2.0" %}

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

source:
  url: https://github.com/google/{{ name }}/archive/v{{ version }}.tar.gz
  sha256: 816c96e8e8f193b40151dad7e8ff37b1221d019dbcb9c35cd3fadbfe6477dfec

build:
  number: 0
  run_exports:
    # https://abi-laboratory.pro/index.php?view=timeline&l=brotli
    # No minor versions to ensure ABI compatibility history
    - {{ pin_subpackage('brotli', max_pin='x.x') }}

requirements:
  build:
    - {{ stdlib('c') }}
    - {{ compiler('c') }}
    - cmake
    - ninja-base

outputs:
  - name: libbrotlicommon
    build:
      run_exports:
        - {{ pin_subpackage("libbrotlicommon", max_pin="x.x") }}
    script: install_library.sh  # [unix]
    script: install_library.bat  # [win]
    requirements:
      build:
        - {{ stdlib('c') }}
        - {{ compiler('c') }}
        - cmake
        - ninja-base
    test:
      commands:
        # CFEP-18: Static libs shouldn't be part of the main package
        - test ! -f ${PREFIX}/lib/libbrotlicommon-static.a        # [unix]
        - test -f ${PREFIX}/lib/libbrotlicommon${SHLIB_EXT}       # [unix]
        - if not exist %LIBRARY_BIN%\\brotlicommon.dll exit 1     # [win]
        - if not exist %LIBRARY_LIB%\\brotlicommon.lib exit 1     # [win]
        - if exist %LIBRARY_LIB%\\brotlicommon-static.lib exit 1  # [win]
  - name: libbrotlienc
    build:
      run_exports:
        - {{ pin_subpackage("libbrotlienc", max_pin="x.x") }}
    script: install_library.sh  # [unix]
    script: install_library.bat  # [win]
    requirements:
      build:
        - {{ stdlib('c') }}
        - {{ compiler('c') }}
        - cmake
        - ninja-base
      host:
        - {{ pin_subpackage("libbrotlicommon", exact=True) }}
      run:
        - {{ pin_subpackage("libbrotlicommon", exact=True) }}
    test:
      commands:
        # CFEP-18: Static libs shouldn't be part of the main package
        - test ! -f ${PREFIX}/lib/libbrotlienc-static.a        # [unix]
        - test -f ${PREFIX}/lib/libbrotlienc${SHLIB_EXT}       # [unix]
        - if not exist %LIBRARY_BIN%\\brotlienc.dll exit 1     # [win]
        - if not exist %LIBRARY_LIB%\\brotlienc.lib exit 1     # [win]
        - if exist %LIBRARY_LIB%\\brotlienc-static.lib exit 1  # [win]
  - name: libbrotlidec
    build:
      run_exports:
        - {{ pin_subpackage("libbrotlidec", max_pin="x.x") }}
    script: install_library.sh  # [unix]
    script: install_library.bat  # [win]
    requirements:
      build:
        - {{ stdlib('c') }}
        - {{ compiler('c') }}
        - cmake
        - ninja-base
      host:
        - {{ pin_subpackage("libbrotlicommon", exact=True) }}
      run:
        - {{ pin_subpackage("libbrotlicommon", exact=True) }}
    test:
      commands:
        # CFEP-18: Static libs shouldn't be part of the main package
        - test ! -f $PREFIX/lib/libbrotlidec-static.a          # [unix]
        - test -f $PREFIX/lib/libbrotlidec$SHLIB_EXT           # [unix]
        - if not exist %LIBRARY_BIN%\\brotlidec.dll exit 1     # [win]
        - if not exist %LIBRARY_LIB%\\brotlidec.lib exit 1     # [win]
        - if exist %LIBRARY_LIB%\\brotlidec-static.lib exit 1  # [win]
  - name: brotli-bin
    script: install_library.sh  # [unix]
    script: install_library.bat  # [win]
    requirements:
      build:
        - {{ stdlib('c') }}
        - {{ compiler('c') }}
        - cmake
        - ninja-base
      host:
        - {{ pin_subpackage("libbrotlienc", exact=True) }}
        - {{ pin_subpackage("libbrotlidec", exact=True) }}
      run:
        - {{ pin_subpackage("libbrotlienc", exact=True) }}
        - {{ pin_subpackage("libbrotlidec", exact=True) }}
    test:
      commands:
        - brotli --help
  - name: brotli
    build:
      run_exports:
        - {{ pin_subpackage("libbrotlicommon", max_pin="x.x") }}
        - {{ pin_subpackage("libbrotlienc", max_pin="x.x") }}
        - {{ pin_subpackage("libbrotlidec", max_pin="x.x") }}
    script: install_library.sh  # [unix]
    script: install_library.bat  # [win]
    requirements:
      build:
        - {{ stdlib('c') }}
        - {{ compiler('c') }}
        - cmake
        - ninja-base
      host:
        - {{ pin_subpackage("libbrotlienc", exact=True) }}
        - {{ pin_subpackage("libbrotlidec", exact=True) }}
        - {{ pin_subpackage("brotli-bin", exact=True) }}
      run:
        - {{ pin_subpackage("libbrotlienc", exact=True) }}
        - {{ pin_subpackage("libbrotlidec", exact=True) }}
        - {{ pin_subpackage("brotli-bin", exact=True) }}
    test:
      commands:
        - brotli --help
        - test -f $PREFIX/lib/libbrotlienc${SHLIB_EXT}         # [unix]
        - test -f $PREFIX/lib/libbrotlidec${SHLIB_EXT}         # [unix]
        - test -f $PREFIX/lib/libbrotlicommon${SHLIB_EXT}      # [unix]
        - test -f $PREFIX/include/brotli/encode.h              # [unix]
        - if not exist %LIBRARY_BIN%\\brotli.exe exit 1        # [win]
        - if not exist %LIBRARY_BIN%\\brotlicommon.dll exit 1  # [win]
        - if not exist %LIBRARY_BIN%\\brotlidec.dll exit 1     # [win]
        - if not exist %LIBRARY_BIN%\\brotlienc.dll exit 1     # [win]
        - if not exist %LIBRARY_LIB%\\brotlicommon.lib exit 1  # [win]
        - if not exist %LIBRARY_LIB%\\brotlidec.lib exit 1     # [win]
        - if not exist %LIBRARY_LIB%\\brotlienc.lib exit 1     # [win]
        - if not exist %LIBRARY_INC%\\brotli\\encode.h exit 1  # [win]

        # CFEP-18: Static libs shouldn't be part of the main package
        - test ! -f $PREFIX/lib/libbrotlienc-static.a             # [unix]
        - test ! -f $PREFIX/lib/libbrotlidec-static.a             # [unix]
        - test ! -f $PREFIX/lib/libbrotlicommon-static.a          # [unix]
        - if exist %LIBRARY_LIB%\\brotlicommon-static.lib exit 1  # [win]
        - if exist %LIBRARY_LIB%\\brotlidec-static.lib exit 1     # [win]
        - if exist %LIBRARY_LIB%\\brotlienc-static.lib exit 1     # [win]

  - name: brotli-python
    build:
      run_exports:
        - {{ pin_subpackage('brotli') }}
    script: install_python.sh  # [unix]
    script: install_python.bat  # [win]
    requirements:
      build:
        - {{ stdlib('c') }}
        - {{ compiler('c') }}
        - cmake
        - ninja-base
      host:
        - pip
        - python
        - setuptools
        - wheel
        - {{ pin_subpackage('brotli', exact=True) }}
      run:
        - python 
    test:
      imports:
        - brotli

about:
  home: https://github.com/google/brotli
  license: MIT
  license_family: MIT
  license_file: LICENSE
  summary: Brotli compression format
  description: Brotli compression format
  doc_url: https://github.com/google/brotli/tree/master/docs
  dev_url: https://github.com/google/brotli

extra:
  recipe-maintainers:
    - wesm
    - xhochy
    - CJ-Wright
