Skip to content

Commit

Permalink
Merge pull request #2328 from hoffie/build-Qt6-compat
Browse files Browse the repository at this point in the history
Build logic: Add Qt6 compatibility
  • Loading branch information
hoffie committed Feb 2, 2022
2 parents 8932460 + f454dab commit f56d8be
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 41 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/autobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ jobs:

- config_name: MacOS (artifacts)
target_os: macos
# Stay on 10.15 as long as we use dmgbuild which does not work with 11's hdiutil (?)
building_on_os: macos-10.15
cmd1_prebuild: "./autobuild/mac/artifacts/autobuild_mac_1_prepare.sh 5.15.2"
cmd2_build: "./autobuild/mac/artifacts/autobuild_mac_2_build.sh sign_if_possible"
cmd3_postbuild: "./autobuild/mac/artifacts/autobuild_mac_3_copy_files.sh"
uses_codeql: false
xcode_version: 11.7

- config_name: MacOS Legacy (artifacts)
target_os: macos
Expand All @@ -131,6 +133,9 @@ jobs:
cmd2_build: "./autobuild/mac/artifacts/autobuild_mac_2_build.sh do_not_sign"
cmd3_postbuild: "./autobuild/mac/artifacts/autobuild_mac_3_copy_files.sh legacy"
uses_codeql: false
# For Qt5 on Mac, we need to ensure SDK 10.15 is used, and not SDK 11.x
# This is done by selecting Xcode 11.7 instead of the latest default of 12.x
xcode_version: 11.7

- config_name: Windows (artifact+codeQL)
target_os: windows
Expand All @@ -151,13 +156,11 @@ jobs:
runs-on: ${{ matrix.config.building_on_os }}
steps:

# For Qt5 on Mac, we need to ensure SDK 10.15 is used, and not SDK 11.x
# This is done by selecting Xcode 11.7 instead of the latest default of 12.x
- name: Select Xcode version for Mac
if: ${{ matrix.config.target_os == 'macos' }}
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '11.7'
xcode-version: ${{ matrix.config.xcode_version }}

# Checkout code
- name: Checkout code
Expand Down
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
- Internal: Improved powershell redirect handling when building for Windows in Github (#2225).
(contributed by @henkdegroot)

- Internal: Prepared autobuild logic for upcoming Qt6 compatibility (#2328).
(contributed by @hoffie, @softins)


### 3.8.1 (2021-10-23) ###

Expand Down
8 changes: 7 additions & 1 deletion autobuild/mac/artifacts/autobuild_mac_1_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ python3 -m pip install aqtinstall
python3 -m aqt install-qt --outputdir /usr/local/opt/qt mac desktop ${QT_VER}

# add the qt binaries to the path
export -p PATH=/usr/local/opt/qt/${QT_VER}/clang_64/bin:"${PATH}"
# The clang_64 entry can be dropped when Qt <6.2 compatibility is no longer needed.
for qt_path in /usr/local/opt/qt/${QT_VER}/macos/bin /usr/local/opt/qt/${QT_VER}/clang_64/bin; do
if [[ -d $qt_path ]]; then
export -p PATH="${qt_path}:${PATH}"
break
fi
done
echo "::set-env name=PATH::${PATH}"
echo "the path is ${PATH}"

8 changes: 7 additions & 1 deletion autobuild/mac/codeQL/autobuild_mac_1_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ python3 -m pip install aqtinstall
python3 -m aqt install-qt --outputdir /usr/local/opt/qt mac desktop ${QT_VER}

# add the qt binaries to the path
export -p PATH=/usr/local/opt/qt/${QT_VER}/clang_64/bin:"${PATH}"
# The clang_64 entry can be dropped when Qt <6.2 compatibility is no longer needed.
for qt_path in /usr/local/opt/qt/${QT_VER}/macos/bin /usr/local/opt/qt/${QT_VER}/clang_64/bin; do
if [[ -d $qt_path ]]; then
export -p PATH="${qt_path}:${PATH}"
break
fi
done
echo "::set-env name=PATH::${PATH}"
echo "the path is ${PATH}"

4 changes: 2 additions & 2 deletions autobuild/windows/autobuild_windowsinstaller_2_build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ echo "Build installer..."
# Build the installer
if ($BuildOption -ne "")
{
powershell "$jamulus_project_path\windows\deploy_windows.ps1" "C:\Qt\5.15.2" -BuildOption $BuildOption
powershell "$jamulus_project_path\windows\deploy_windows.ps1" "C:\Qt\5.15.2" "C:\Qt\5.15.2" -BuildOption $BuildOption
}
else
{
powershell "$jamulus_project_path\windows\deploy_windows.ps1" "C:\Qt\5.15.2"
powershell "$jamulus_project_path\windows\deploy_windows.ps1" "C:\Qt\5.15.2" "C:\Qt\5.15.2"
}
if ( !$? )
{
Expand Down
79 changes: 45 additions & 34 deletions windows/deploy_windows.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
param (
# Replace default path with system Qt installation folder if necessary
[string] $QtInstallPath = "C:\Qt\5.15.2",
[string] $QtInstallPath32 = "C:\Qt\5.15.2",
[string] $QtInstallPath64 = "C:\Qt\5.15.2",
[string] $QtCompile32 = "msvc2019",
[string] $QtCompile64 = "msvc2019_64",
[string] $AsioSDKName = "asiosdk_2.3.3_2019-06-14",
Expand Down Expand Up @@ -139,8 +140,6 @@ Function Install-Dependencies
Function Initialize-Build-Environment
{
param(
[Parameter(Mandatory=$true)]
[string] $QtInstallPath,
[Parameter(Mandatory=$true)]
[string] $BuildArch
)
Expand All @@ -155,43 +154,25 @@ Function Initialize-Build-Environment
if ($BuildArch -Eq "x86_64")
{
$VcVarsBin = "$VsInstallPath\VC\Auxiliary\build\vcvars64.bat"
$QtMsvcSpecPath = "$QtInstallPath\$QtCompile64\bin"
}
else
{
$VcVarsBin = "$VsInstallPath\VC\Auxiliary\build\vcvars32.bat"
$QtMsvcSpecPath = "$QtInstallPath\$QtCompile32\bin"
}

# Setup Qt executables paths for later calls
Set-Item Env:QtQmakePath "$QtMsvcSpecPath\qmake.exe"
Set-Item Env:QtWinDeployPath "$QtMsvcSpecPath\windeployqt.exe"

""
"**********************************************************************"
"Using Visual Studio/Build Tools environment settings located at"
$VcVarsBin
"**********************************************************************"
""
"**********************************************************************"
"Using Qt binaries for Visual C++ located at"
$QtMsvcSpecPath
"**********************************************************************"
""

if (-Not (Test-Path -Path $VcVarsBin))
{
Throw "Microsoft Visual Studio ($BuildArch variant) is not installed. " + `
"Please install Visual Studio 2017 or above it before running this script."
}

if (-Not (Test-Path -Path $Env:QtQmakePath))
{
Throw "The Qt binaries for Microsoft Visual C++ 2017 or above could not be located at $QtMsvcSpecPath. " + `
"Please install Qt with support for MSVC 2017 or above before running this script," + `
"then call this script with the Qt install location, for example C:\Qt\5.15.2"
}

# Import environment variables set by vcvarsXX.bat into current scope
$EnvDump = [System.IO.Path]::GetTempFileName()
Invoke-Native-Command -Command "cmd" `
Expand All @@ -208,6 +189,36 @@ Function Initialize-Build-Environment
Remove-Item -Path $EnvDump -Force
}

# Setup Qt environment variables and build tool paths
Function Initialize-Qt-Build-Environment
{
param(
[Parameter(Mandatory=$true)]
[string] $QtInstallPath,
[Parameter(Mandatory=$true)]
[string] $QtCompile
)

$QtMsvcSpecPath = "$QtInstallPath\$QtCompile\bin"

# Setup Qt executables paths for later calls
Set-Item Env:QtQmakePath "$QtMsvcSpecPath\qmake.exe"
Set-Item Env:QtWinDeployPath "$QtMsvcSpecPath\windeployqt.exe"

"**********************************************************************"
"Using Qt binaries for Visual C++ located at"
$QtMsvcSpecPath
"**********************************************************************"
""

if (-Not (Test-Path -Path $Env:QtQmakePath))
{
Throw "The Qt binaries for Microsoft Visual C++ 2017 or above could not be located at $QtMsvcSpecPath. " + `
"Please install Qt with support for MSVC 2017 or above before running this script," + `
"then call this script with the Qt install location, for example C:\Qt\5.15.2"
}
}

# Build Jamulus x86_64 and x86
Function Build-App
{
Expand Down Expand Up @@ -236,15 +247,19 @@ Function Build-App
# Build and deploy Jamulus 64bit and 32bit variants
function Build-App-Variants
{
param(
[Parameter(Mandatory=$true)]
[string] $QtInstallPath
)

foreach ($_ in ("x86_64", "x86"))
{
$OriginalEnv = Get-ChildItem Env:
Initialize-Build-Environment -QtInstallPath $QtInstallPath -BuildArch $_
if ($_ -eq "x86")
{
Initialize-Build-Environment -BuildArch $_
Initialize-Qt-Build-Environment -QtInstallPath $QtInstallPath32 -QtCompile $QtCompile32
}
else
{
Initialize-Build-Environment -BuildArch $_
Initialize-Qt-Build-Environment -QtInstallPath $QtInstallPath64 -QtCompile $QtCompile64
}
Build-App -BuildConfig "release" -BuildArch $_
$OriginalEnv | % { Set-Item "Env:$($_.Name)" $_.Value }
}
Expand Down Expand Up @@ -286,16 +301,12 @@ Function Build-Installer
# Build and copy NS-Process dll
Function Build-NSProcess
{
param(
[Parameter(Mandatory=$true)]
[string] $QtInstallPath
)
if (!(Test-Path -path "$WindowsPath\nsProcess.dll")) {

echo "Building nsProcess..."

$OriginalEnv = Get-ChildItem Env:
Initialize-Build-Environment -QtInstallPath $QtInstallPath -BuildArch "x86"
Initialize-Build-Environment -BuildArch "x86"

Invoke-Native-Command -Command "msbuild" `
-Arguments ("$WindowsPath\nsProcess\nsProcess.sln", '/p:Configuration="Release UNICODE"', `
Expand All @@ -309,6 +320,6 @@ Function Build-NSProcess

Clean-Build-Environment
Install-Dependencies
Build-App-Variants -QtInstallPath $QtInstallPath
Build-NSProcess -QtInstallPath $QtInstallPath
Build-App-Variants
Build-NSProcess
Build-Installer -BuildOption $BuildOption

0 comments on commit f56d8be

Please sign in to comment.