{% set name = "brunsli" %}
{% set version = "0.1" %}

package:
  name: {{ name|lower }}
  version: {{ version }}

source:
  url: https://github.com/google/brunsli/archive/v{{ version }}.tar.gz
  sha256: 62762dc740f9fcc9706449c078f12c2a366416486d2882be50a9f201f99ac0bc
  patches:
    # https://github.com/google/brunsli/issues/91
    - use_conda_forge_shared_libraries.patch

build:
  number: 0
  # Windows builds seem too experimental upstream
  # https://github.com/google/brunsli/issues/51
  # https://github.com/google/brunsli/issues/62
  # https://github.com/google/brunsli/issues/93
  skip: true  # [win]
  run_exports:
    # New package by google, keep defaults
    - {{ pin_subpackage( name | lower ) }}

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - cmake
    - make   # [unix]
    - ninja  # [win]
  host:
    - brotli

test:
  commands:
    - test -f $PREFIX/include/brunsli/encode.h         # [unix]
    - test -f $PREFIX/include/brunsli/decode.h         # [unix]
    - test -f $PREFIX/lib/libbrunslienc-c${SHLIB_EXT}  # [unix]
    - test -f $PREFIX/lib/libbrunslidec-c${SHLIB_EXT}  # [unix]
    # Executable aways returns 1
    - which cbrunsli  # [unix]
    - which dbrunsli  # [unix]
    - if not exist %LIBRARY_INC%\brunsli\encode.h exit 1  # [win]
    - if not exist %LIBRARY_INC%\brunsli\decode.h exit 1  # [win]
    - if not exist %LIBRARY_LIB%\brunslienc-c.lib exit 1  # [win]
    - if not exist %LIBRARY_LIB%\brunslidec-c.lib exit 1  # [win]
    - if not exist %LIBRARY_BIN%\brunslienc-c.dll exit 1  # [win]
    - if not exist %LIBRARY_BIN%\brunslidec-c.dll exit 1  # [win]
    - where cbrunsli  # [win]
    - where dbrunsli  # [win]

about:
  home: https://github.com/google/brunsli
  license: MIT
  license_family: MIT
  license_file: LICENSE
  summary: Practical JPEG Repacker

  description: |
    Brunsli is a lossless JPEG repacking library.

    Brunsli allows for a 22% decrease in file size while
    allowing the original JPEG to be recovered byte-by-byte.

extra:
  recipe-maintainers:
    - hmaarrfk
