From 80ad17c12b3adf9d5c81a9aa82dc95ce885fbadf Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sun, 11 Oct 2020 19:53:33 +0200 Subject: [PATCH 1/8] backend: build statically with musl --- src/backend/src/CMakeLists.txt | 5 +++++ src/backend/test/CMakeLists.txt | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/backend/src/CMakeLists.txt b/src/backend/src/CMakeLists.txt index 4d1b8a57ff..7cf66fc385 100644 --- a/src/backend/src/CMakeLists.txt +++ b/src/backend/src/CMakeLists.txt @@ -88,6 +88,11 @@ if(NOT IOS AND NOT ANDROID) mavsdk ) + 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) + # 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/backend/test/CMakeLists.txt b/src/backend/test/CMakeLists.txt index 8c3319cf37..91a6934dde 100644 --- a/src/backend/test/CMakeLists.txt +++ b/src/backend/test/CMakeLists.txt @@ -42,4 +42,9 @@ target_link_libraries(unit_tests_backend gmock_main ) +target_link_options(unit_tests_backend PRIVATE -static-libgcc -static-libstdc++ -static) +set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") +set_target_properties(unit_tests_backend PROPERTIES LINK_SEARCH_START_STATIC ON) +set_target_properties(unit_tests_backend PROPERTIES LINK_SEARCH_END_STATIC ON) + add_test(unit_tests unit_tests_backend) From 281195481bef4c2447ab1b791be4061b3937645f Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sat, 17 Oct 2020 17:52:54 +0200 Subject: [PATCH 2/8] backend: option to trigger static mavsdk_server --- src/backend/src/CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/backend/src/CMakeLists.txt b/src/backend/src/CMakeLists.txt index 7cf66fc385..9b64850688 100644 --- a/src/backend/src/CMakeLists.txt +++ b/src/backend/src/CMakeLists.txt @@ -88,10 +88,12 @@ if(NOT IOS AND NOT ANDROID) mavsdk ) - 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) + 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 From 7f5f4878c7d74276aaf8a1662f3891bf16b2d2b8 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sat, 17 Oct 2020 17:53:16 +0200 Subject: [PATCH 3/8] backend: don't bother making test static --- src/backend/test/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/backend/test/CMakeLists.txt b/src/backend/test/CMakeLists.txt index 91a6934dde..8c3319cf37 100644 --- a/src/backend/test/CMakeLists.txt +++ b/src/backend/test/CMakeLists.txt @@ -42,9 +42,4 @@ target_link_libraries(unit_tests_backend gmock_main ) -target_link_options(unit_tests_backend PRIVATE -static-libgcc -static-libstdc++ -static) -set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") -set_target_properties(unit_tests_backend PROPERTIES LINK_SEARCH_START_STATIC ON) -set_target_properties(unit_tests_backend PROPERTIES LINK_SEARCH_END_STATIC ON) - add_test(unit_tests unit_tests_backend) From 72dee6ba649cb8fe346df380c4a07372530145b3 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sat, 17 Oct 2020 17:53:33 +0200 Subject: [PATCH 4/8] workflows: use new option, try arm32v7 build --- .github/workflows/main.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 84b2f1ea88..65e59ec9db 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -124,7 +124,26 @@ 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 + run: ./build/release/src/unit_tests_runner + - name: test (mavsdk_server) + run: ./build/release/src/backend/test/unit_tests_backend + + alpine-linux-arm32v7: + name: alpine arm32v7 (musl) + runs-on: ubuntu-18.04 + container: arm32v7/alpine + steps: + - name: install tools + run: apk update && apk add build-base cmake git linux-headers libexecinfo-dev + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: configure + 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 From 92c1e152f5d31d0e0bc0b1204108072e4810e819 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sat, 17 Oct 2020 18:21:07 +0200 Subject: [PATCH 5/8] workflows: try to use run-on-arch-action --- .github/workflows/main.yml | 67 ++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 65e59ec9db..c0397f52a8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -132,24 +132,65 @@ jobs: - name: test (mavsdk_server) run: ./build/release/src/backend/test/unit_tests_backend - alpine-linux-arm32v7: - name: alpine arm32v7 (musl) + alpine-linux-qemu: runs-on: ubuntu-18.04 - container: arm32v7/alpine + 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: - - name: install tools - run: apk update && apk add build-base cmake git linux-headers libexecinfo-dev - uses: actions/checkout@v2 with: submodules: recursive - - name: configure - 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 - run: ./build/release/src/unit_tests_runner - - name: test (mavsdk_server) - run: ./build/release/src/backend/test/unit_tests_backend + - 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" + + # 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 + + run: | + cd /root/MAVSDK + 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 + + - name: Check the artifact + run: | + file "${PWD}/install/bin/mavsdk_server" px4-sitl-older: name: PX4 SITL ${{ matrix.px4_version }} (ubuntu-18.04) From 01910928795a63f8678647917a4239edf8dc3672 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sun, 18 Oct 2020 21:15:15 +0200 Subject: [PATCH 6/8] core: relax test accuracy for aarch64 build --- src/core/geometry_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); +} From 29b29de6f320682c4fe59f603d82b854474aa53b Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sun, 18 Oct 2020 21:23:18 +0200 Subject: [PATCH 7/8] workflows: try ccache for alpine/musl builds --- .github/workflows/main.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c0397f52a8..3911c8c630 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -150,6 +150,21 @@ jobs: - 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 @@ -163,6 +178,7 @@ jobs: # 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 @@ -179,14 +195,19 @@ jobs: # no secrets are present in the container state or logs. install: | apk update - apk add build-base cmake git linux-headers libexecinfo-dev + 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: | From 5eff7c199a76521f2de1f8a7f84a2c75f1dcf325 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Mon, 19 Oct 2020 08:41:20 +0200 Subject: [PATCH 8/8] workflows: add artefact publishing --- .github/workflows/main.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3911c8c630..35a0b236af 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -212,6 +212,15 @@ jobs: - 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)