|
| 1 | +on: |
| 2 | + push: |
| 3 | + pull_request: |
| 4 | + |
| 5 | +name: Windows |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + name: ${{ matrix.name }} |
| 10 | + runs-on: ${{ matrix.os }} |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - name: "Windows 2022 MSVC" |
| 16 | + os: windows-2022 |
| 17 | + triplet: x64-windows |
| 18 | + build_type: Release |
| 19 | + generators: "Visual Studio 17 2022" |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Unix line endings in git |
| 23 | + run: | |
| 24 | + git config --global core.autocrlf input |
| 25 | + git config --global core.eol lf |
| 26 | +
|
| 27 | + - uses: actions/checkout@v2 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + submodules: recursive |
| 31 | + |
| 32 | + - name: Get number of CPU cores |
| 33 | + id: cpu-cores |
| 34 | + uses: SimenB/github-actions-cpu-cores@5e7112c2e8c5b63b649a678bc2fb5920d0c8202e |
| 35 | + |
| 36 | + # - name: change vcpkg |
| 37 | + # shell: bash |
| 38 | + # run: | |
| 39 | + # cd ${VCPKG_INSTALLATION_ROOT//\\//} |
| 40 | + # git remote add --fetch jkt https://github.com/jktjkt/vcpkg.git |
| 41 | + # git reset --hard jkt/wtf |
| 42 | + |
| 43 | + - name: Extract VCPKG version |
| 44 | + id: extract-vcpkg-version |
| 45 | + shell: bash |
| 46 | + run: | |
| 47 | + cd ${VCPKG_INSTALLATION_ROOT//\\//} |
| 48 | + echo "::set-output name=VCPKG_PATH::$VCPKG_INSTALLATION_ROOT" |
| 49 | + echo "::set-output name=VCPKG_COMMIT::$(git rev-parse HEAD)" |
| 50 | + # cd '${{ github.workspace }}/'libyang |
| 51 | + # echo "::set-output name=LIBYANG_COMMIT::$(git rev-parse HEAD)" |
| 52 | + # cd '${{ github.workspace }}/'libyang-cpp |
| 53 | + # echo "::set-output name=LIBYANG_CPP_COMMIT::$(git rev-parse HEAD)" |
| 54 | +
|
| 55 | + # Unfortunately, this is broken due to dlfcn-win32 assuming that "debug" is always there: |
| 56 | + # (the last item at https://github.com/microsoft/vcpkg/issues/6045) |
| 57 | + # Fixed via https://github.com/microsoft/vcpkg/pull/25278 |
| 58 | + # But then bzip2 also fails... |
| 59 | + # - name: Slim down VCPKG builds |
| 60 | + # shell: bash |
| 61 | + # run: echo 'set(VCPKG_BUILD_TYPE "${{ matrix.build_type }}")' >> ${VCPKG_INSTALLATION_ROOT//\\//}/triplets/${{ matrix.triplet }}.cmake |
| 62 | + |
| 63 | + - name: Cache VCPKG |
| 64 | + id: cache-vcpkg |
| 65 | + uses: actions/cache@v3 |
| 66 | + with: |
| 67 | + path: '${{ steps.extract-vcpkg-version.outputs.VCPKG_PATH }}' |
| 68 | + key: 'vcpkg-1-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.triplet }}-${{ steps.extract-vcpkg-version.outputs.VCPKG_COMMIT }}' |
| 69 | + |
| 70 | + - name: Configure Windows PATH |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + echo '${{ github.workspace }}/'../target/bin >> $GITHUB_PATH |
| 74 | + echo '${{ github.workspace }}/'../target/lib >> $GITHUB_PATH |
| 75 | + echo ${VCPKG_INSTALLATION_ROOT//\\//}'/installed/${{ matrix.triplet }}/bin' >> $GITHUB_PATH |
| 76 | +
|
| 77 | + - name: Install Windows dependencies |
| 78 | + if: ${{ steps.cache-vcpkg.outputs.cache-hit != 'true' }} |
| 79 | + run: vcpkg install --triplet=${{ matrix.triplet }} pcre2 pthreads dirent dlfcn-win32 cmocka getopt doctest pkgconf pybind11 |
| 80 | + |
| 81 | + - name: configure libyang |
| 82 | + shell: bash |
| 83 | + run: | |
| 84 | + cmake \ |
| 85 | + -S '${{ github.workspace }}/'libyang \ |
| 86 | + -B '${{ github.workspace }}/'../build-libyang \ |
| 87 | + -G '${{ matrix.generators }}' \ |
| 88 | + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ |
| 89 | + -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \ |
| 90 | + -DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT//\\//}/scripts/buildsystems/vcpkg.cmake \ |
| 91 | + -DENABLE_TESTS=ON \ |
| 92 | + -DCMAKE_INSTALL_PREFIX:PATH='${{ github.workspace }}/'../target |
| 93 | +
|
| 94 | + - name: build libyang |
| 95 | + working-directory: '${{ github.workspace }}/../build-libyang' |
| 96 | + run: cmake --build . -j${{ steps.cpu-cores.outputs.count }} --config ${{ matrix.build_type }} |
| 97 | + |
| 98 | + - name: test libyang |
| 99 | + working-directory: '${{ github.workspace }}/../build-libyang' |
| 100 | + run: ctest --output-on-failure -j${{ steps.cpu-cores.outputs.count }} --build-config ${{ matrix.build_type }} |
| 101 | + |
| 102 | + - name: install libyang |
| 103 | + working-directory: '${{ github.workspace }}/../build-libyang' |
| 104 | + run: cmake --install . --strip |
| 105 | + |
| 106 | + - name: test the installed yanglint |
| 107 | + run: yanglint -f tree ${{ github.workspace }}/libyang/tests/modules/yang/[email protected] |
| 108 | + |
| 109 | + - name: configure libyang-cpp |
| 110 | + shell: bash |
| 111 | + run: | |
| 112 | + set -ex |
| 113 | + MY_TARGET=${GITHUB_WORKSPACE//\\//}/../target |
| 114 | + export MY_PKGCONFIG="${VCPKG_INSTALLATION_ROOT//\\//}/installed/${{ matrix.triplet }}/tools/pkgconf/pkgconf.exe" |
| 115 | + export PKG_CONFIG_PATH="${VCPKG_INSTALLATION_ROOT//\\//}/installed/${{ matrix.triplet }}/lib/pkgconfig;${MY_TARGET}/lib/pkgconfig" |
| 116 | + export CXXFLAGS=" /wd4251 /wd4275" |
| 117 | + cmake \ |
| 118 | + -S '${{ github.workspace }}/'libyang-cpp \ |
| 119 | + -B '${{ github.workspace }}/'../build-libyang-cpp \ |
| 120 | + -G '${{ matrix.generators }}' \ |
| 121 | + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ |
| 122 | + -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \ |
| 123 | + -DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT//\\//}/scripts/buildsystems/vcpkg.cmake \ |
| 124 | + -DPKG_CONFIG_EXECUTABLE=${MY_PKGCONFIG} \ |
| 125 | + -DCMAKE_PREFIX_PATH:PATH=${MY_TARGET} \ |
| 126 | + -DCMAKE_INSTALL_PREFIX:PATH='${{ github.workspace }}/'../target |
| 127 | +
|
| 128 | + - name: build libyang-cpp |
| 129 | + working-directory: '${{ github.workspace }}/../build-libyang-cpp' |
| 130 | + run: cmake --build . -j${{ steps.cpu-cores.outputs.count }} --config ${{ matrix.build_type }} |
| 131 | + |
| 132 | + - name: test libyang-cpp |
| 133 | + working-directory: '${{ github.workspace }}/../build-libyang-cpp' |
| 134 | + run: ctest --output-on-failure -j${{ steps.cpu-cores.outputs.count }} --build-config ${{ matrix.build_type }} |
| 135 | + |
| 136 | + - name: install libyang-cpp |
| 137 | + working-directory: '${{ github.workspace }}/../build-libyang-cpp' |
| 138 | + run: cmake --install . --strip |
0 commit comments