diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 0311bc3..af300fc 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -33,42 +33,70 @@ jobs: - os: ubuntu-24.04 c_compiler: gcc cpp_compiler: g++ + arm_c_compiler: aarch64-linux-gnu-gcc + arm_cpp_compiler: aarch64-linux-gnu-g++ - os: ubuntu-24.04 c_compiler: clang cpp_compiler: clang++ + arm_c_compiler: clang + arm_cpp_compiler: clang++ - os: ubuntu-22.04 c_compiler: gcc cpp_compiler: g++ + arm_c_compiler: aarch64-linux-gnu-gcc + arm_cpp_compiler: aarch64-linux-gnu-g++ - os: ubuntu-22.04 c_compiler: clang cpp_compiler: clang++ + arm_c_compiler: clang + arm_cpp_compiler: clang++ - os: ubuntu-20.04 c_compiler: gcc cpp_compiler: g++ + arm_c_compiler: aarch64-linux-gnu-gcc + arm_cpp_compiler: aarch64-linux-gnu-g++ - os: ubuntu-20.04 c_compiler: clang cpp_compiler: clang++ + arm_c_compiler: aarch64-linux-gnu-gcc + arm_cpp_compiler: aarch64-linux-gnu-g++ - os: windows-latest steps: - uses: actions/checkout@v4 - - - name: Build using CMake on Linux + + - name: Install cross compiler if: ${{ Contains(matrix.os, 'ubuntu') }} - run: > - ./build_samples.sh - --no-tests - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + run: | + sudo apt-get update + sudo apt-get install -y g++-aarch64-linux-gnu gcc-aarch64-linux-gnu libstdc++6-arm64-cross linux-libc-dev-arm64-cross - name: Setup vcpkg uses: lukka/run-vcpkg@v11 - if: ${{ Contains(matrix.os, 'windows') }} id: runvcpkg with: # The vcpkg.json file, which will be part of cache key computation. vcpkgJsonGlob: '**/src/vcpkg.json' + - name: Build using CMake on Linux for amd64 + if: ${{ Contains(matrix.os, 'ubuntu') }} + run: > + ./build_samples_x64.sh + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + + - name: Cleanup Build + if: ${{ Contains(matrix.os, 'ubuntu') }} + run: > + rm -r ../nx-lyve-cloud-plugin-build/ + + - name: Build using CMake on Linux for arm64 + if: ${{ Contains(matrix.os, 'ubuntu') }} + run: > + ./build_samples_arm64.sh + -DCMAKE_CXX_COMPILER=${{ matrix.arm_cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.arm_c_compiler }} + - name: Build using CMake on Windows shell: powershell if: ${{ Contains(matrix.os, 'windows') }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ceea186..38e2fbb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,32 +14,70 @@ jobs: - os: ubuntu-24.04 c_compiler: gcc cpp_compiler: g++ + arm_c_compiler: aarch64-linux-gnu-gcc + arm_cpp_compiler: aarch64-linux-gnu-g++ - os: ubuntu-22.04 c_compiler: gcc cpp_compiler: g++ + arm_c_compiler: aarch64-linux-gnu-gcc + arm_cpp_compiler: aarch64-linux-gnu-g++ - os: ubuntu-20.04 c_compiler: gcc cpp_compiler: g++ + arm_c_compiler: aarch64-linux-gnu-gcc + arm_cpp_compiler: aarch64-linux-gnu-g++ - os: windows-latest steps: - name: Checkout code uses: actions/checkout@v4 - - name: Run build script for Linux + - name: Install cross compiler if: ${{ Contains(matrix.os, 'ubuntu') }} - run: > - ./build_samples.sh - --no-tests - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + run: | + sudo apt-get update + sudo apt-get install -y g++-aarch64-linux-gnu gcc-aarch64-linux-gnu - name: Setup vcpkg uses: lukka/run-vcpkg@v11 - if: ${{ Contains(matrix.os, 'windows') }} id: runvcpkg with: # The vcpkg.json file, which will be part of cache key computation. vcpkgJsonGlob: '**/src/vcpkg.json' + + - name: Run build script for Linux x64 + if: ${{ Contains(matrix.os, 'ubuntu') }} + run: > + ./build_samples_x64.sh + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + + - name: Package Artifacts Linux x64 + if: ${{ Contains(matrix.os, 'ubuntu') }} + run: | + mkdir nx-lyve-cloud-plugin-${{ matrix.os }}_x64 + mv ../nx-lyve-cloud-plugin-build/cloudfuse_plugin/*.so nx-lyve-cloud-plugin-${{ matrix.os }}_x64/cloudfuse_plugin.so + cp ./setup_fuse_allow_other.sh nx-lyve-cloud-plugin-${{ matrix.os }}_x64/ + zip -r nx-lyve-cloud-plugin-${{ matrix.os }}_x64.zip nx-lyve-cloud-plugin-${{ matrix.os }}_x64 + + - name: Cleanup Build + if: ${{ Contains(matrix.os, 'ubuntu') }} + run: > + rm -r ../nx-lyve-cloud-plugin-build/ + + - name: Run build script for Linux arm64 + if: ${{ Contains(matrix.os, 'ubuntu') }} + run: > + ./build_samples_arm64.sh + -DCMAKE_CXX_COMPILER=${{ matrix.arm_cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.arm_c_compiler }} + + - name: Package Artifacts Linux arm64 + if: ${{ Contains(matrix.os, 'ubuntu') }} + run: | + mkdir nx-lyve-cloud-plugin-${{ matrix.os }}_arm64 + mv ../nx-lyve-cloud-plugin-build/cloudfuse_plugin/*.so nx-lyve-cloud-plugin-${{ matrix.os }}_arm64/cloudfuse_plugin.so + cp ./setup_fuse_allow_other.sh nx-lyve-cloud-plugin-${{ matrix.os }}_arm64/ + zip -r nx-lyve-cloud-plugin-${{ matrix.os }}_arm64.zip nx-lyve-cloud-plugin-${{ matrix.os }}_arm64 - name: Run build script for Windows shell: powershell @@ -48,14 +86,6 @@ jobs: .\build_samples.bat --no-tests - - name: Package Artifacts Linux - if: ${{ Contains(matrix.os, 'ubuntu') }} - run: | - mkdir nx-lyve-cloud-plugin-${{ matrix.os }} - mv ../nx-lyve-cloud-plugin-build/cloudfuse_plugin/*.so nx-lyve-cloud-plugin-${{ matrix.os }}/cloudfuse_plugin.so - cp ./setup_fuse_allow_other.sh nx-lyve-cloud-plugin-${{ matrix.os }}/ - zip -r nx-lyve-cloud-plugin-${{ matrix.os }}.zip nx-lyve-cloud-plugin-${{ matrix.os }} - - name: Package Artifacts Windows shell: powershell if: ${{ Contains(matrix.os, 'windows') }} @@ -64,12 +94,20 @@ jobs: mv ..\nx-lyve-cloud-plugin-build\cloudfuse_plugin\Release\cloudfuse_plugin.dll nx-lyve-cloud-plugin-windows/cloudfuse_plugin.dll Compress-Archive nx-lyve-cloud-plugin-windows nx-lyve-cloud-plugin-windows.zip - - name: Archive production artifacts from Ubuntu + - name: Archive production artifacts from Ubuntu x64 + if: ${{ Contains(matrix.os, 'ubuntu') }} + uses: actions/upload-artifact@v4 + with: + name: nx-lyve-cloud-plugin-${{ matrix.os }}_x64 + path: nx-lyve-cloud-plugin-${{ matrix.os }}_x64.zip + if-no-files-found: error + + - name: Archive production artifacts from Ubuntu arm64 if: ${{ Contains(matrix.os, 'ubuntu') }} uses: actions/upload-artifact@v4 with: - name: nx-lyve-cloud-plugin-${{ matrix.os }} - path: nx-lyve-cloud-plugin-${{ matrix.os }}.zip + name: nx-lyve-cloud-plugin-${{ matrix.os }}_arm64 + path: nx-lyve-cloud-plugin-${{ matrix.os }}_arm64.zip if-no-files-found: error - name: Archive production artifacts from Windows @@ -94,7 +132,10 @@ jobs: uses: softprops/action-gh-release@v2 with: files: | - nx-lyve-cloud-plugin-ubuntu-24.04/* - nx-lyve-cloud-plugin-ubuntu-22.04/* - nx-lyve-cloud-plugin-ubuntu-20.04/* + nx-lyve-cloud-plugin-ubuntu-24.04_x64/* + nx-lyve-cloud-plugin-ubuntu-22.04_x64/* + nx-lyve-cloud-plugin-ubuntu-20.04_x64/* + nx-lyve-cloud-plugin-ubuntu-24.04_arm64/* + nx-lyve-cloud-plugin-ubuntu-22.04_arm64/* + nx-lyve-cloud-plugin-ubuntu-20.04_arm64/* nx-lyve-cloud-plugin-windows/* diff --git a/build_samples_arm64.sh b/build_samples_arm64.sh index bdf5ec9..b82e30e 100755 --- a/build_samples_arm64.sh +++ b/build_samples_arm64.sh @@ -12,5 +12,6 @@ set -x #< Log each command. "$BASE_DIR"/build_samples.sh \ --no-tests \ - -DCMAKE_TOOLCHAIN_FILE=$BASE_DIR/toolchain_arm64.cmake \ + -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT"/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=arm64-linux \ + -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$BASE_DIR/toolchain_arm64.cmake" \ "$@" diff --git a/build_samples_x64.sh b/build_samples_x64.sh new file mode 100755 index 0000000..2cb78ff --- /dev/null +++ b/build_samples_x64.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +## Copyright © 2024 Seagate Technology LLC and/or its Affiliates +## Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/ + +set -e #< Exit on error. +set -u #< Prohibit undefined variables. + +BASE_DIR=$(readlink -f "$(dirname "$0")") #< Absolute path to the current dir. + +set -x #< Log each command. + +"$BASE_DIR"/build_samples.sh \ + --no-tests \ + -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT"/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux \ + -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$BASE_DIR/toolchain_x64.cmake" \ + "$@" diff --git a/toolchain_arm64.cmake b/toolchain_arm64.cmake index 0e07242..4a3fb79 100644 --- a/toolchain_arm64.cmake +++ b/toolchain_arm64.cmake @@ -1,8 +1,20 @@ ## Copyright © 2024 Seagate Technology LLC and/or its Affiliates ## Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/ -set(CMAKE_C_COMPILER "/usr/bin/aarch64-linux-gnu-gcc") -set(CMAKE_CXX_COMPILER "/usr/bin/aarch64-linux-gnu-g++") +# Clang supports cross compiling, but needs to specify the target to compile to +if(CMAKE_C_COMPILER MATCHES "clang") + set(CMAKE_C_FLAGS "--target=aarch64-linux-gnu") + set(CMAKE_CXX_FLAGS "--target=aarch64-linux-gnu") +endif() + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(CMAKE_CROSSCOMPILING TRUE) + +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CMAKE_SYSTEM_NAME Linux) # This is required by FindThreads CMake module. set(THREADS_PTHREAD_ARG "2" CACHE STRING "" FORCE) diff --git a/toolchain_x64.cmake b/toolchain_x64.cmake new file mode 100644 index 0000000..d80bea7 --- /dev/null +++ b/toolchain_x64.cmake @@ -0,0 +1,10 @@ +## Copyright © 2024 Seagate Technology LLC and/or its Affiliates +## Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/ + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR AMD64) + +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CMAKE_SYSTEM_NAME Linux)