# Copyright (c) 2021-2023, NVIDIA CORPORATION.

{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') %}
{% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %}
{% set cuda_major = cuda_version.split('.')[0] %}
{% set date_string = environ['RAPIDS_DATE_STRING'] %}


package:
  name: libcucim
  version: {{ version }}

source:
  git_url: ../../..

build:
  number: {{ GIT_DESCRIBE_NUMBER }}
  string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }}
  ignore_run_exports:
    - libwebp-base
  ignore_run_exports_from:
    {% if cuda_major == "11" %}
    - {{ compiler('cuda11') }}
    {% endif %}
  script_env:
    - AWS_ACCESS_KEY_ID
    - AWS_SECRET_ACCESS_KEY
    - AWS_SESSION_TOKEN
    - CMAKE_C_COMPILER_LAUNCHER
    - CMAKE_CUDA_COMPILER_LAUNCHER
    - CMAKE_CXX_COMPILER_LAUNCHER
    - CMAKE_GENERATOR
    - PARALLEL_LEVEL
    - SCCACHE_BUCKET
    - SCCACHE_IDLE_TIMEOUT
    - SCCACHE_REGION
    - SCCACHE_S3_KEY_PREFIX=libcucim-aarch64 # [aarch64]
    - SCCACHE_S3_KEY_PREFIX=libcucim-linux64 # [linux64]
    - SCCACHE_S3_USE_SSL
    - SCCACHE_S3_NO_CREDENTIALS

requirements:
  build:
    - {{ compiler("c") }}
    - {{ compiler("cxx") }}
    {% if cuda_major == "11" %}
    - {{ compiler('cuda11') }} ={{ cuda_version }}
    {% else %}
    - {{ compiler('cuda') }}
    {% endif %}
    - cuda-version ={{ cuda_version }}
    - binutils
    - cmake >=3.23.1,!=3.25.0
    - make
    - ninja
    - sysroot_{{ target_platform }} {{ sysroot_version }}
    - yasm # [x86_64]
  host:
    - cuda-version ={{ cuda_version }}
    {% if cuda_major == "11" %}
    - libcufile {{ cuda11_libcufile_host_version }}         # [linux64]
    - libcufile-dev {{ cuda11_libcufile_host_version }}     # [linux64]
    - libnvjpeg {{ cuda11_libnvjpeg_host_version }}
    - libnvjpeg-dev {{ cuda11_libnvjpeg_host_version }}
    {% else %}
    - libcufile-dev     # [linux64]
    - libnvjpeg-dev
    - libnvjpeg-static
    {% endif %}
    - jbig
    - libwebp-base
    - nvtx-c >=3.1.0
    - openslide
    - xz
    - zlib
    - zstd
  run:
    - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }}
    {% if cuda_major == "11" %}
    - cudatoolkit
    - libcufile {{ cuda11_libcufile_run_version }}      # [linux64]
    {% endif %}
    - {{ pin_compatible('libwebp-base', max_pin='x.x') }}
    - jbig
    # - openslide # skipping here but benchmark binary would need openslide library
    - xz
    - zlib
    - zstd

about:
  home: https://developer.nvidia.com/multidimensional-image-processing
  summary: libcucim C++ library
  license: Apache-2.0
  license_family: Apache
  license_file: LICENSE
  doc_url: https://docs.rapids.ai/api/cucim/stable/
  dev_url: https://github.com/rapidsai/cucim
