Skip to content

Commit

Permalink
add cross-compilation test for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Oct 25, 2024
1 parent b439a16 commit df5c424
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 39 deletions.
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[target.x86_64-unknown-linux-musl]
rustflags = "-Ctarget-feature=-crt-static"
linker = "x86_64-linux-musl-gcc"

[target.aarch64-unknown-linux-musl]
rustflags = "-Ctarget-feature=-crt-static"
Expand Down
67 changes: 66 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
!target/release/.*
!target/release/*.d
cross-compile-mac:
cross-compile-mac-os:
name: Cross compile on macOS-latest
runs-on: macOS-latest
strategy:
Expand Down Expand Up @@ -163,6 +163,71 @@ jobs:
cmake -DCMAKE_TOOLCHAIN_FILE="../ci/toolchains/TC-x86_64-pc-windows-gnu.cmake" -DZENOHC_BUILD_WITH_SHARED_MEMORY=ON -DZENOHC_BUILD_WITH_UNSTABLE_API=ON ..
cmake --build . --target examples
cross-compile-ubuntu:
name: Cross compile on ubuntu-latest
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get install -y musl-tools
sudo apt-get install -y gcc-arm-linux-gnueabi
sudo apt-get install -y g++-arm-linux-gnueabi
sudo apt-get install -y mingw-w64
sudo apt-get install -y gcc-aarch64-linux-gnu
sudo apt-get install -y g++-aarch64-linux-gnu
wget https://musl.cc/aarch64-linux-musl-cross.tgz
tar xvfz aarch64-linux-musl-cross.tgz
echo "$(readlink -f aarch64-linux-musl-cross)/bin" >> "$GITHUB_PATH"
wget https://musl.cc/x86_64-linux-musl-cross.tgz
tar xvfz x86_64-linux-musl-cross.tgz
echo "$(readlink -f x86_64-linux-musl-cross)/bin" >> "$GITHUB_PATH"
- name: Install rust toolchains
run: |
rustup target add arm-unknown-linux-gnueabi
rustup target add x86_64-pc-windows-gnu
rustup target add aarch64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-musl
rustup target add x86_64-unknown-linux-musl
- name: Cross compile for arm-unknown-linux-gnueabi
run: |
rm -rf ./build
mkdir -p ./build && cd ./build
cmake -DCMAKE_TOOLCHAIN_FILE="../ci/toolchains/TC-arm-unknown-linux-gnueabi.cmake" -DZENOHC_BUILD_WITH_SHARED_MEMORY=ON -DZENOHC_BUILD_WITH_UNSTABLE_API=ON ..
cmake --build . --target examples
- name: Cross compile for aarch64-unknown-linux-gnu
run: |
rm -rf ./build
mkdir -p ./build && cd ./build
cmake -DCMAKE_TOOLCHAIN_FILE="../ci/toolchains/TC-aarch64-unknown-linux-gnu.cmake" -DZENOHC_BUILD_WITH_SHARED_MEMORY=ON -DZENOHC_BUILD_WITH_UNSTABLE_API=ON ..
cmake --build . --target examples
- name: Cross compile for aarch64-unknown-linux-musl
run: |
rm -rf ./build
mkdir -p ./build && cd ./build
cmake -DCMAKE_TOOLCHAIN_FILE="../ci/toolchains/TC-aarch64-unknown-linux-musl.cmake" -DZENOHC_BUILD_WITH_SHARED_MEMORY=ON -DZENOHC_BUILD_WITH_UNSTABLE_API=ON ..
cmake --build . --target examples
- name: Cross compile for x86_64-unknown-linux-musl
run: |
rm -rf ./build
mkdir -p ./build && cd ./build
cmake -DCMAKE_TOOLCHAIN_FILE="../ci/toolchains/TC-x86_64-unknown-linux-musl.cmake" -DZENOHC_BUILD_WITH_SHARED_MEMORY=ON -DZENOHC_BUILD_WITH_UNSTABLE_API=ON ..
cmake --build . --target examples
- name: Cross compile for x86_64-pc-windows-gnu
run: |
rm -rf ./build
mkdir -p ./build && cd ./build
cmake -DCMAKE_TOOLCHAIN_FILE="../ci/toolchains/TC-x86_64-pc-windows-gnu.cmake" -DZENOHC_BUILD_WITH_SHARED_MEMORY=ON -DZENOHC_BUILD_WITH_UNSTABLE_API=ON ..
cmake --build . --target examples
# NOTE: In GitHub repository settings, the "Require status checks to pass
# before merging" branch protection rule ensures that commits are only merged
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ endif()
# Components included only if project is the root project
#
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
include(cmake/cross_build_check.cmake)
add_subdirectory(install)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${cargo_binary_dir}/tests)
add_subdirectory(tests)
Expand Down
5 changes: 5 additions & 0 deletions ci/toolchains/TC-aarch64-unknown-linux-gnu.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(ZENOHC_CUSTOM_TARGET aarch64-unknown-linux-gnu)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
5 changes: 5 additions & 0 deletions ci/toolchains/TC-aarch64-unknown-linux-musl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(ZENOHC_CUSTOM_TARGET aarch64-unknown-linux-musl)
set(CMAKE_C_COMPILER aarch64-linux-musl-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-musl-g++)
5 changes: 5 additions & 0 deletions ci/toolchains/TC-arm-unknown-linux-gnueabi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(ZENOHC_CUSTOM_TARGET arm-unknown-linux-gnueabi)
set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++)
2 changes: 1 addition & 1 deletion ci/toolchains/TC-armv7-unknown-linux-gnueabihf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv7)
set(ZENOHC_CUSTOM_TARGET armv7-unknown-linux-gnueabihf)
set(CMAKE_C_COMPILER armv7-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER armv7-linux-gnueabihf-g++)
set(CMAKE_CXX_COMPILER armv7-linux-gnueabihf-g++)
2 changes: 1 addition & 1 deletion ci/toolchains/TC-x86_64-pc-windows-gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(ZENOHC_CUSTOM_TARGET x86_64-pc-windows-gnu)
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
2 changes: 1 addition & 1 deletion ci/toolchains/TC-x86_64-unknown-linux-gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(ZENOHC_CUSTOM_TARGET x86_64-unknown-linux-gnu)
set(CMAKE_C_COMPILER x86_64-unknown-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER x86_64-unknown-linux-gnu-g++)
set(CMAKE_CXX_COMPILER x86_64-unknown-linux-gnu-g++)
5 changes: 5 additions & 0 deletions ci/toolchains/TC-x86_64-unknown-linux-musl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(ZENOHC_CUSTOM_TARGET x86_64-unknown-linux-musl)
set(CMAKE_C_COMPILER x86_64-linux-musl-gcc)
set(CMAKE_CXX_COMPILER x86_64-linux-musl-g++)
34 changes: 0 additions & 34 deletions cmake/cross_build_check.cmake

This file was deleted.

0 comments on commit df5c424

Please sign in to comment.