|
| 1 | +--- |
| 2 | +name: Cross Compilation |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - develop |
| 9 | + #- release |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - develop |
| 13 | + #- release |
| 14 | + |
| 15 | +jobs: |
| 16 | + pkvisor: |
| 17 | + name: pktvisor |
| 18 | + runs-on: ubuntu-latest |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - arch: x86_64 |
| 23 | + conan_arch: x86_64 |
| 24 | + toolchain: http://musl.cc/x86_64-linux-musl-cross.tgz |
| 25 | + cc: x86_64-linux-musl-gcc |
| 26 | + cxx: x86_64-linux-musl-g++ |
| 27 | + ldflags: "-static" |
| 28 | + - arch: armv7lh # ARMv7 little-endian hard-float |
| 29 | + conan_arch: armv7hf |
| 30 | + toolchain: http://musl.cc/armv7l-linux-musleabihf-cross.tgz |
| 31 | + cc: armv7l-linux-musleabihf-gcc |
| 32 | + cxx: armv7l-linux-musleabihf-g++ |
| 33 | + - arch: aarch64 |
| 34 | + conan_arch: armv8 |
| 35 | + toolchain: http://musl.cc/aarch64-linux-musl-cross.tgz |
| 36 | + cc: aarch64-linux-musl-gcc |
| 37 | + cxx: aarch64-linux-musl-g++ |
| 38 | + env: |
| 39 | + CC: gcc-10 |
| 40 | + CXX: g++-10 |
| 41 | + CONAN_USER_HOME: "${{github.workspace}}" |
| 42 | + steps: |
| 43 | + - name: Install sccache from cache |
| 44 | + id: cache-sccache |
| 45 | + uses: actions/cache@v2 |
| 46 | + with: |
| 47 | + path: bin/sccache |
| 48 | + key: sccache-v0.2.15 |
| 49 | + - name: Install sccache |
| 50 | + if: steps.cache-sccache.outputs.cache-hit != 'true' |
| 51 | + run: | |
| 52 | + mkdir -p bin |
| 53 | + curl -L https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz | \ |
| 54 | + tar -C bin -xz --strip-components=1 sccache-v0.2.15-x86_64-unknown-linux-musl/sccache |
| 55 | + chmod +x bin/sccache |
| 56 | +
|
| 57 | + - name: Install compiler toolchain from cache |
| 58 | + id: cache-toolchain |
| 59 | + uses: actions/cache@v2 |
| 60 | + with: |
| 61 | + path: toolchain |
| 62 | + key: toolchain-test-${{matrix.toolchain}} |
| 63 | + - name: Install compiler toolchain |
| 64 | + if: steps.cache-toolchain.outputs.cache-hit != 'true' |
| 65 | + run: | |
| 66 | + mkdir -p toolchain |
| 67 | + curl -L "${{matrix.toolchain}}" | tar -C toolchain -xz --strip-components=1 |
| 68 | +
|
| 69 | + - name: Install Conan |
| 70 | + run: pip install --no-cache-dir conan |
| 71 | + - name: Create Conan configuration |
| 72 | + run: | |
| 73 | + # init config |
| 74 | + CONAN_V2_MODE=1 conan config init |
| 75 | + conan config set general.revisions_enabled=1 |
| 76 | + conan remote add ns1labs https://ns1labs.jfrog.io/artifactory/api/conan/ns1labs-conan |
| 77 | + # add custom compiler settings for libc |
| 78 | + python3 -c 'import yaml; p = "${{env.CONAN_USER_HOME}}/.conan/settings.yml"; d = yaml.safe_load(open(p)); d["compiler"]["gcc"]["libc"] = ["None", "glibc", "musl"]; yaml.safe_dump(d, open(p, "w"))' |
| 79 | + - name: Create Conan host profile |
| 80 | + run: | |
| 81 | + cat > "${{env.CONAN_USER_HOME}}/.conan/profiles/host" << "EOF" |
| 82 | + [settings] |
| 83 | + os=Linux |
| 84 | + os_build=Linux |
| 85 | + arch=${{matrix.conan_arch}} |
| 86 | + arch_build=x86_64 |
| 87 | + compiler=gcc |
| 88 | + compiler.version=11 |
| 89 | + compiler.libcxx=libstdc++11 |
| 90 | + compiler.libc=musl |
| 91 | + build_type=Release |
| 92 | + [options] |
| 93 | + pcapplusplus:with_musl=True |
| 94 | + [build_requires] |
| 95 | + [env] |
| 96 | + CC=${{github.workspace}}/toolchain/bin/${{matrix.cc}} |
| 97 | + CXX=${{github.workspace}}/toolchain/bin/${{matrix.cxx}} |
| 98 | + LDFLAGS=${{matrix.ldflags}} |
| 99 | + EOF |
| 100 | +
|
| 101 | + - name: Restore sccache |
| 102 | + uses: actions/cache@v2 |
| 103 | + with: |
| 104 | + path: ~/.cache/sccache |
| 105 | + key: sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-${{github.run_id}} |
| 106 | + restore-keys: | |
| 107 | + sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}- |
| 108 | + sccache-${{matrix.arch}}-${{github.base_ref||github.event.repository.default_branch}}- |
| 109 | +
|
| 110 | + - name: Checkout sources |
| 111 | + uses: actions/checkout@v2 |
| 112 | + with: |
| 113 | + path: src |
| 114 | + - name: Install dependencies |
| 115 | + run: | |
| 116 | + mkdir build |
| 117 | + cd build |
| 118 | + conan install -pr:b default -pr:h host -g virtualenv --build=missing "${{github.workspace}}/src" |
| 119 | + - name: Configure |
| 120 | + run: | |
| 121 | + cd build |
| 122 | + source environment.sh.env |
| 123 | + export CC CXX |
| 124 | + export LDFLAGS=-static |
| 125 | + cmake "${{github.workspace}}/src" \ |
| 126 | + -DCMAKE_BUILD_TYPE=Release \ |
| 127 | + -DCMAKE_C_COMPILER_LAUNCHER="${{github.workspace}}/bin/sccache" -DCMAKE_CXX_COMPILER_LAUNCHER="${{github.workspace}}/bin/sccache" \ |
| 128 | + -DPKTVISOR_CONAN_INIT=OFF -DPKTVISOR_CONAN_BUILD="never" -DPKTVISOR_CONAN_BUILD_PROFILE="default" -DPKTVISOR_CONAN_HOST_PROFILE="host" \ |
| 129 | + -DProtobuf_PROTOC_EXECUTABLE=$(command -v protoc) \ |
| 130 | + -DCORRADE_RC_PROGRAM=$(command -v corrade-rc) \ |
| 131 | + -DCMAKE_CXX_STANDARD_LIBRARIES=-latomic |
| 132 | + - name: Build |
| 133 | + run: | |
| 134 | + cd build |
| 135 | + make -j4 VERBOSE=1 |
| 136 | +
|
| 137 | + - name: Print sccache stats |
| 138 | + run: | |
| 139 | + "${{github.workspace}}/bin/sccache" -s |
| 140 | +
|
| 141 | + - name: Upload pktvisord |
| 142 | + uses: actions/upload-artifact@v2 |
| 143 | + with: |
| 144 | + name: pktvisord-linux-${{matrix.arch}}-static |
| 145 | + path: build/bin/pktvisord |
| 146 | + retention-days: 7 |
| 147 | + |
| 148 | + - name: Upload pktvisor-reader |
| 149 | + uses: actions/upload-artifact@v2 |
| 150 | + with: |
| 151 | + name: pktvisor-reader-linux-${{matrix.arch}}-static |
| 152 | + path: build/bin/pktvisor-reader |
| 153 | + retention-days: 7 |
| 154 | + |
| 155 | + pkvisor-cli: |
| 156 | + name: pktvisor-cli |
| 157 | + runs-on: ubuntu-latest |
| 158 | + strategy: |
| 159 | + matrix: |
| 160 | + os: [linux, macos] |
| 161 | + arch: [x86_64, armv7lh, aarch64] |
| 162 | + exclude: |
| 163 | + - os: macos |
| 164 | + arch: armv7lh |
| 165 | + steps: |
| 166 | + - name: Setup Go |
| 167 | + uses: actions/setup-go@v2 |
| 168 | + with: |
| 169 | + go-version: 1.17 |
| 170 | + - name: Checkout sources |
| 171 | + uses: actions/checkout@v2 |
| 172 | + with: |
| 173 | + path: src |
| 174 | + - name: Configure |
| 175 | + run: | |
| 176 | + VERSION_ONLY=1 cmake src |
| 177 | + - name: Build |
| 178 | + run: | |
| 179 | + if [ "${{matrix.os}}" = macos ]; then |
| 180 | + export GOOS=darwin |
| 181 | + fi |
| 182 | +
|
| 183 | + if [ "${{matrix.arch}}" = armv7lh ]; then |
| 184 | + export GOARCH=arm |
| 185 | + elif [ "${{matrix.arch}}" = aarch64 ]; then |
| 186 | + export GOARCH=arm64 |
| 187 | + fi |
| 188 | +
|
| 189 | + cd src/golang |
| 190 | + go build -o ${{github.workspace}}/pktvisor-cli ./cmd/pktvisor-cli |
| 191 | + - name: Upload pktvisor-cli |
| 192 | + uses: actions/upload-artifact@v2 |
| 193 | + with: |
| 194 | + name: pktvisor-cli-${{matrix.os}}-${{matrix.arch}} |
| 195 | + path: pktvisor-cli |
| 196 | + retention-days: 7 |
0 commit comments