coin: Add instructions to build standalone examples

If a qt5.git configuration is marked with the StandaloneTests feature,
tell CMake not to build the examples in-tree, and instead use
qt-internal-configure-examples to build the examples out-of-tree.

This brings a couple of improvements:
- higher chance of building examples as ExternalProjects without
  issues
- ability to use deployment api in examples, without installing the
  examples into a main install prefix

The new coin instructions files use a copy of the standalone tests
instructions as a base.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: If89e6da0b327a38b9c2738f58aa1b5b5fb9fda37
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit d644f2e02ce36520b4d101ea03fbbcf1b72e7e6f)
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2024-03-06 17:43:04 +01:00
parent 7b4c6ff81d
commit bc227037b8
10 changed files with 139 additions and 0 deletions

View File

@ -306,6 +306,13 @@ macro(qt_internal_setup_build_examples)
option(QT_INSTALL_EXAMPLES_SOURCES_BY_DEFAULT option(QT_INSTALL_EXAMPLES_SOURCES_BY_DEFAULT
"Install example sources as part of the default 'install' target" ON) "Install example sources as part of the default 'install' target" ON)
# We need a way to force disable building in-tree examples in the CI, so that we instead build
# standalone examples. Because the Coin yaml instructions don't allow us to remove
# -make examples from from the configure args, we instead read a variable that only Coin sets.
if(QT_INTERNAL_CI_NO_BUILD_IN_TREE_EXAMPLES)
set(QT_BUILD_EXAMPLES OFF CACHE BOOL "Build Qt examples" FORCE)
endif()
if(QT_BUILD_STANDALONE_EXAMPLES) if(QT_BUILD_STANDALONE_EXAMPLES)
# BuildInternals might have set it to OFF on initial configuration. So force it to ON when # BuildInternals might have set it to OFF on initial configuration. So force it to ON when
# building standalone examples. # building standalone examples.

View File

@ -0,0 +1,26 @@
type: Group
instructions:
- type: ChangeDirectory
directory: "{{.BuildDir}}"
- type: ExecuteCommand
command: "{{.Env.EXAMPLES_ENV_PREFIX}} {{.Env.INSTALL_DIR_FOR_EXAMPLES}}\\bin\\qt-internal-configure-examples {{.Env.COIN_CMAKE_ARGS}}"
executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution
maxTimeInSeconds: 6000
maxTimeBetweenOutput: 1200
userMessageOnFailure: >
Failed to call configure examples.
enable_if:
condition: property
property: host.os
equals_value: Windows
- type: ExecuteCommand
command: "{{.Env.EXAMPLES_ENV_PREFIX}} {{.Env.INSTALL_DIR_FOR_EXAMPLES}}/libexec/qt-internal-configure-examples {{.Env.COIN_CMAKE_ARGS}}"
executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution
maxTimeInSeconds: 6000
maxTimeBetweenOutput: 1200
userMessageOnFailure: >
Failed to call configure examples.
disable_if:
condition: property
property: host.os
equals_value: Windows

View File

@ -0,0 +1,32 @@
type: Group
instructions:
- type: ChangeDirectory
directory: "{{.SourceDir}}"
- type: MakeDirectory
directory: "{{.SourceDir}}_standalone_examples"
- type: SetBuildDirectory
directory: "{{.SourceDir}}_standalone_examples"
- type: ChangeDirectory
directory: "{{.BuildDir}}"
- type: AppendToEnvironmentVariable
variableName: COIN_CMAKE_ARGS
variableValue: " -S {{.SourceDir}} -B ."
disable_if:
condition: runtime
env_var: COIN_CMAKE_ARGS
equals_value: null
- type: EnvironmentVariable
variableName: COIN_CMAKE_ARGS
variableValue: "-S {{.SourceDir}} -B ."
enable_if:
condition: runtime
env_var: COIN_CMAKE_ARGS
equals_value: null
- !include "{{qt/qtbase}}/call_cmake_for_standalone_examples.yaml"
- type: ExecuteCommand
command: "{{.Env.EXAMPLES_ENV_PREFIX}} cmake --build . --parallel -v"
maxTimeInSeconds: 6000
maxTimeBetweenOutput: 4800
userMessageOnFailure: >
Failed to build examples.

View File

@ -0,0 +1,16 @@
type: Group
instructions:
- type: EnvironmentVariable
variableName: EXAMPLES_ENV_PREFIX
variableValue: "{{.Env.ENV_PREFIX}}"
- type: EnvironmentVariable
variableName: INSTALL_DIR_FOR_EXAMPLES
variableValue: "{{.InstallDir}}"
- type: EnvironmentVariable
variableName: COIN_CMAKE_ARGS
variableValue: "{{.Env.COMMON_EXAMPLES_CMAKE_ARGS}}"
- !include "{{qt/qtbase}}/cmake_build_standalone_examples.yaml"
enable_if:
condition: property
property: features
contains_value: StandaloneExamples

View File

@ -0,0 +1,30 @@
type: Group
instructions:
- type: EnvironmentVariable
variableName: EXAMPLES_ENV_PREFIX
variableValue: "{{.Env.TARGET_ENV_PREFIX}}"
- type: EnvironmentVariable
variableName: INSTALL_DIR_FOR_EXAMPLES
variableValue: "{{.InstallDir}}\\target"
enable_if:
condition: property
property: host.os
equals_value: Windows
- type: EnvironmentVariable
variableName: INSTALL_DIR_FOR_EXAMPLES
variableValue: "{{.InstallDir}}/target"
# TODO: Might need android multi-abi support whenever we decide to build examples for that
# config. See 7b9bb698b93e747e02bf6ab8310c439867318f8e in qtbase and how the instructions
# were modified for multi-abi android tests.
disable_if:
condition: property
property: host.os
equals_value: Windows
- type: EnvironmentVariable
variableName: COIN_CMAKE_ARGS
variableValue: "{{.Env.COMMON_TARGET_EXAMPLES_CMAKE_ARGS}}"
- !include "{{qt/qtbase}}/cmake_build_standalone_examples.yaml"
enable_if:
condition: property
property: features
contains_value: StandaloneExamples

View File

@ -174,5 +174,6 @@ instructions:
- type: EnvironmentVariable - type: EnvironmentVariable
variableName: COIN_CONFIG_TYPE variableName: COIN_CONFIG_TYPE
variableValue: "Target" variableValue: "Target"
- !include "{{qt/qtbase}}/cmake_build_standalone_examples_target.yaml"
- !include "{{qt/qtbase}}/qmake/get_qmake_location_target.yaml" - !include "{{qt/qtbase}}/qmake/get_qmake_location_target.yaml"
- !include "{{qt/qtbase}}/qmake_examples/build_qmake_examples_instructions.yaml" - !include "{{qt/qtbase}}/qmake_examples/build_qmake_examples_instructions.yaml"

View File

@ -175,5 +175,6 @@ instructions:
- type: EnvironmentVariable - type: EnvironmentVariable
variableName: COIN_CONFIG_TYPE variableName: COIN_CONFIG_TYPE
variableValue: "Target" variableValue: "Target"
- !include "{{qt/qtbase}}/cmake_build_standalone_examples_target.yaml"
- !include "{{qt/qtbase}}/qmake/get_qmake_location_target.yaml" - !include "{{qt/qtbase}}/qmake/get_qmake_location_target.yaml"
- !include "{{qt/qtbase}}/qmake_examples/build_qmake_examples_instructions.yaml" - !include "{{qt/qtbase}}/qmake_examples/build_qmake_examples_instructions.yaml"

View File

@ -95,5 +95,6 @@ instructions:
- type: EnvironmentVariable - type: EnvironmentVariable
variableName: COIN_CONFIG_TYPE variableName: COIN_CONFIG_TYPE
variableValue: "Host" variableValue: "Host"
- !include "{{qt/qtbase}}/cmake_build_standalone_examples_host.yaml"
- !include "{{qt/qtbase}}/qmake/get_qmake_location_host.yaml" - !include "{{qt/qtbase}}/qmake/get_qmake_location_host.yaml"
- !include "{{qt/qtbase}}/qmake_examples/build_qmake_examples_instructions.yaml" - !include "{{qt/qtbase}}/qmake_examples/build_qmake_examples_instructions.yaml"

View File

@ -92,5 +92,6 @@ instructions:
- type: EnvironmentVariable - type: EnvironmentVariable
variableName: COIN_CONFIG_TYPE variableName: COIN_CONFIG_TYPE
variableValue: "Host" variableValue: "Host"
- !include "{{qt/qtbase}}/cmake_build_standalone_examples_host.yaml"
- !include "{{qt/qtbase}}/qmake/get_qmake_location_host.yaml" - !include "{{qt/qtbase}}/qmake/get_qmake_location_host.yaml"
- !include "{{qt/qtbase}}/qmake_examples/build_qmake_examples_instructions.yaml" - !include "{{qt/qtbase}}/qmake_examples/build_qmake_examples_instructions.yaml"

View File

@ -484,6 +484,9 @@ instructions:
- type: AppendToEnvironmentVariable - type: AppendToEnvironmentVariable
variableName: COMMON_TEST_CMAKE_ARGS variableName: COMMON_TEST_CMAKE_ARGS
variableValue: " -DCMAKE_AUTOGEN_VERBOSE=ON -DCMAKE_MESSAGE_LOG_LEVEL=STATUS" variableValue: " -DCMAKE_AUTOGEN_VERBOSE=ON -DCMAKE_MESSAGE_LOG_LEVEL=STATUS"
- type: AppendToEnvironmentVariable
variableName: COMMON_EXAMPLES_CMAKE_ARGS
variableValue: " -DCMAKE_AUTOGEN_VERBOSE=ON -DCMAKE_MESSAGE_LOG_LEVEL=STATUS"
- type: AppendToEnvironmentVariable - type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_CMAKE_ARGS variableName: COMMON_TARGET_CMAKE_ARGS
@ -494,6 +497,9 @@ instructions:
- type: AppendToEnvironmentVariable - type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_TEST_CMAKE_ARGS variableName: COMMON_TARGET_TEST_CMAKE_ARGS
variableValue: " -DCMAKE_AUTOGEN_VERBOSE=ON -DCMAKE_MESSAGE_LOG_LEVEL=STATUS" variableValue: " -DCMAKE_AUTOGEN_VERBOSE=ON -DCMAKE_MESSAGE_LOG_LEVEL=STATUS"
- type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_EXAMPLES_CMAKE_ARGS
variableValue: " -DCMAKE_AUTOGEN_VERBOSE=ON -DCMAKE_MESSAGE_LOG_LEVEL=STATUS"
# Sccache # Sccache
- type: Group - type: Group
@ -507,6 +513,9 @@ instructions:
- type: AppendToEnvironmentVariable - type: AppendToEnvironmentVariable
variableName: COMMON_TEST_CMAKE_ARGS variableName: COMMON_TEST_CMAKE_ARGS
variableValue: " -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache" variableValue: " -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
- type: AppendToEnvironmentVariable
variableName: COMMON_EXAMPLES_CMAKE_ARGS
variableValue: " -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
- type: AppendToEnvironmentVariable - type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_CMAKE_ARGS variableName: COMMON_TARGET_CMAKE_ARGS
@ -517,6 +526,9 @@ instructions:
- type: AppendToEnvironmentVariable - type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_TEST_CMAKE_ARGS variableName: COMMON_TARGET_TEST_CMAKE_ARGS
variableValue: " -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache" variableValue: " -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
- type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_EXAMPLES_CMAKE_ARGS
variableValue: " -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
enable_if: enable_if:
condition: property condition: property
property: features property: features
@ -532,6 +544,18 @@ instructions:
- type: AppendToEnvironmentVariable - type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_CMAKE_ARGS variableName: COMMON_TARGET_CMAKE_ARGS
variableValue: " -DQT_INTERNAL_EXAMPLES_INSTALL_PREFIX={{unixPathSeparators .BuildDir}}/installed_examples" variableValue: " -DQT_INTERNAL_EXAMPLES_INSTALL_PREFIX={{unixPathSeparators .BuildDir}}/installed_examples"
- type: Group
instructions:
- type: AppendToEnvironmentVariable
variableName: COMMON_CMAKE_ARGS
variableValue: " -DQT_INTERNAL_CI_NO_BUILD_IN_TREE_EXAMPLES=ON"
- type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_CMAKE_ARGS
variableValue: " -DQT_INTERNAL_CI_NO_BUILD_IN_TREE_EXAMPLES=ON"
enable_if:
condition: property
property: features
contains_value: StandaloneExamples
enable_if: enable_if:
# Only set the custom installation dir if examples are built. # Only set the custom installation dir if examples are built.
condition: or condition: or