# Copyright (c) 2018-2024, NVIDIA CORPORATION.

{% set version = environ['RAPIDS_PACKAGE_VERSION'].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: librmm-split

source:
  path: ../../..

requirements:
  build:
    - cmake {{ cmake_version }}
    - ninja
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    {% if cuda_major == "11" %}
    - {{ compiler('cuda11') }} {{ cuda_version }}
    {% else %}
    - {{ compiler('cuda') }}
    {% endif %}
    - cuda-version ={{ cuda_version }}
    - {{ stdlib("c") }}
  host:
    - cuda-version ={{ cuda_version }}
    # We require spdlog and fmt (which was de-vendored from spdlog
    # conda-forge packages in 1.11.0) so that the spdlog headers are not
    # pulled by CPM and installed as a part of the rmm packages. However,
    # building against librmm still requires these headers. They are also
    # added as a run requirement via the packages' run_exports.
    - fmt {{ fmt_version }}
    - spdlog {{ spdlog_version }}

build:
  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=librmm-aarch64 # [aarch64]
    - SCCACHE_S3_KEY_PREFIX=librmm-linux64 # [linux64]
    - SCCACHE_S3_USE_SSL
    - SCCACHE_S3_NO_CREDENTIALS

outputs:
  - name: librmm
    version: {{ version }}
    script: install_librmm.sh
    build:
      number: {{ GIT_DESCRIBE_NUMBER }}
      string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }}
      run_exports:
        - {{ pin_subpackage("librmm", max_pin="x.x") }}
      ignore_run_exports_from:
        {% if cuda_major == "11" %}
        - {{ compiler('cuda11') }}
        {% else %}
        - {{ compiler('cuda') }}
        {% endif %}
    requirements:
      build:
        - cmake {{ cmake_version }}
      host:
        - cuda-version ={{ cuda_version }}
      run:
        - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }}
        {% if cuda_major == "11" %}
        - cudatoolkit
        {% endif %}
        - fmt {{ fmt_version }}
        - spdlog {{ spdlog_version }}
    test:
      commands:
        - test -d "${PREFIX}/include/rmm"
    about:
      home: https://rapids.ai/
      license: Apache-2.0
      summary: librmm library
  - name: librmm-tests
    version: {{ version }}
    script: install_librmm_tests.sh
    build:
      number: {{ GIT_DESCRIBE_NUMBER }}
      string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }}
      ignore_run_exports_from:
        {% if cuda_major == "11" %}
        - {{ compiler('cuda11') }}
        {% else %}
        - {{ compiler('cuda') }}
        - cuda-cudart-dev
        {% endif %}
    requirements:
      build:
        - cmake {{ cmake_version }}
      host:
        - cuda-version ={{ cuda_version }}
        {% if cuda_major == "11" %}
        - cudatoolkit
        {% else %}
        - cuda-cudart-dev
        {% endif %}
      run:
        {% if cuda_major == "11" %}
        - cudatoolkit
        {% else %}
        - cuda-cudart
        {% endif %}
        - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }}
        - {{ pin_subpackage('librmm', exact=True) }}
    about:
      home: https://rapids.ai/
      license: Apache-2.0
      summary: librmm test & benchmark executables
