From 665fd3848f638562aae810aa6f6af5d6cdc9b9ba Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 13 Mar 2024 19:03:19 +0100 Subject: [PATCH] CMake: Allow configuring a minimal subset of examples to deploy When building examples as part of Qt in the CI, it's best to skip running deployment for all examples to save resources (space and time). Add a QT_DEPLOY_MINIMAL_EXAMPLES option similar to our QT_BUILD_MINIMAL_STATIC_TESTS option, which will set QT_INTERNAL_SKIP_DEPLOYMENT at the root examples directory scope, to skip deployment for all examples. Each example can then opt into the minimal subset by unsetting the QT_INTERNAL_SKIP_DEPLOYMENT variable before its qt_internal_add_example call. Add Coin instructions to enable this option when building our examples in the CI. Task-number: QTBUG-90820 Task-number: QTBUG-96232 Task-number: QTBUG-102057 Change-Id: I2efcda455b400c27fe1efd1bcf81b133137fa2d1 Reviewed-by: Alexey Edelev (cherry picked from commit 224b7c6b6a2a425487df19643709d105e8f3cdd5) Reviewed-by: Alexey Edelev --- cmake/QtBuildOptionsHelpers.cmake | 3 +++ cmake/QtBuildRepoExamplesHelpers.cmake | 9 +++++++++ coin/instructions/prepare_building_env.yaml | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/cmake/QtBuildOptionsHelpers.cmake b/cmake/QtBuildOptionsHelpers.cmake index 81166a7f263..6f795e2ec2b 100644 --- a/cmake/QtBuildOptionsHelpers.cmake +++ b/cmake/QtBuildOptionsHelpers.cmake @@ -323,6 +323,9 @@ macro(qt_internal_setup_build_examples) "Should examples be built as part of the default 'all' target." FORCE) endif() + option(QT_DEPLOY_MINIMAL_EXAMPLES + "Deploy minimal subset of examples to save time and space" OFF) + # FIXME: Support prefix builds as well QTBUG-96232 # We don't want to enable EP examples with -debug-and-release because starting with CMake 3.24 # ExternalProject_Add ends up creating build rules twice, once for each configuration, in the diff --git a/cmake/QtBuildRepoExamplesHelpers.cmake b/cmake/QtBuildRepoExamplesHelpers.cmake index 5261dd90a1f..b6e47430c5a 100644 --- a/cmake/QtBuildRepoExamplesHelpers.cmake +++ b/cmake/QtBuildRepoExamplesHelpers.cmake @@ -11,6 +11,14 @@ macro(qt_examples_build_begin) # Examples are not unity-ready. set(CMAKE_UNITY_BUILD OFF) + # Skip running deployment steps when the developer asked to deploy a minimal subset of examples. + # Each example can then decide whether it wants to be deployed as part of the minimal subset + # by unsetting the QT_INTERNAL_SKIP_DEPLOYMENT variable before its qt_internal_add_example call. + # This will be used by our CI. + if(NOT DEFINED QT_INTERNAL_SKIP_DEPLOYMENT AND QT_DEPLOY_MINIMAL_EXAMPLES) + set(QT_INTERNAL_SKIP_DEPLOYMENT TRUE) + endif() + # Use by qt_internal_add_example. set(QT_EXAMPLE_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") @@ -407,6 +415,7 @@ function(qt_internal_add_example_external_project subdir) QT_BUILD_CMAKE_PREFIX_PATH:STRING QT_ADDITIONAL_PACKAGES_PREFIX_PATH:STRING QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES:STRING + QT_INTERNAL_SKIP_DEPLOYMENT:BOOL CMAKE_FIND_ROOT_PATH:STRING CMAKE_MODULE_PATH:STRING BUILD_SHARED_LIBS:BOOL diff --git a/coin/instructions/prepare_building_env.yaml b/coin/instructions/prepare_building_env.yaml index d1517dce09d..a3ac5c3f0b8 100644 --- a/coin/instructions/prepare_building_env.yaml +++ b/coin/instructions/prepare_building_env.yaml @@ -536,6 +536,8 @@ instructions: # Specify a custom examples installation directory, so that the built example binaries are not # packaged into the artifact archive together with the Qt libraries. + # Also specify that during examples deployment, only a subset of examples should be deployed, to + # save time and space. - type: Group instructions: - type: AppendToEnvironmentVariable @@ -544,6 +546,12 @@ instructions: - type: AppendToEnvironmentVariable variableName: COMMON_TARGET_CMAKE_ARGS variableValue: " -DQT_INTERNAL_EXAMPLES_INSTALL_PREFIX={{unixPathSeparators .BuildDir}}/installed_examples" + - type: AppendToEnvironmentVariable + variableName: COMMON_CMAKE_ARGS + variableValue: " -DQT_DEPLOY_MINIMAL_EXAMPLES=ON" + - type: AppendToEnvironmentVariable + variableName: COMMON_TARGET_CMAKE_ARGS + variableValue: " -DQT_DEPLOY_MINIMAL_EXAMPLES=ON" - type: Group instructions: - type: AppendToEnvironmentVariable