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

@ -113,11 +113,6 @@ jobs:
find . -name '*.exe' -o -name '*.dll'
bld/src/curl.exe --disable --version
- name: 'autotools build examples'
if: ${{ matrix.build == 'automake' }}
timeout-minutes: 5
run: make -C bld -j5 V=1 examples
- name: 'autotools build tests'
if: ${{ matrix.build == 'automake' && matrix.tflags != 'skipall' }}
timeout-minutes: 15
@ -133,6 +128,11 @@ jobs:
fi
make -C bld -j5 V=1 test-ci
- name: 'autotools build examples'
if: ${{ matrix.build == 'automake' }}
timeout-minutes: 5
run: make -C bld -j5 V=1 examples
- name: 'cmake configure'
if: ${{ matrix.build == 'cmake' }}
timeout-minutes: 5
@ -141,7 +141,6 @@ jobs:
cmake -B bld -G Ninja ${options} \
-DCMAKE_UNITY_BUILD=ON \
-DCURL_WERROR=ON \
-DBUILD_EXAMPLES=ON \
-DENABLE_WEBSOCKETS=ON \
-DCURL_BROTLI=ON \
${{ matrix.config }}
@ -186,3 +185,8 @@ jobs:
fi
PATH="$PWD/bld/lib:$PATH"
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

View file

@ -504,7 +504,6 @@ jobs:
cmake . \
-DCMAKE_C_COMPILER_TARGET=$(uname -m)-pc-linux-gnu -DBUILD_STATIC_LIBS=ON \
-DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON \
-DBUILD_EXAMPLES=ON \
-DCURL_BROTLI=ON -DCURL_ZSTD=ON \
${{ matrix.build.generate }}
if: ${{ matrix.build.generate }}
@ -535,10 +534,6 @@ jobs:
- run: ./src/curl -V
name: 'check curl -V output'
- run: ${{ matrix.build.make-prefix }} make V=1 examples
if: ${{ matrix.build.configure }}
name: 'make examples'
- run: make V=1 -C tests
if: ${{ matrix.build.configure && matrix.build.install_steps != 'skipall' }}
name: 'make tests (autotools)'
@ -566,3 +561,11 @@ jobs:
env:
TFLAGS: "${{ matrix.build.tflags }}"
CURL_CI: github
- run: ${{ matrix.build.make-prefix }} make V=1 examples
if: ${{ matrix.build.configure }}
name: 'make examples (autotools)'
- run: ${{ matrix.build.make-prefix }} make VERBOSE=1 curl-examples
if: ${{ matrix.build.generate }}
name: 'make examples (cmake)'

View file

@ -121,7 +121,7 @@ jobs:
compiler: gcc-12
configure: --enable-debug --with-secure-transport --enable-websockets --with-libssh2=$(brew --prefix libssh2)
macos-version-min: '10.8'
- name: 'LibreSSL'
- name: 'LibreSSL +examples'
compiler: clang
install: libressl
configure: --enable-debug --with-openssl=$(brew --prefix libressl) --enable-websockets
@ -229,9 +229,6 @@ jobs:
- name: 'curl version'
run: bld/src/curl --disable --version
- name: 'make examples'
run: make -C bld V=1 examples
- name: 'make tests'
run: make -C bld V=1 -C tests
@ -264,6 +261,10 @@ jobs:
rm -f $HOME/.curlrc
make -C bld V=1 test-ci
- name: 'make examples'
if: ${{ contains(matrix.build.name, '+examples') }}
run: make -C bld V=1 examples
cmake:
name: 'CM ${{ matrix.compiler }} ${{ matrix.build.name }}'
runs-on: 'macos-latest'
@ -287,9 +288,9 @@ jobs:
- name: 'SecureTransport ws debug+'
generate: -DCURL_USE_SECTRANSP=ON -DENABLE_WEBSOCKETS=ON -DENABLE_DEBUG=ON -DENABLE_CURLDEBUG=ON
macos-version-min: '10.8'
- name: 'LibreSSL !ldap heimdal c-ares'
- name: 'LibreSSL !ldap heimdal c-ares +examples'
install: libressl heimdal
generate: -DOPENSSL_ROOT_DIR=$(brew --prefix libressl) -DENABLE_ARES=ON -DCURL_USE_GSSAPI=ON -DGSS_ROOT_DIR=$(brew --prefix heimdal) -DCURL_DISABLE_LDAP=ON -DBUILD_EXAMPLES=ON
generate: -DOPENSSL_ROOT_DIR=$(brew --prefix libressl) -DENABLE_ARES=ON -DCURL_USE_GSSAPI=ON -DGSS_ROOT_DIR=$(brew --prefix heimdal) -DCURL_DISABLE_LDAP=ON
macos-version-min: '10.15'
- name: 'wolfSSL !ldap brotli zstd'
install: brotli wolfssl zstd
@ -399,6 +400,10 @@ jobs:
rm -f $HOME/.curlrc
ninja -C bld test-ci
- name: 'cmake build examples'
if: ${{ contains(matrix.name, '+examples') }}
run: make -C bld VERBOSE=1
combinations: # Test buildability with host OS, Xcode / SDK, compiler, target-OS, SecureTransport/not, built tool, combinations
if: true # Set to `true` to enable this test matrix. It runs quickly.
name: "${{ matrix.build == 'cmake' && 'CM' || 'AM' }} ${{ matrix.compiler }} ${{ matrix.image }} ${{ matrix.xcode }} ${{ matrix.config }}"

View file

@ -58,7 +58,6 @@ jobs:
-DCMAKE_UNITY_BUILD=ON \
-DCURL_WERROR=ON \
-DENABLE_DEBUG=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG= \
-DBUILD_EXAMPLES=ON \
-DENABLE_WEBSOCKETS=ON \
-DCURL_USE_OPENSSL=ON \
-DCURL_BROTLI=ON -DCURL_USE_GSSAPI=ON \
@ -70,6 +69,9 @@ jobs:
export TFLAGS='-j0' # flakies: ~389 ~392 ~TFTP and more
cmake --build bld --config Debug --target test-ci
fi
echo '::group::build examples'
cmake --build bld --config Debug --parallel 3 --target curl-examples
echo '::endgroup::'
openbsd:
name: 'OpenBSD (cmake, libressl, clang)'
@ -93,7 +95,6 @@ jobs:
-DCMAKE_UNITY_BUILD=ON \
-DCURL_WERROR=ON \
-DENABLE_DEBUG=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG= \
-DBUILD_EXAMPLES=ON \
-DENABLE_WEBSOCKETS=ON \
-DCURL_USE_OPENSSL=ON \
-DCURL_BROTLI=ON \
@ -105,6 +106,9 @@ jobs:
export TFLAGS='-j8 ~3017 ~TFTP ~FTP' # FIXME: TFTP requests executed twice? Related: `curl: (69) TFTP: Access Violation`?
cmake --build bld --config Debug --target test-ci
fi
echo '::group::build examples'
cmake --build bld --config Debug --parallel 3 --target curl-examples
echo '::endgroup::'
freebsd:
name: 'FreeBSD (${{ matrix.build }}, openssl, ${{ matrix.compiler }}, ${{ matrix.arch }})'
@ -140,11 +144,13 @@ jobs:
--disable-dependency-tracking || { tail -n 1000 config.log; false; }
make -j3 install
src/curl --disable --version
make -j3 examples
if [ '${{ matrix.arch }}' = 'x86_64' ]; then # Slow on emulated CPU
make -j3 -C tests
make test-ci V=1 TFLAGS='-j8 ~FTP'
fi
echo '::group::build examples'
make -j3 examples
echo '::endgroup::'
- name: 'cmake'
if: ${{ matrix.build == 'cmake' }}
@ -162,7 +168,6 @@ jobs:
-DCMAKE_UNITY_BUILD=ON \
-DCURL_WERROR=ON \
-DENABLE_DEBUG=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG= \
-DBUILD_EXAMPLES=ON \
-DENABLE_WEBSOCKETS=ON \
-DCURL_USE_OPENSSL=ON \
-DCURL_BROTLI=ON -DCURL_USE_GSSAPI=ON \
@ -174,6 +179,9 @@ jobs:
export TFLAGS='-j8 ~FTP'
cmake --build bld --config Debug --target test-ci
fi
echo '::group::build examples'
cmake --build bld --config Debug --parallel 3 --target curl-examples
echo '::endgroup::'
omnios:
name: 'OmniOS (autotools, openssl, gcc, amd64)'
@ -197,6 +205,8 @@ jobs:
--disable-dependency-tracking || { tail -n 1000 config.log; false; }
gmake -j3 install
src/curl --disable --version
gmake -j3 examples
gmake -j3 -C tests
gmake test-ci V=1 TFLAGS='-j12 ~MQTT ~FTP'
echo '::group::build examples'
gmake -j3 examples
echo '::endgroup::'

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