distributable:
  url: https://archive.apache.org/dist/arrow/arrow-{{version}}/apache-arrow-{{version}}.tar.gz
  strip-components: 1
versions:
  url: https://archive.apache.org/dist/arrow/
  match: /arrow-\d+\.\d+\.\d+/
  strip:
    - /^arrow-/
dependencies:
  github.com/aws/aws-sdk-cpp: '*'
  github.com/google/brotli: '*'
  sourceware.org/bzip2: '*'
  google.com/glog: '*'
  grpc.io: '*'
  lz4.org: '*'
  openssl.org: '*'
  protobuf.dev: 24
  rapidjson.org: '*'
  github.com/google/re2: '*'
  google.github.io/snappy: '*'
  apache.org/thrift: '*'
  github.com/JuliaStrings/utf8proc: '*'
  facebook.com/zstd: '*'
build:
  dependencies:
    boost.org: '*'
    cmake.org: '*'
    llvm.org: ~16
    python.org: '<3.12'
  working-directory: cpp
  script:
    - cmake -B $BUILD_DIR $CMAKE_ARGS
    - cmake --build $BUILD_DIR
    - cmake --install $BUILD_DIR
    - run: |
        sed -i.bak "s|$PKGX_DIR|\${pcfiledir}/../../../..|g" ./*.pc
        rm ./*.bak
      working-directory: '{{prefix}}/lib/pkgconfig'
  env:
    BUILD_DIR: $(mktemp -d)
    CC: clang
    CXX: clang++
    LD: clang
    CMAKE_ARGS:
      - -DCMAKE_INSTALL_PREFIX="{{prefix}}
      - -DCMAKE_INSTALL_LIBDIR=lib
      - -DCMAKE_BUILD_TYPE=Release
      - -DCMAKE_FIND_FRAMEWORK=LAST
      - -DCMAKE_VERBOSE_MAKEFILE=ON
      - -Wno-dev
      - -DBUILD_TESTING=OFF
      - -DCMAKE_INSTALL_RPATH={{prefix}}
      - -DARROW_ACERO=ON
      - -DARROW_COMPUTE=ON
      - -DARROW_CSV=ON
      - -DARROW_DATASET=ON
      - -DARROW_FILESYSTEM=ON
      - -DARROW_GANDIVA=ON
      - -DARROW_HDFS=ON
      - -DARROW_JSON=ON
      - -DARROW_ORC=ON
      - -DARROW_PARQUET=ON
      - -DARROW_PROTOBUF_USE_SHARED=ON
      - -DARROW_S3=ON
      - -DARROW_WITH_BZ2=ON
      - -DARROW_WITH_ZLIB=ON
      - -DARROW_WITH_ZSTD=ON
      - -DARROW_WITH_LZ4=ON
      - -DARROW_WITH_SNAPPY=ON
      - -DARROW_WITH_BROTLI=ON
      - -DARROW_WITH_UTF8PROC=ON
      - -DARROW_INSTALL_NAME_RPATH=OFF
      - -DPARQUET_BUILD_EXECUTABLES=ON
    aarch64:
      CMAKE_ARGS:
        - -DARROW_MIMALLOC=ON
provides:
  - bin/parquet-dump-schema
  - bin/parquet-reader
  - bin/parquet-scan
test:
  dependencies:
    freedesktop.org/pkg-config: '*'
  script:
    - run: |
        cat << EOF > test.cpp
        #include "arrow/api.h"
        int main(void) {
          arrow::int64();
          return 0;
        }
        EOF
    - c++ test.cpp -std=c++17 -larrow -o test
    - ./test
    - run: |
        cat << EOF > version.cpp
        #include <arrow/api.h>
        #include <iostream>

        int main() {
            std::cout << "Apache Arrow Version: " << ARROW_VERSION_STRING << std::endl;
            return 0;
        }
        EOF
    - c++ version.cpp -std=c++17 -larrow -o version
    - ./version | grep {{version}}
    - pkg-config --modversion arrow | grep {{version}}
