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

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

source:
  git_url: https://github.com/dmlc/xgboost
  # This is the commit where the CRAN version got updated
  git_tag: 98be9aef9aab76ca8e1ca6c250c565dcdbcb7be0
  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
    # dmlc-core patches
    - 0001-Do-not-define-fopen64-as-std-fopen-on-32-bit-mingw-w.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
    script: install-py-xgboost.sh
    requirements:
      build:
        - {{ compiler('c') }}    # [not win]
        - {{ compiler('cxx') }}  # [not win]
        - llvm-openmp >=4.0.1    # [osx]
        - m2w64-toolchain        # [win]
      host:
        - {{ pin_subpackage('libxgboost', exact=True) }}
        - python
        - setuptools
      run:
        - {{ pin_subpackage('libxgboost', exact=True) }}
        - llvm-openmp >=4.0.1    # [osx]
        - python
        - numpy
        - scipy
        - scikit-learn
    test:
      script: test-py-xgboost.py

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