distributable:
  url: https://github.com/libgit2/libgit2/archive/v{{version}}.tar.gz
  strip-components: 1

versions:
  github: libgit2/libgit2

dependencies:
  libssh2.org: ^1

build:
  dependencies:
    cmake.org: ^3
    freedesktop.org/pkg-config: ^0.29
  working-directory: build
  script: |
    cmake .. $ARGS
    make --jobs {{ hw.concurrency }} install
  env:
    ARGS:
      - -DBUILD_EXAMPLES=OFF
      - -DBUILD_TESTS=OFF
      - -DUSE_SSH=ON
      - -DBUILD_SHARED_LIBS=ON
      - -DCMAKE_INSTALL_PREFIX="{{prefix}}"
      - -DCMAKE_BUILD_TYPE=Release

provides:
  - bin/git2

test:
  fixture: |
    #include <git2.h>
    #include <assert.h>
    int main(int argc, char *argv[]) {
      int options = git_libgit2_features();
      assert(options & GIT_FEATURE_SSH);
      return 0;
    }
  script: |
    mv $FIXTURE b.c
    cc b.c -lgit2
    ./a.out
