# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

package:
  name: arrow-adbc-split
  # TODO: this needs to get bumped by the release process
  version: 0.6.0

source:
  path: ../../

build:
  number: 0

outputs:
  - name: adbc-driver-manager-cpp
    script: build-cpp.sh                                                         # [not win]
    script: build-cpp.bat                                                        # [win]
    requirements:
      build:
        - {{ compiler('cxx') }}
        - cmake
        - ninja
      host:
      run:
    test:
      commands:
        - test -f $PREFIX/include/adbc.h                                         # [unix]
        - test -f $PREFIX/include/adbc_driver_manager.h                          # [unix]
        - test -d $PREFIX/lib/cmake/AdbcDriverManager/                           # [unix]
        - test -f $PREFIX/lib/pkgconfig/adbc-driver-manager.pc                   # [unix]
        - test ! -f $PREFIX/lib/libadbc_driver_manager.a                         # [unix]
        - test -f $PREFIX/lib/libadbc_driver_manager.so                          # [linux]
        - test -f $PREFIX/lib/libadbc_driver_manager.dylib                       # [osx]

        - if not exist %LIBRARY_BIN%\adbc_driver_manager.dll exit 1              # [win]
        - if not exist %LIBRARY_INC%\adbc.h exit 1                               # [win]
        - if not exist %LIBRARY_INC%\adbc_driver_manager.h exit 1                # [win]
        - if not exist %LIBRARY_LIB%\adbc_driver_manager.lib exit 1              # [win]
        - if not exist %LIBRARY_LIB%\cmake\AdbcDriverManager exit 1              # [win]
        - if not exist %LIBRARY_LIB%\pkgconfig\adbc-driver-manager.pc exit 1     # [win]

  - name: adbc-driver-flightsql-go
    script: build-cpp.sh                                                         # [not win]
    script: build-cpp.bat                                                        # [win]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - _go_select *=cgo
        - cmake
        - go-cgo >=1.18
        - ninja
        - pkg-config
    test:
      commands:
        - test ! -f $PREFIX/include/adbc.h                                       # [unix]
        - test -f $PREFIX/lib/pkgconfig/adbc-driver-flightsql.pc                 # [unix]
        - test ! -f $PREFIX/lib/libadbc_driver_flightsql.a                       # [unix]
        - test -f $PREFIX/lib/libadbc_driver_flightsql.so                        # [linux]
        - test -f $PREFIX/lib/libadbc_driver_flightsql.dylib                     # [osx]

        - if exist %LIBRARY_INC%\adbc.h exit 1                                   # [win]
        - if not exist %LIBRARY_BIN%\adbc_driver_flightsql.dll exit 1            # [win]
        - if not exist %LIBRARY_LIB%\adbc_driver_flightsql.lib exit 1            # [win]
        - if not exist %LIBRARY_LIB%\pkgconfig\adbc-driver-flightsql.pc exit 1   # [win]

  - name: adbc-driver-postgresql-cpp
    script: build-cpp.sh                                                         # [not win]
    script: build-cpp.bat                                                        # [win]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - cmake
        - ninja
        - pkg-config
      host:
        - libpq
      run:
        - libpq
    test:
      commands:
        - test ! -f $PREFIX/include/adbc.h                                       # [unix]
        - test -d $PREFIX/lib/cmake/AdbcDriverPostgreSQL/                        # [unix]
        - test -f $PREFIX/lib/pkgconfig/adbc-driver-postgresql.pc                # [unix]
        - test ! -f $PREFIX/lib/libadbc_driver_postgresql.a                      # [unix]
        - test -f $PREFIX/lib/libadbc_driver_postgresql.so                       # [linux]
        - test -f $PREFIX/lib/libadbc_driver_postgresql.dylib                    # [osx]

        - if exist %LIBRARY_INC%\adbc.h exit 1                                   # [win]
        - if not exist %LIBRARY_BIN%\adbc_driver_postgresql.dll exit 1           # [win]
        - if not exist %LIBRARY_LIB%\adbc_driver_postgresql.lib exit 1           # [win]
        - if not exist %LIBRARY_LIB%\cmake\AdbcDriverPostgreSQL exit 1           # [win]
        - if not exist %LIBRARY_LIB%\pkgconfig\adbc-driver-postgresql.pc exit 1  # [win]

  - name: adbc-driver-sqlite-cpp
    script: build-cpp.sh                                                         # [not win]
    script: build-cpp.bat                                                        # [win]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - cmake
        - ninja
        - pkg-config
      host:
        - libsqlite
      run:
        - libsqlite
    test:
      commands:
        - test ! -f $PREFIX/include/adbc.h                                       # [unix]
        - test -d $PREFIX/lib/cmake/AdbcDriverSQLite/                            # [unix]
        - test -f $PREFIX/lib/pkgconfig/adbc-driver-sqlite.pc                    # [unix]
        - test ! -f $PREFIX/lib/libadbc_driver_sqlite.a                          # [unix]
        - test -f $PREFIX/lib/libadbc_driver_sqlite.so                           # [linux]
        - test -f $PREFIX/lib/libadbc_driver_sqlite.dylib                        # [osx]

        - if exist %LIBRARY_INC%\adbc.h exit 1                                   # [win]
        - if not exist %LIBRARY_BIN%\adbc_driver_sqlite.dll exit 1               # [win]
        - if not exist %LIBRARY_LIB%\adbc_driver_sqlite.lib exit 1               # [win]
        - if not exist %LIBRARY_LIB%\cmake\AdbcDriverSQLite exit 1               # [win]
        - if not exist %LIBRARY_LIB%\pkgconfig\adbc-driver-sqlite.pc exit 1      # [win]

  - name: adbc-driver-manager
    script: build-python.sh                                                      # [not win]
    script: build-python.bat                                                     # [win]
    requirements:
      build:
        - {{ compiler('cxx') }}
        - cross-python_{{ target_platform }}                                     # [build_platform != target_platform]
        - cython
        - pip
        - python {{ python }}
        - setuptools
      host:
        - cython
        - pip
        - python
        - setuptools
      run:
        - python
      run_constrained:
        - pyarrow >=8.0.0
    test:
      imports:
        - adbc_driver_manager
        - adbc_driver_manager._lib

  - name: adbc-driver-flightsql
    build:
      noarch: python
    script: build-python.sh                                                      # [not win]
    script: build-python.bat                                                     # [win]
    requirements:
      build:
        - pip
        - setuptools
      host:
        - {{ pin_subpackage('adbc-driver-flightsql-go', exact=True) }}
        - pip
        - python >=3.9
        - setuptools
      run:
        - {{ pin_subpackage('adbc-driver-manager') }}
        - {{ pin_subpackage('adbc-driver-flightsql-go', exact=True) }}
        - python >=3.9
      run_constrained:
        - pyarrow >=8.0.0
    test:
      imports:
        - adbc_driver_flightsql

  - name: adbc-driver-postgresql
    build:
      noarch: python
    script: build-python.sh                                                      # [not win]
    script: build-python.bat                                                     # [win]
    requirements:
      build:
        - pip
        - setuptools
      host:
        - {{ pin_subpackage('adbc-driver-postgresql-cpp', exact=True) }}
        - pip
        - python >=3.9
        - setuptools
      run:
        - {{ pin_subpackage('adbc-driver-manager') }}
        - {{ pin_subpackage('adbc-driver-postgresql-cpp', exact=True) }}
        - python >=3.9
      run_constrained:
        - pyarrow >=8.0.0
    test:
      imports:
        - adbc_driver_postgresql

  - name: adbc-driver-sqlite
    build:
      noarch: python
    script: build-python.sh                                                      # [not win]
    script: build-python.bat                                                     # [win]
    requirements:
      build:
        - pip
        - setuptools
      host:
        - {{ pin_subpackage('adbc-driver-sqlite-cpp', exact=True) }}
        - pip
        - python >=3.9
        - setuptools
      run:
        - {{ pin_subpackage('adbc-driver-manager') }}
        - {{ pin_subpackage('adbc-driver-sqlite-cpp', exact=True) }}
        - python >=3.9
      run_constrained:
        - pyarrow >=8.0.0
    test:
      imports:
        - adbc_driver_sqlite

about:
  home: https://arrow.apache.org
  summary: 'Database access libraries for Apache Arrow'
  description: |
    ADBC is an API standard for database access libraries ("drivers")
    in C and Java that uses Arrow for data. Instead of writing code
    for each individual database, applications can build against the
    ADBC APIs, and link against drivers that implement the
    standard. Additionally, a JDBC/ODBC-style driver manager is
    provided. This also implements the ADBC APIs, but dynamically
    loads drivers and dispatches calls to them.
  license: Apache-2.0
  license_family: APACHE
  license_file: LICENSE.txt
  doc_url: https://arrow.apache.org/docs/
  dev_url: https://github.com/apache/arrow-adbc

extra:
  recipe-maintainers:
    - lidavidm
