Skip to content

Commit

Permalink
coin: Add instructions to build standalone examples
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Qt CI Bot <[email protected]>
  • Loading branch information
alcroito committed Mar 14, 2024
1 parent 6290516 commit d644f2e
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmake/QtBuildOptionsHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ macro(qt_internal_setup_build_examples)
option(QT_INSTALL_EXAMPLES_SOURCES_BY_DEFAULT
"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)
# BuildInternals might have set it to OFF on initial configuration. So force it to ON when
# building standalone examples.
Expand Down
26 changes: 26 additions & 0 deletions coin/instructions/call_cmake_for_standalone_examples.yaml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions coin/instructions/cmake_build_standalone_examples.yaml
Original file line number Diff line number Diff line change
@@ -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.
16 changes: 16 additions & 0 deletions coin/instructions/cmake_build_standalone_examples_host.yaml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions coin/instructions/cmake_build_standalone_examples_target.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,6 @@ instructions:
- type: EnvironmentVariable
variableName: COIN_CONFIG_TYPE
variableValue: "Target"
- !include "{{qt/qtbase}}/cmake_build_standalone_examples_target.yaml"
- !include "{{qt/qtbase}}/qmake/get_qmake_location_target.yaml"
- !include "{{qt/qtbase}}/qmake_examples/build_qmake_examples_instructions.yaml"
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,6 @@ instructions:
- type: EnvironmentVariable
variableName: COIN_CONFIG_TYPE
variableValue: "Target"
- !include "{{qt/qtbase}}/cmake_build_standalone_examples_target.yaml"
- !include "{{qt/qtbase}}/qmake/get_qmake_location_target.yaml"
- !include "{{qt/qtbase}}/qmake_examples/build_qmake_examples_instructions.yaml"
1 change: 1 addition & 0 deletions coin/instructions/cmake_module_build_instructions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@ instructions:
- type: EnvironmentVariable
variableName: COIN_CONFIG_TYPE
variableValue: "Host"
- !include "{{qt/qtbase}}/cmake_build_standalone_examples_host.yaml"
- !include "{{qt/qtbase}}/qmake/get_qmake_location_host.yaml"
- !include "{{qt/qtbase}}/qmake_examples/build_qmake_examples_instructions.yaml"
1 change: 1 addition & 0 deletions coin/instructions/cmake_qtbase_build_instructions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@ instructions:
- type: EnvironmentVariable
variableName: COIN_CONFIG_TYPE
variableValue: "Host"
- !include "{{qt/qtbase}}/cmake_build_standalone_examples_host.yaml"
- !include "{{qt/qtbase}}/qmake/get_qmake_location_host.yaml"
- !include "{{qt/qtbase}}/qmake_examples/build_qmake_examples_instructions.yaml"
24 changes: 24 additions & 0 deletions coin/instructions/prepare_building_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ instructions:
- type: AppendToEnvironmentVariable
variableName: COMMON_TEST_CMAKE_ARGS
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
variableName: COMMON_TARGET_CMAKE_ARGS
Expand All @@ -494,6 +497,9 @@ instructions:
- type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_TEST_CMAKE_ARGS
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
- type: Group
Expand All @@ -507,6 +513,9 @@ instructions:
- type: AppendToEnvironmentVariable
variableName: COMMON_TEST_CMAKE_ARGS
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
variableName: COMMON_TARGET_CMAKE_ARGS
Expand All @@ -517,6 +526,9 @@ instructions:
- type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_TEST_CMAKE_ARGS
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:
condition: property
property: features
Expand All @@ -532,6 +544,18 @@ instructions:
- type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_CMAKE_ARGS
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:
# Only set the custom installation dir if examples are built.
condition: or
Expand Down

0 comments on commit d644f2e

Please sign in to comment.