cmake: separate target for examples, optimize CI, fix fallouts

- Move `docs/examples` builds under a separate target.

- Make `BUILD_EXAMPLES` default to `ON`. It means to generate the rules
  for `docs/examples` by default, but not build them. To build them,
  an explicit `make curl-examples` (or ninja, etc) command is necessary.
  This syncs behaviour with autotools, and also how both cmake and
  autotools are building tests.

- GHA: update cmake jobs to use the new way of building examples.

- GHA: move examples build step at the end of the job, after building
  and running tests. This allows to have build and test run results
  faster, and leave the seldom-changing examples build to the end.
  Building examples is the slowest build step with no practical way to
  make them fast.

- appveyor: enable building examples in two old-MSVC jobs.

- examples: fix examples to build cleanly with old MSVC versions.

- GHA/non-native: move example build log under a GHA foldable section.

- GHA/windows: move building examples into separate step for Linux cross
  jobs.

Follow-up to dfdd978f7c #13491
Closes #14906
This commit is contained in:
Viktor Szakats 2024-09-14 02:21:33 +02:00
parent caefaecaad
commit 45202cbba4
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
13 changed files with 116 additions and 53 deletions

View file

@ -56,8 +56,8 @@ jobs:
- { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: '~2301 ~2302' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_ARES=ON', type: 'Debug', name: 'schannel c-ares U' }
- { build: 'cmake' , sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_CURLDEBUG=ON', type: 'Release', name: 'schannel R TrackMemory' }
- { build: 'cmake' , sys: 'clang64', env: 'clang-x86_64', tflags: 'skiprun' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_OPENSSL=ON -DENABLE_UNICODE=OFF', type: 'Release', name: 'openssl' }
- { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DBUILD_EXAMPLES=OFF', type: 'Release', test: 'uwp', name: 'schannel R' }
- { build: 'cmake' , sys: 'mingw32', env: 'i686' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DBUILD_EXAMPLES=OFF', type: 'Release', name: 'schannel R' }
- { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON', type: 'Release', test: 'uwp', name: 'schannel R' }
- { build: 'cmake' , sys: 'mingw32', env: 'i686' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON', type: 'Release', name: 'schannel R' }
fail-fast: false
steps:
- run: git config --global core.autocrlf input
@ -135,11 +135,6 @@ jobs:
find . -name '*.exe' -o -name '*.dll'
bld/src/curl.exe --disable --version
- name: 'autotools build examples'
if: ${{ matrix.build == 'autotools' }}
timeout-minutes: 5
run: make -C bld -j5 V=1 examples
- name: 'autotools build tests'
if: ${{ matrix.build == 'autotools' && matrix.tflags != 'skipall' }}
timeout-minutes: 10
@ -169,6 +164,11 @@ jobs:
PATH="$PATH:/c/Program Files (x86)/stunnel/bin"
make -C bld -j5 V=1 test-ci
- name: 'autotools build examples'
if: ${{ matrix.build == 'autotools' }}
timeout-minutes: 5
run: make -C bld -j5 V=1 examples
- name: 'cmake configure'
if: ${{ matrix.build == 'cmake' }}
timeout-minutes: 5
@ -198,7 +198,6 @@ jobs:
'-DCMAKE_BUILD_TYPE=${{ matrix.type }}' \
-DCMAKE_UNITY_BUILD=ON \
-DCURL_WERROR=ON \
-DBUILD_EXAMPLES=ON \
-DENABLE_WEBSOCKETS=ON \
-DCURL_BROTLI=ON \
${{ matrix.config }}
@ -224,7 +223,7 @@ jobs:
if: ${{ matrix.build == 'cmake' }}
timeout-minutes: 1
run: |
find . -name '*.exe' -o -name '*.dll' | grep -v '/examples/'
find . -name '*.exe' -o -name '*.dll'
if [ '${{ matrix.test }}' != 'uwp' ]; then # UWP missing 'msvcr120_app.dll', fails with exit code 0xc0000135
PATH="$PWD/bld/lib:$PATH"
bld/src/curl.exe --disable --version
@ -259,6 +258,11 @@ jobs:
PATH="$PWD/bld/lib:$PATH:/c/Program Files (x86)/stunnel/bin"
cmake --build bld --config '${{ matrix.type }}' --target test-ci
- name: 'cmake build examples'
if: ${{ matrix.build == 'cmake' }}
timeout-minutes: 5
run: cmake --build bld --config '${{ matrix.type }}' --parallel 5 --target curl-examples
old-mingw-w64:
name: 'old-mingw, CM ${{ matrix.env }} ${{ matrix.name }}'
runs-on: windows-latest
@ -327,7 +331,6 @@ jobs:
'-DCMAKE_BUILD_TYPE=${{ matrix.type }}' \
-DCMAKE_UNITY_BUILD=ON \
-DCURL_WERROR=ON \
-DBUILD_EXAMPLES=ON \
-DENABLE_WEBSOCKETS=ON \
-DCURL_USE_LIBPSL=OFF \
${{ matrix.config }}
@ -343,7 +346,7 @@ jobs:
run: cat bld/lib/curl_config.h || true
- name: 'cmake build'
timeout-minutes: 10
timeout-minutes: 5
run: |
PATH="$(cygpath "${USERPROFILE}")/my-cache/${{ matrix.dir }}/bin:/c/msys64/usr/bin:$PATH"
cmake --build bld --config '${{ matrix.type }}' --parallel 5
@ -351,7 +354,7 @@ jobs:
- name: 'curl version'
timeout-minutes: 1
run: |
find . -name '*.exe' -o -name '*.dll' | grep -v '/examples/'
find . -name '*.exe' -o -name '*.dll'
PATH="$PWD/bld/lib:$PATH"
bld/src/curl.exe --disable --version
@ -382,6 +385,12 @@ jobs:
PATH="$PWD/bld/lib:$PATH:/c/Program Files (x86)/stunnel/bin"
cmake --build bld --config '${{ matrix.type }}' --target test-ci
- name: 'cmake build examples'
timeout-minutes: 5
run: |
PATH="$(cygpath "${USERPROFILE}")/my-cache/${{ matrix.dir }}/bin:/c/msys64/usr/bin:$PATH"
cmake --build bld --config '${{ matrix.type }}' --parallel 5 --target curl-examples
linux-cross-mingw-w64:
name: "linux-mingw, ${{ matrix.build == 'cmake' && 'CM' || 'AM' }} ${{ matrix.compiler }}"
runs-on: ubuntu-latest
@ -418,9 +427,11 @@ jobs:
- name: 'autotools build'
if: ${{ matrix.build == 'autotools' }}
run: |
make -C bld -j5
make -C bld -j5 examples
run: make -C bld -j5
- name: 'autotools build examples'
if: ${{ matrix.build == 'autotools' }}
run: make -C bld -j5 examples
- name: 'cmake configure'
if: ${{ matrix.build == 'cmake' }}
@ -431,7 +442,6 @@ jobs:
-DCMAKE_C_COMPILER=${TRIPLET}-gcc \
-DCMAKE_UNITY_BUILD=ON \
-DCURL_WERROR=ON \
-DBUILD_EXAMPLES=ON \
-DCURL_USE_SCHANNEL=ON -DUSE_WIN32_IDN=ON \
-DCURL_USE_LIBPSL=OFF
@ -443,6 +453,10 @@ jobs:
if: ${{ matrix.build == 'cmake' }}
run: cmake --build bld --parallel 5
- name: 'cmake build examples'
if: ${{ matrix.build == 'cmake' }}
run: cmake --build bld --parallel 5 --target curl-examples
msvc:
name: 'msvc, CM ${{ matrix.arch }}-${{ matrix.plat }} ${{ matrix.name }}'
runs-on: windows-latest
@ -553,7 +567,6 @@ jobs:
'-DCMAKE_BUILD_TYPE=${{ matrix.type }}' \
-DCMAKE_UNITY_BUILD=ON \
-DCURL_WERROR=ON \
-DBUILD_EXAMPLES=ON \
-DENABLE_WEBSOCKETS=ON \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG= \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE= \
@ -576,7 +589,7 @@ jobs:
- name: 'curl version'
timeout-minutes: 1
run: |
find . -name '*.exe' -o -name '*.dll' | grep -v '/examples/'
find . -name '*.exe' -o -name '*.dll'
if [ '${{ matrix.plat }}' != 'uwp' ]; then
PATH="$PWD/bld/lib:$PATH"
bld/src/curl.exe --disable --version
@ -611,3 +624,7 @@ jobs:
fi
PATH="$PWD/bld/lib:$PATH:/c/Program Files (x86)/stunnel/bin:/c/Program Files/OpenSSH-Win64"
cmake --build bld --config '${{ matrix.type }}' --target test-ci
- name: 'cmake build examples'
timeout-minutes: 5
run: cmake --build bld --config '${{ matrix.type }}' --parallel 5 --target curl-examples