libdivecomputer-sys 0.1.0

Unsafe bindings for libdivecomputer
Documentation
name: Build

on: [push, pull_request]

jobs:

  linux:

    name: Linux

    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        compiler: [gcc, clang]

    env:
      CC: ${{ matrix.compiler }}

    steps:
      - uses: actions/checkout@v3
      - name: Install dependencies
        run: sudo apt-get install libbluetooth-dev libusb-1.0-0-dev
      - run: autoreconf --install --force
      - run: ./configure --prefix=/usr
      - run: make
      - run: make distcheck
      - name: Package artifacts
        run: |
          make install DESTDIR=$PWD/artifacts
          tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr
      - uses: actions/upload-artifact@v3
        with:
          name: ${{ github.job }}-${{ matrix.compiler }}
          path: ${{ github.job }}-${{ matrix.compiler }}.tar.gz

  mac:

    name: Mac

    runs-on: macos-latest

    strategy:
      fail-fast: false
      matrix:
        compiler: [gcc, clang]

    env:
      CC: ${{ matrix.compiler }}

    steps:
      - uses: actions/checkout@v3
      - name: Install dependencies
        run: brew install autoconf automake libtool hidapi libusb
      - run: autoreconf --install --force
      - run: ./configure --prefix=/usr
      - run: make
      - run: make distcheck
      - name: Package artifacts
        run: |
          make install DESTDIR=$PWD/artifacts
          tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr
      - uses: actions/upload-artifact@v3
        with:
          name: ${{ github.job }}-${{ matrix.compiler }}
          path: ${{ github.job }}-${{ matrix.compiler }}.tar.gz

  windows:

    name: Windows

    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        arch: [i686, x86_64]

    steps:
      - uses: actions/checkout@v3
      - name: Install dependencies
        run: sudo apt-get install gcc-mingw-w64 binutils-mingw-w64 mingw-w64-tools
      - name: Install libusb
        env:
          LIBUSB_VERSION: 1.0.26
        run: |
          wget -c https://github.com/libusb/libusb/archive/refs/tags/v${LIBUSB_VERSION}.tar.gz
          tar xzf v${LIBUSB_VERSION}.tar.gz
          pushd libusb-${LIBUSB_VERSION}
          autoreconf --install --force
          ./configure --host=${{ matrix.arch }}-w64-mingw32 --prefix=/usr
          make
          make install DESTDIR=$PWD/../artifacts
          popd
      - name: Install hidapi
        env:
          HIDAPI_VERSION: 0.12.0
        run: |
          wget -c https://github.com/libusb/hidapi/archive/refs/tags/hidapi-${HIDAPI_VERSION}.tar.gz
          tar xzf hidapi-${HIDAPI_VERSION}.tar.gz
          pushd hidapi-hidapi-${HIDAPI_VERSION}
          autoreconf --install --force
          ./configure --host=${{ matrix.arch }}-w64-mingw32 --prefix=/usr LDFLAGS='-static-libgcc'
          make
          make install DESTDIR=$PWD/../artifacts
          popd
      - run: autoreconf --install --force
      - run: ./configure --host=${{ matrix.arch }}-w64-mingw32 --prefix=/usr
        env:
          PKG_CONFIG_LIBDIR: ${{ github.workspace }}/artifacts/usr/lib/pkgconfig
          PKG_CONFIG_SYSROOT_DIR: ${{ github.workspace }}/artifacts
          PKG_CONFIG_ALLOW_SYSTEM_CFLAGS: 1
          PKG_CONFIG_ALLOW_SYSTEM_LIBS: 1
      - run: make
      - run: make distcheck
      - name: Package artifacts
        run: |
          make install DESTDIR=$PWD/artifacts
          tar -czf ${{ github.job }}-${{ matrix.arch }}.tar.gz -C artifacts usr
      - uses: actions/upload-artifact@v3
        with:
          name: ${{ github.job }}-${{ matrix.arch }}
          path: ${{ github.job }}-${{ matrix.arch }}.tar.gz

  msvc:

    name: Visual Studio

    runs-on: windows-latest

    strategy:
      fail-fast: false
      matrix:
        platform: [x86, x64]

    env:
      CONFIGURATION: Release

    steps:
      - uses: actions/checkout@v3
      - uses: msys2/setup-msys2@v2
        with:
          install: autoconf automake libtool pkg-config make gcc
      - run: |
          autoreconf --install --force
          ./configure --prefix=/usr
          make -C src revision.h
        shell: msys2 {0}
      - uses: microsoft/setup-msbuild@v1
      - run: msbuild -m -p:Platform=${{ matrix.platform }} -p:Configuration=${{ env.CONFIGURATION }} contrib/msvc/libdivecomputer.vcxproj
      - uses: actions/upload-artifact@v3
        with:
          name: ${{ github.job }}-${{ matrix.platform }}
          path: contrib/msvc/${{ matrix.platform }}/${{ env.CONFIGURATION }}/bin

  android:

    name: Android

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      - run: |
          autoreconf --install --force
          ./configure --prefix=/usr
          make -C src revision.h
      - run: $ANDROID_NDK/ndk-build -C contrib/android NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk
      - uses: actions/upload-artifact@v3
        with:
          name: ${{ github.job }}
          path: contrib/android/libs