diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98ade7358..f65c528fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -167,7 +167,9 @@ jobs: run: | sudo apt-get install -y musl-tools sudo apt-get install -y gcc-arm-linux-gnueabi + sudo apt-get install -y gcc-arm-linux-gnueabihf sudo apt-get install -y g++-arm-linux-gnueabi + sudo apt-get install -y g++-arm-linux-gnueabihf 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 @@ -181,6 +183,7 @@ jobs: - name: Install rust toolchains run: | rustup target add arm-unknown-linux-gnueabi + rustup target add arm-unknown-linux-gnueabihf rustup target add x86_64-pc-windows-gnu rustup target add aarch64-unknown-linux-gnu rustup target add aarch64-unknown-linux-musl @@ -193,6 +196,13 @@ jobs: 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 arm-unknown-linux-gnueabihf + run: | + rm -rf ./build + mkdir -p ./build && cd ./build + cmake -DCMAKE_TOOLCHAIN_FILE="../ci/toolchains/TC-arm-unknown-linux-gnueabihf.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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 86b21b5ea..4667eac35 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -72,33 +72,142 @@ jobs: GIT_USER_NAME: eclipse-zenoh-bot GIT_USER_EMAIL: eclipse-zenoh-bot@users.noreply.github.com - build-debian: - name: Build Debian packages + build: + name: Build packages + runs-on: ${{ matrix.build.os }} + strategy: + fail-fast: false + matrix: + build: + - { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04 } + - { target: x86_64-unknown-linux-musl, os: ubuntu-20.04 } + - { target: arm-unknown-linux-gnueabi, os: ubuntu-20.04 } + - { target: arm-unknown-linux-gnueabihf, os: ubuntu-20.04 } + - { target: armv7-unknown-linux-gnueabihf, os: macos-14 } + - { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04 } + - { target: aarch64-unknown-linux-musl, os: ubuntu-20.04 } + - { target: x86_64-apple-darwin, os: macos-14 } + - { target: aarch64-apple-darwin, os: macos-14 } + - { target: x86_64-pc-windows-msvc, os: windows-2019 } + - { target: x86_64-pc-windows-gnu, os: ubuntu-20.04 } needs: tag - uses: eclipse-zenoh/ci/.github/workflows/build-crates-debian.yml@main - with: - repo: ${{ github.repository }} - version: ${{ needs.tag.outputs.version }} - branch: ${{ needs.tag.outputs.branch }} - secrets: inherit + steps: + - name: Checkout this repository + uses: actions/checkout@v4 + with: + ref: ${{ needs.tag.outputs.branch }} + token: ${{ secrets.BOT_TOKEN_WORKFLOW }} - build-standalone: - name: Build executables and libraries - needs: tag - uses: eclipse-zenoh/ci/.github/workflows/build-crates-standalone.yml@main - with: - repo: ${{ github.repository }} - version: ${{ needs.tag.outputs.version }} - branch: ${{ needs.tag.outputs.branch }} - artifact-patterns: | - ^libzenohc\.(dylib|so)$ - ^zenohc\.dll$ - ^include$ - secrets: inherit + - name: Add rust toolchain + run: | + rustup target add ${{ matrix.build.target }} + + - name: Install build deps + if: ${{ matrix.build.target == 'x86_64-unknown-linux-musl'}} + run: | + sudo apt-get install -y musl-tools + 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 build deps + if: ${{ matrix.build.target == 'arm-unknown-linux-gnueabi'}} + run: sudo apt-get install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi + + - name: Install build deps + if: ${{ matrix.build.target == 'arm-unknown-linux-gnueabihf'}} + run: sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf + + - name: Install build deps + if: ${{ matrix.build.target == 'armv7-unknown-linux-gnueabihf'}} + run: | + brew install -f messense/macos-cross-toolchains/armv7-unknown-linux-gnueabihf + brew install dpkg + brew install rpm + + - name: Install build deps + if: ${{ matrix.build.target == 'aarch64-unknown-linux-gnu'}} + run: sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + + - name: Install build deps + if: ${{ matrix.build.target == 'aarch64-unknown-linux-musl'}} + run: | + 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" + + - name: Install build deps + if: ${{ matrix.build.target == 'x86_64-pc-windows-gnu'}} + run: | + sudo apt-get install -y mingw-w64 + + - name: Compute package name + id: compute-package-name + shell: bash + run: | + if [[ "${{ matrix.build.target }}" =~ "armv7" ]]; then + echo "value=zenohc-armv7" >> $GITHUB_OUTPUT + elif [[ "${{ matrix.build.target }}" =~ "musl" ]]; then + echo "value=zenohc-musl" >> $GITHUB_OUTPUT + else + echo "value=zenohc" >> $GITHUB_OUTPUT + fi + + - name: Build standalone + id: build + shell: bash + run: | + toolchain_file=$(readlink -f ci/toolchains/TC-${{ matrix.build.target }}.cmake) + mkdir -p build && cd build + cmake .. -DCPACK_PACKAGE_NAME=${{ steps.compute-package-name.outputs.value }} -DZENOHC_CUSTOM_TARGET=${{ matrix.build.target }} -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DZENOHC_BUILD_WITH_UNSTABLE_API=ON -DZENOHC_BUILD_WITH_SHARED_MEMORY=ON + cmake --build . --config Release + cpack -C Release -G ZIP + + - name: Build distro packages (DEB/RPM) + id: build-distro-packages + if: ${{ contains(matrix.build.target, 'linux') }} + run: | + cd build + cpack -G DEB + cpack -G RPM + + - name: Prepare standalone archives + shell: bash + run: | + zip_filename=$(readlink -f ./build/packages/*.zip) + mv ${zip_filename} zenoh-c-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-standalone.zip + + - name: Zip deb/rpm archives + shell: bash + if: ${{ contains(matrix.build.target, 'linux') }} + run: | + zip -9 -j libzenohc-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-debian.zip ./build/packages/*.deb + zip -9 -j libzenohc-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-rpm.zip ./build/packages/*.rpm + + - name: Upload standalone archive + uses: actions/upload-artifact@v4 + with: + # Publish the artifact with zenoh-c (repo name) so it can be used by homebrew action + name: zenoh-c-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-standalone.zip + path: zenoh-c-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-standalone.zip + + - name: Upload DEB archive + if: ${{ contains(matrix.build.target, 'linux') }} + uses: actions/upload-artifact@v4 + with: + name: libzenohc-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-debian.zip + path: libzenohc-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-debian.zip + + - name: Upload RPM archive + if: ${{ contains(matrix.build.target, 'linux') }} + uses: actions/upload-artifact@v4 + with: + name: libzenohc-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-rpm.zip + path: libzenohc-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-rpm.zip debian: name: Publish Debian packages - needs: [tag, build-debian] + needs: [tag, build] uses: eclipse-zenoh/ci/.github/workflows/release-crates-debian.yml@main with: no-build: true @@ -111,7 +220,7 @@ jobs: homebrew: name: Publish Homebrew formulae - needs: [tag, build-standalone] + needs: [tag, build] uses: eclipse-zenoh/ci/.github/workflows/release-crates-homebrew.yml@main with: no-build: true @@ -128,7 +237,7 @@ jobs: eclipse: name: Publish artifacts to Eclipse downloads - needs: [tag, build-standalone] + needs: [tag, build] uses: eclipse-zenoh/ci/.github/workflows/release-crates-eclipse.yml@main with: no-build: true @@ -145,7 +254,7 @@ jobs: github: name: Publish artifacts to GitHub Releases - needs: [tag, build-standalone] + needs: [tag, build] uses: eclipse-zenoh/ci/.github/workflows/release-crates-github.yml@main with: no-build: true diff --git a/ci/toolchains/TC-aarch64-apple-darwin.cmake b/ci/toolchains/TC-aarch64-apple-darwin.cmake new file mode 100644 index 000000000..be899bf0c --- /dev/null +++ b/ci/toolchains/TC-aarch64-apple-darwin.cmake @@ -0,0 +1,3 @@ +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(ZENOHC_CUSTOM_TARGET aarch64-apple-darwin) \ No newline at end of file diff --git a/ci/toolchains/TC-aarch64-unknown-linux-gnu.cmake b/ci/toolchains/TC-aarch64-unknown-linux-gnu.cmake index 8f1a6b36c..2d17d7f93 100644 --- a/ci/toolchains/TC-aarch64-unknown-linux-gnu.cmake +++ b/ci/toolchains/TC-aarch64-unknown-linux-gnu.cmake @@ -1,5 +1,6 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(DEBARCH arm64) set(ZENOHC_CUSTOM_TARGET aarch64-unknown-linux-gnu) set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) -set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) +set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) \ No newline at end of file diff --git a/ci/toolchains/TC-aarch64-unknown-linux-musl.cmake b/ci/toolchains/TC-aarch64-unknown-linux-musl.cmake index 0793da1ab..5cbf91701 100644 --- a/ci/toolchains/TC-aarch64-unknown-linux-musl.cmake +++ b/ci/toolchains/TC-aarch64-unknown-linux-musl.cmake @@ -1,5 +1,6 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(DEBARCH arm64) set(ZENOHC_CUSTOM_TARGET aarch64-unknown-linux-musl) set(CMAKE_C_COMPILER aarch64-linux-musl-gcc) -set(CMAKE_CXX_COMPILER aarch64-linux-musl-g++) +set(CMAKE_CXX_COMPILER aarch64-linux-musl-g++) \ No newline at end of file diff --git a/ci/toolchains/TC-arm-unknown-linux-gnueabi.cmake b/ci/toolchains/TC-arm-unknown-linux-gnueabi.cmake index 8b340ce22..24ce00d67 100644 --- a/ci/toolchains/TC-arm-unknown-linux-gnueabi.cmake +++ b/ci/toolchains/TC-arm-unknown-linux-gnueabi.cmake @@ -1,5 +1,6 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) +set(DEBARCH armel) set(ZENOHC_CUSTOM_TARGET arm-unknown-linux-gnueabi) set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc) -set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++) +set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++) \ No newline at end of file diff --git a/ci/toolchains/TC-arm-unknown-linux-gnueabihf.cmake b/ci/toolchains/TC-arm-unknown-linux-gnueabihf.cmake new file mode 100644 index 000000000..e986a0f19 --- /dev/null +++ b/ci/toolchains/TC-arm-unknown-linux-gnueabihf.cmake @@ -0,0 +1,6 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR armhf) +set(DEBARCH armhf) +set(ZENOHC_CUSTOM_TARGET arm-unknown-linux-gnueabihf) +set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) +set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) \ No newline at end of file diff --git a/ci/toolchains/TC-armv7-unknown-linux-gnueabihf.cmake b/ci/toolchains/TC-armv7-unknown-linux-gnueabihf.cmake index 83362af52..62180b901 100644 --- a/ci/toolchains/TC-armv7-unknown-linux-gnueabihf.cmake +++ b/ci/toolchains/TC-armv7-unknown-linux-gnueabihf.cmake @@ -1,5 +1,6 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR armv7) +set(DEBARCH armhf) 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++) \ No newline at end of file diff --git a/ci/toolchains/TC-x86_64-apple-darwin.cmake b/ci/toolchains/TC-x86_64-apple-darwin.cmake new file mode 100644 index 000000000..647d1520b --- /dev/null +++ b/ci/toolchains/TC-x86_64-apple-darwin.cmake @@ -0,0 +1,3 @@ +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_PROCESSOR x86_64) +set(ZENOHC_CUSTOM_TARGET x86_64-apple-darwin) \ No newline at end of file diff --git a/ci/toolchains/TC-x86_64-pc-windows-gnu.cmake b/ci/toolchains/TC-x86_64-pc-windows-gnu.cmake index 9be83069d..2afb5508d 100644 --- a/ci/toolchains/TC-x86_64-pc-windows-gnu.cmake +++ b/ci/toolchains/TC-x86_64-pc-windows-gnu.cmake @@ -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++) \ No newline at end of file diff --git a/ci/toolchains/TC-x86_64-pc-windows-msvc.cmake b/ci/toolchains/TC-x86_64-pc-windows-msvc.cmake new file mode 100644 index 000000000..aa076adef --- /dev/null +++ b/ci/toolchains/TC-x86_64-pc-windows-msvc.cmake @@ -0,0 +1,3 @@ +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) +set(ZENOHC_CUSTOM_TARGET x86_64-pc-windows-msvc) \ No newline at end of file diff --git a/ci/toolchains/TC-x86_64-unknown-linux-gnu.cmake b/ci/toolchains/TC-x86_64-unknown-linux-gnu.cmake index ce56df0f3..73a629c49 100644 --- a/ci/toolchains/TC-x86_64-unknown-linux-gnu.cmake +++ b/ci/toolchains/TC-x86_64-unknown-linux-gnu.cmake @@ -1,5 +1,6 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR x86_64) +set(DEBARCH amd64) 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_C_COMPILER x86_64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER x86_64-linux-gnu-g++) \ No newline at end of file diff --git a/ci/toolchains/TC-x86_64-unknown-linux-musl.cmake b/ci/toolchains/TC-x86_64-unknown-linux-musl.cmake index f4904a4ae..f84271f73 100644 --- a/ci/toolchains/TC-x86_64-unknown-linux-musl.cmake +++ b/ci/toolchains/TC-x86_64-unknown-linux-musl.cmake @@ -1,5 +1,6 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR x86_64) +set(DEBARCH amd64) 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++) +set(CMAKE_CXX_COMPILER x86_64-linux-musl-g++) \ No newline at end of file diff --git a/install/CMakeLists.txt b/install/CMakeLists.txt index 7278eb1db..b770e3c22 100644 --- a/install/CMakeLists.txt +++ b/install/CMakeLists.txt @@ -39,7 +39,7 @@ function(install_zenohc_lib configurations property_postfix package_name) get_target_property(staticlib_path zenohc::static IMPORTED_LOCATION_${property_postfix}) get_target_property(NATIVE_STATIC_LIBS zenohc::static INTERFACE_LINK_LIBRARIES) get_filename_component(STATICLIB ${staticlib_path} NAME) - install(FILES ${staticlib_path} DESTINATION ${CMAKE_INSTALL_LIBDIR} CONFIGURATIONS ${configurations} COMPONENT lib) + install(FILES ${staticlib_path} DESTINATION ${CMAKE_INSTALL_LIBDIR} CONFIGURATIONS ${configurations} COMPONENT dev) set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${package_name}") @@ -98,18 +98,17 @@ set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) set(CPACK_COMPONENT_LIB_DESCRIPTION "The C client library for Eclipse zenoh") -set(CPACK_COMPONENT_DEV_DESCRIPTION "${CPACK_COMPONENT_LIB_DESCRIPTION} - cmake files") +set(CPACK_COMPONENT_DEV_DESCRIPTION "${CPACK_COMPONENT_LIB_DESCRIPTION} - zenoh-c static lib and cmake files") set(CPACK_COMPONENT_HEADERS_DESCRIPTION "${CPACK_COMPONENT_LIB_DESCRIPTION} - header files") set(CPACK_COMPONENT_LIB_GROUP "lib") set(CPACK_COMPONENT_HEADERS_GROUP "dev") set(CPACK_COMPONENT_DEV_GROUP "dev") set(CPACK_COMPONENT_HEADERS_DEPENDS lib) set(CPACK_COMPONENT_DEV_DEPENDS lib) +set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) set(CPACK_GENERATOR ZIP) -# set package name to format -. -# platform name doesn't matter for header-only library -set(CPACK_PACKAGE_NAME zenohc) +set(CPACK_CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}) if(NOT CPACK_PACKAGE_VERSION) set(SEM_VER "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") @@ -124,7 +123,16 @@ endif() set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") -set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}) +if(NOT DEBARCH) + set(DEBARCH ${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_NAME}) +endif() +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DEBARCH}) + +if(NOT RPMARCH) + set(RPMARCH ${CMAKE_SYSTEM_PROCESSOR}) +endif() +set(CPACK_RPM_PACKAGE_ARCHITECTURE ${RPMARCH}) + set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cpack_project_config.cmake") include(CPack) diff --git a/install/cpack_project_config.cmake b/install/cpack_project_config.cmake index 51c220aab..70bf7b9a1 100644 --- a/install/cpack_project_config.cmake +++ b/install/cpack_project_config.cmake @@ -1,6 +1,6 @@ +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_CMAKE_SYSTEM_PROCESSOR}") if(CPACK_GENERATOR MATCHES "DEB") # DEB package - message(STATUS "Configure DEB packaging for Linux ${DEBARCH}") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "ZettaScale Zenoh Team, ") set(CPACK_DEB_COMPONENT_INSTALL ON) set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) @@ -14,11 +14,6 @@ if(CPACK_GENERATOR MATCHES "RPM") # RPM package # rpmbuild should be installed # apt install rpm - if(NOT RPMARCH) - set(RPMARCH ${CMAKE_SYSTEM_PROCESSOR}) - endif() - message(STATUS "Configure RPM packaging for Linux ${RPMARCH}") - set(CPACK_RPM_PACKAGE_ARCHITECTURE ${RPMARCH}) set(CPACK_RPM_COMPONENT_INSTALL ON) set(CPACK_RPM_FILE_NAME RPM-DEFAULT) set(CPACK_RPM_LIB_PACKAGE_NAME ${CPACK_PACKAGE_NAME}) # avoid "-lib" suffix for "lib" package