Skip to content

Commit 7fd0e66

Browse files
authored
GHA CI: re-use qt_modules and qt_archives lists for macOS and Linux (#2118)
* GHA CI: re-use qt_modules and qt_archives lists for macOS and Linux
1 parent 7a0ca52 commit 7fd0e66

4 files changed

Lines changed: 43 additions & 15 deletions

File tree

.github/workflows/setup_environment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ jobs:
122122
source ./buildScripts/github/install_linter.sh
123123
LEFT="${{ github.event.pull_request.base.sha || github.event.before }}"
124124
RIGHT="${{ github.event.pull_request.head.sha || github.event.after }}"
125+
${{ inputs.executor }} git fetch origin ${LEFT} --depth=1
126+
${{ inputs.executor }} git fetch origin ${RIGHT} --depth=1
125127
${{ inputs.executor }} env COMMIT_RANGE="$LEFT...$RIGHT" buildScripts/github/vera_translation.sh
126128
env:
127129
TRIK_QT_VERSION: ${{ inputs.trik_qt_version }}

buildScripts/github/install.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ XCODE_VERSION=${XCODE_VERSION:-15.3}
66
SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
77

88
source "$SCRIPT_DIR/utilities.sh"
9-
9+
qt_archives=("qtbase" "qtmultimedia" "qtsvg" "qtscript" "qttools" "qtserialport" "qtimageformats" "qtdeclarative" "qtquickcontrols2" "qttranslations")
10+
qt_modules=("qtscript")
1011
case "$(uname)" in
1112
Darwin)
1213
export HOMEBREW_NO_INSTALL_CLEANUP=1
@@ -18,8 +19,8 @@ case "$(uname)" in
1819
p="${pkg##*/}"
1920
p="${p%.*}"
2021
brew install --quiet "$pkg" || brew upgrade "$pkg" || brew link --force "$pkg" || echo "Failed to install/upgrade $pkg"
21-
done
22-
modules=("qtscript")
22+
done
23+
qt_archives+=("qtmacextras")
2324

2425
PYTHON_VERSION="3.${TRIK_PYTHON3_VERSION_MINOR}.$TRIK_PYTHON3_VERSION_PATCH"
2526
PYTHON_INSTALLER_NAME="python-$PYTHON_VERSION-macos11.pkg"
@@ -35,7 +36,7 @@ case "$(uname)" in
3536
sudo port selfupdate
3637
sudo port install libusb +universal
3738

38-
install_qt mac desktop "${TRIK_QT_VERSION}" "$HOME/Qt" $modules
39+
install_qt mac desktop "${TRIK_QT_VERSION}" "$HOME/Qt" qt_modules qt_archives
3940
sudo xcode-select -s /Applications/Xcode_${XCODE_VERSION}.app/Contents/Developer
4041
xcodebuild -showsdks
4142
xcrun -sdk macosx --show-sdk-path
@@ -69,9 +70,9 @@ case "$(uname)" in
6970
else
7071
sudo yum install -y --setopt=install_weak_deps=False libX11-xcb libXext libxkbcommon-x11 fontconfig freetype libXrender
7172
#libQt5WaylandCompositor.so.5.15: libQt5Quick.so.5 libQt5Qml.so.5 libQt5QmlModels.so.5
72-
modules=("qtscript" "qtwaylandcompositor")
73-
archives=("qtbase" "qtmultimedia" "qtsvg" "qtscript" "qttools" "qtserialport" "qtimageformats" "icu" "qtwayland" "qtdeclarative" "qtquickcontrols2" "qttranslations")
74-
install_qt linux desktop "$TRIK_QT_VERSION" "$HOME/Qt" $modules $archives
73+
qt_modules+=("qtwaylandcompositor")
74+
qt_archives+=("icu" "qtwayland")
75+
install_qt linux desktop "$TRIK_QT_VERSION" "$HOME/Qt" qt_modules qt_archives
7576
QT_ROOT_DIR=$(ls -1d "$HOME"/Qt/$TRIK_QT_VERSION*/gcc_64 | head -n 1)
7677
echo "$QT_ROOT_DIR/bin" >> $GITHUB_PATH
7778
fi

buildScripts/github/install_linter.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sudo apt-get update && sudo apt-get install -y --no-install-recommends vera++
88

99
modules=("qtscript" "qtwaylandcompositor")
1010
archives=("qtbase" "qtmultimedia" "qtsvg" "qtscript" "qttools" "qtserialport" "qtimageformats" "icu" "qtwayland" "qtdeclarative" "qttranslations" "qtsvgwidgets" "qtxmlpatterns" "qtwebenginewidgets" "qtwebkit" "qtwebkitwidgets")
11-
install_qt linux desktop "$TRIK_QT_VERSION" "$HOME/Qt" $modules $archives
11+
install_qt linux desktop "$TRIK_QT_VERSION" "$HOME/Qt" modules archives
1212
QT_ROOT_DIR=$(ls -1d "$HOME"/Qt/$TRIK_QT_VERSION*/gcc_64 | head -n 1)
1313
echo "$QT_ROOT_DIR/bin" >> $GITHUB_PATH
1414
export PATH="$QT_ROOT_DIR/bin:$PATH"

buildScripts/github/utilities.sh

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,45 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
set -euxo pipefail
33
TRIK_PYTHON3_VERSION_MINOR=${TRIK_PYTHON3_VERSION_MINOR:-11}
44
TRIK_PYTHON=python3.${TRIK_PYTHON3_VERSION_MINOR}
55

6-
install_qt(){
6+
get_array_by_name() {
7+
# Bash expansion (works on 3.2+ for macOS too)
8+
9+
#Check for output var to be declared before call as an array
10+
if ! declare -p get_array_by_name_result 2>/dev/null | grep -q ' -a '; then
11+
echo "Error: 'get_array_by_name_result' variable must be declared as an array before calling get_array_by_name." >&2
12+
return 1
13+
fi
14+
local name="${1:-}"
15+
# Check that referenced by name one is defined as an array
16+
if declare -p "$name" 2>/dev/null | grep -q ' -a '; then
17+
local ref="${name}[@]"
18+
get_array_by_name_result=("${!ref}")
19+
else
20+
get_array_by_name_result=()
21+
echo "Error: '$name' is not a defined indexed array." >&2
22+
return 1
23+
fi
24+
}
25+
26+
27+
install_qt() {
728
# Usage: install_qt <os> <platform-type> <qt-version> <path-to-install-qt> <modules> <archives>
829
# TODO: add <addittional-options>
930
"$TRIK_PYTHON" -m venv venv
1031
. ./venv/bin/activate
1132
"$TRIK_PYTHON" -m pip install -U pip
1233
"$TRIK_PYTHON" -m pip install aqtinstall
13-
if [ -z "${6+x}" ]; then
14-
"$TRIK_PYTHON" -m aqt install-qt "$1" "$2" "$3" -O "$4" -m "${modules[@]}"
15-
else
16-
"$TRIK_PYTHON" -m aqt install-qt "$1" "$2" "$3" -O "$4" -m "${modules[@]}" --archives "${archives[@]}"
17-
fi
34+
local -a cmd=("$TRIK_PYTHON" -m aqt install-qt "$1" "$2" "$3" -O "$4")
35+
36+
37+
local -a get_array_by_name_result=() #declare before call
38+
if [[ -n "$5:-" ]] ; then { get_array_by_name "${5}" || return 1 ; (( ${#get_array_by_name_result[@]} > 0 )) && cmd+=("-m" "${get_array_by_name_result[@]}") ; } ; fi
39+
if [[ -n "$6:-" ]] ; then { get_array_by_name "${6}" || return 1 ; (( ${#get_array_by_name_result[@]} > 0 )) && cmd+=("--archives" "${get_array_by_name_result[@]}") ; } ; fi
40+
41+
"${cmd[@]}"
42+
1843
if [ "$BUILD_INSTALLER" = "true" ]; then
1944
[ -d $HOME/qtifw ] || env TRIK_QTIFW_INSTALL_DIR="$HOME/qtifw" "$(dirname $(realpath ${BASH_SOURCE[0]}))"/install_qtifw.sh
2045
fi

0 commit comments

Comments
 (0)