Skip to content

Commit

Permalink
Merge pull request #1223 from mavlink/pr-musl
Browse files Browse the repository at this point in the history
backend: build statically with musl
  • Loading branch information
julianoes authored Oct 19, 2020
2 parents d3e0b95 + 5eff7c1 commit 6535d3f
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 4 deletions.
92 changes: 91 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,104 @@ 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-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/[email protected]
with:
path: .ccache
key: ${{ matrix.arch }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
restore-keys: |
${{ matrix.arch }}-ccache-
- uses: uraimo/[email protected]
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
Expand Down
7 changes: 7 additions & 0 deletions src/backend/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
6 changes: 3 additions & 3 deletions src/core/geometry_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
EXPECT_NEAR(location.north_m, location_again.north_m, 1e-8);
EXPECT_NEAR(location.east_m, location_again.east_m, 1e-8);
}

0 comments on commit 6535d3f

Please sign in to comment.