{% set name = "xgboost" %}
{% set version = "0.90" %}

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

source:
  git_url: https://github.com/dmlc/xgboost
  # corresponds to 0.80 tag
  git_tag: 515f5f5c4779ff5361dcd796e22d55937e1048ea
  patches:
    # xgboost patches
    - 0001-conda-Unbundle-libxgboost.-dll-dylib-so.patch
    - 0002-Fix-R-package-PKGROOT.patch
    - 0003-Fix-R-package-mingw-w64-compiler-flags-remove-m64.patch
    - 0004-Fix-configure-check-for-OpenMP-on-macOS.patch
    - 0005-Add-ADD_-FLAGS-to-end-of-commandlines.patch

build:
  skip: true  # [win32 or linux32]

requirements:
  build:
    - {{ compiler('c') }}    # [not win]
    - {{ compiler('cxx') }}  # [not win]
    - llvm-openmp >=4.0.1    # [osx]
    - m2w64-toolchain        # [win]
    - git                    # [not win]
    - m2-git                 # [win]
    - make                   # [not win]
    - posix                  # [win]

outputs:
  - name: libxgboost
    script: install-libxgboost.sh
    requirements:
      build:
        - {{ compiler('c') }}    # [not win]
        - {{ compiler('cxx') }}  # [not win]
        - llvm-openmp >=4.0.1    # [osx]
        - m2w64-toolchain        # [win]
        - git                    # [not win]
        - m2-git                 # [win]
        - make                   # [not win]
        - posix                  # [win]
      host:
        - llvm-openmp >=4.0.1    # [osx]
      run:
        - llvm-openmp >=4.0.1    # [osx]
        - m2w64-gcc-libs         # [win]

  - name: _py-xgboost-mutex
    version: 2.0
    build:
      string: cpu_0

  - name: py-xgboost
    script: install-py-xgboost.sh
    requirements:
      build:
        - {{ compiler('c') }}    # [not win]
        - {{ compiler('cxx') }}  # [not win]
        - llvm-openmp >=4.0.1    # [osx]
        - m2w64-toolchain        # [win]
        - posix                  # [win]
      host:
        - {{ pin_subpackage('libxgboost', exact=True) }}
        - python
        - setuptools
      run:
        - {{ pin_subpackage('libxgboost', exact=True) }}
        - {{ pin_subpackage('_py-xgboost-mutex', exact=True) }}
        - llvm-openmp >=4.0.1    # [osx]
        - python
        - numpy
        - scipy
        - scikit-learn
    test:
      script: test-py-xgboost.py

  - name: py-xgboost-cpu
    requirements:
      host:
        - python
      run:
        - python
        - {{ pin_subpackage('py-xgboost', exact=True) }}

  - name: _r-xgboost-mutex
    version: 2.0
    build:
      string: cpu_0

  - name: r-xgboost
    script: install-r-xgboost.sh
    build:
      merge_build_host: True  # [win]
      rpaths:
        - lib/R/lib
    requirements:
      build:
        - {{ compiler('c') }}    # [not win]
        - {{ compiler('cxx') }}  # [not win]
        - llvm-openmp >=4.0.1    # [osx]
        - m2w64-toolchain        # [win]
        - git                    # [not win]
        - m2-git                 # [win]
        - make                   # [not win]
        - posix                  # [win]
      host:
        - {{ pin_subpackage('libxgboost', exact=True) }}
        - r-base
        - r-matrix
        - r-data.table
        - r-magrittr
        - r-stringi
        - r-knitr
      run:
        - {{ pin_subpackage('libxgboost', exact=True) }}
        - {{ pin_subpackage('_r-xgboost-mutex', exact=True) }}
        - llvm-openmp >=4.0.1    # [osx]
        - r-base
        - r-matrix
        - r-data.table
        - r-magrittr
        - r-stringi
    test:
      files:
        - test-r-xgboost.r
      commands:
        - Rscript test-r-xgboost.r

  - name: r-xgboost-cpu
    requirements:
      host:
        - r-base
      run:
        - r-base
        - {{ pin_subpackage('r-xgboost', exact=True) }}
