diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 90b6fe7a06..fd8393c196 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -124,7 +124,7 @@ jobs: with: submodules: recursive - name: configure - run: cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_BACKEND=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=install -DWERROR=ON -j 2 -Bbuild/release -H. + run: cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_BACKEND=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_MAVSDK_SERVER=ON -DCMAKE_INSTALL_PREFIX=install -DWERROR=ON -j 2 -Bbuild/release -H. - name: build run: cmake --build build/release --target install -- -j2 - name: test @@ -132,6 +132,96 @@ jobs: - name: test (mavsdk_server) run: ./build/release/src/backend/test/unit_tests_backend + alpine-linux-qemu: + runs-on: ubuntu-18.04 + name: Build on alpine for ${{ matrix.arch }} + + strategy: + matrix: + include: + - arch: armv6 + distro: alpine_latest + - arch: armv7 + distro: alpine_latest + - arch: aarch64 + distro: alpine_latest + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - name: ccache cache files + uses: actions/cache@v1.1.0 + with: + path: .ccache + key: ${{ matrix.arch }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: | + ${{ matrix.arch }}-ccache- + + - uses: uraimo/run-on-arch-action@v2.0.6 + name: Build + id: build + with: + arch: ${{ matrix.arch }} + distro: ${{ matrix.distro }} + + # Not required, but speeds up builds + githubToken: ${{ github.token }} + + # Mount the source directory in the container + dockerRunArgs: | + --volume "${PWD}:/root/MAVSDK" + --volume "${PWD}/.ccache:/root/.ccache" + + # Pass some environment variables to the container + #env: | # YAML, but pipe character is necessary + # artifact_name: git-${{ matrix.distro }}_${{ matrix.arch }} + + # The shell to run commands with in the container + shell: /bin/sh + + # Install some dependencies in the container. This speeds up builds if + # you are also using githubToken. Any dependencies installed here will + # be part of the container image that gets cached, so subsequent + # builds don't have to re-install them. The image layer is cached + # publicly in your project's package repository, so it is vital that + # no secrets are present in the container state or logs. + install: | + apk update + apk add build-base cmake git linux-headers libexecinfo-dev ccache + + run: | + cd /root/MAVSDK + export CC=/usr/lib/ccache/bin/gcc + export CXX=/usr/lib/ccache/bin/g++ + export CCACHE_COMPRESS="true" + export CCACHE_MAXSIZE="400M" + cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_BACKEND=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_MAVSDK_SERVER=ON -DCMAKE_INSTALL_PREFIX=install -DWERROR=ON -j 2 -Bbuild/release -H. + cmake --build build/release --target install -- -j2 + ./build/release/src/unit_tests_runner + ./build/release/src/backend/test/unit_tests_backend + ccache -s + + - name: Check the artifact + run: | + file "${PWD}/install/bin/mavsdk_server" + - name: Publish artefacts + if: startsWith(github.ref, 'refs/tags/v') + uses: svenstaro/upload-release-action@v1-release + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: "${PWD}/install/bin/mavsdk_server" + asset_name: 'mavsdk_server_musl_${{ matrix.arch }}' + tag: ${{ github.ref }} + overwrite: true + px4-sitl-older: name: PX4 SITL ${{ matrix.px4_version }} (ubuntu-18.04) runs-on: ubuntu-18.04 diff --git a/src/backend/src/CMakeLists.txt b/src/backend/src/CMakeLists.txt index 4d1b8a57ff..9b64850688 100644 --- a/src/backend/src/CMakeLists.txt +++ b/src/backend/src/CMakeLists.txt @@ -88,6 +88,13 @@ if(NOT IOS AND NOT ANDROID) mavsdk ) + if (BUILD_STATIC_MAVSDK_SERVER) + target_link_options(mavsdk_server_bin PRIVATE -static-libgcc -static-libstdc++ -static) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + set_target_properties(mavsdk_server_bin PROPERTIES LINK_SEARCH_START_STATIC ON) + set_target_properties(mavsdk_server_bin PROPERTIES LINK_SEARCH_END_STATIC ON) + endif() + # MSVC fails to generate the `mavsdk_server` binary while having # a library called `mavsdk_server` as well. This means that with # MSVC, we build `mavsdk_server_bin.exe`. diff --git a/src/core/geometry_test.cpp b/src/core/geometry_test.cpp index d24332e03c..9e3af2d458 100644 --- a/src/core/geometry_test.cpp +++ b/src/core/geometry_test.cpp @@ -45,6 +45,6 @@ TEST(Geoemtry, LocalToGlobalAndBack) CoordinateTransformation::LocalCoordinate location{-140.0, 240.0}; auto location_again = ct.local_from_global(ct.global_from_local(location)); - EXPECT_NEAR(location.north_m, location_again.north_m, 1e-9); - EXPECT_NEAR(location.east_m, location_again.east_m, 1e-9); -} \ No newline at end of file + EXPECT_NEAR(location.north_m, location_again.north_m, 1e-8); + EXPECT_NEAR(location.east_m, location_again.east_m, 1e-8); +}