diff options
author | Nikita Shulga <nshulga@fb.com> | 2022-07-08 03:54:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-08 03:54:13 +0300 |
commit | 4c54515b841b55b94a83153931020beea4bea11c (patch) | |
tree | 522f6d6b0cfd5ac042c3157774118a3ea2ffa769 | |
parent | 4b5a76c4de21265ddba98fc8f259e136ad11411b (diff) |
[GHA] Add build workflow (#97)
So far on Linux, Windows, Mac and Android
-rw-r--r-- | .github/workflows/build.yml | 68 | ||||
-rwxr-xr-x | scripts/local-build.sh | 38 |
2 files changed, 106 insertions, 0 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..794e283 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,68 @@ +name: Build using CMake +on: + pull_request: + push: + branches: + - master + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true +jobs: + cmake-linux-local: + runs-on: ubuntu-latest + timeout-minutes: 40 + steps: + - uses: actions/checkout@v2 + - name: Update apt + run: sudo apt update + - name: Install ninja + run: sudo apt install ninja-build + - name: Configure and build + run: scripts/local-build.sh + working-directory: ${{ github.workspace }} + cmake-darwin: + runs-on: macos-latest + timeout-minutes: 40 + steps: + - uses: actions/checkout@v2 + - name: Install ninja + run: brew install ninja + - name: Configure and build + run: scripts/local-build.sh + working-directory: ${{ github.workspace }} + cmake-windows: + runs-on: windows-latest + timeout-minutes: 40 + steps: + - uses: actions/checkout@v2 + - name: Install ninja + run: choco install ninja + - name: Configure and build + run: scripts/local-build.sh + shell: bash # Specify bash so we can reuse the build script on Windows (runs on Git bash) + working-directory: ${{ github.workspace }} + cmake-android: + strategy: + matrix: + script: [android-arm64-build.sh, android-armv7-build.sh, android-x86-build.sh] + runs-on: ubuntu-latest + timeout-minutes: 40 + steps: + - uses: actions/checkout@v2 + - name: Update apt + run: sudo apt update + - name: Install ninja + run: sudo apt install ninja-build + - name: Setup Android NDK + id: setup-ndk + uses: nttld/setup-ndk@v1.0.6 + with: + ndk-version: r23b + add-to-path: false + - name: Configure and build + run: scripts/${{ matrix.script }} + working-directory: ${{ github.workspace }} + env: + ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }} diff --git a/scripts/local-build.sh b/scripts/local-build.sh new file mode 100755 index 0000000..426a13b --- /dev/null +++ b/scripts/local-build.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# +# Copyright (c) Facebook, Inc. and its affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +set -e + +mkdir -p build/local + +CMAKE_ARGS=() + +# CMake-level configuration +CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release") +CMAKE_ARGS+=("-DCMAKE_POSITION_INDEPENDENT_CODE=ON") + +# If Ninja is installed, prefer it to Make +if [ -x "$(command -v ninja)" ] +then + CMAKE_ARGS+=("-GNinja") +fi + +# Use-specified CMake arguments go last to allow overridding defaults +CMAKE_ARGS+=($@) + +cd build/local && cmake ../.. \ + "${CMAKE_ARGS[@]}" + +# Cross-platform parallel build +if [ "$(uname)" == "Darwin" ]; then + cmake --build . -- "-j$(sysctl -n hw.ncpu)" +elif [ "$(uname)" == "Linux" ]; then + cmake --build . -- "-j$(nproc)" +else + cmake --build . +fi |