{% set version = "0.2.6" %}

{% set posix = 'm2-' if win else '' %}
{% set native = 'm2w64-' if win else '' %}

package:
  name: r-duckdb
  version: {{ version|replace("-", "_") }}

source:
  url:
    - {{ cran_mirror }}/src/contrib/duckdb_{{ version }}.tar.gz
    - {{ cran_mirror }}/src/contrib/Archive/duckdb/duckdb_{{ version }}.tar.gz
  sha256: 5cf2af519f349b54f3e91f143214aece31febf8d96720d3b29cd2def49ae1584

build:
  merge_build_host: true  # [win]
  number: 0
  rpaths:
    - lib/R/lib/
    - lib/

requirements:
  build:
    - {{ compiler('c') }}              # [not win]
    - {{ compiler('m2w64_c') }}        # [win]
    - {{ compiler('cxx') }}            # [not win]
    - {{ compiler('m2w64_cxx') }}      # [win]
    - {{ posix }}filesystem        # [win]
    - {{ posix }}make
    - {{ posix }}sed               # [win]
    - {{ posix }}coreutils         # [win]
    - {{ posix }}zip               # [win]
    - cross-r-base {{ r_base }}    # [build_platform != target_platform]

  host:
    - r-base
    - r-dbi

  run:
    - r-base
    - {{ native }}gcc-libs         # [win]
    - r-dbi

test:
  commands:
    - $R -e "library('duckdb')"           # [not win]
    - "\"%R%\" -e \"library('duckdb')\""  # [win]

about:
  home: https://duckdb.org/, https://github.com/cwida/duckdb
  license: MPL-2.0
  summary: The DuckDB project is an embedded analytical data management system with support for the Structured Query Language (SQL). This package includes all of DuckDB and a R Database Interface (DBI) connector.
  license_family: MOZILLA
  license_file: LICENSE

extra:
  recipe-maintainers:
    - conda-forge/r
    - izahn
