Skip to content

Commit

Permalink
workflows built Qt QMYSQL driver 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Jun 9, 2024
1 parent f55eb0e commit f7965bf
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 112 deletions.
77 changes: 33 additions & 44 deletions .github/workflows/clang-cl-qt6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:

runs-on: windows-2022

env:
TINY_QT_VERSION: 6.7.1
TINY_QT_SPEC: msvc2019_64

steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -535,60 +539,50 @@ jobs:
postgres.exe --version
Write-Output '::endgroup::'
- name: Qt 6.7.1 install base components
- name: Visual Studio 2022 pwsh shell setup
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- name: Qt ${{ env.TINY_QT_VERSION }} install base components
uses: jurplel/install-qt-action@v3
with:
archives: qtbase
version: 6.7.1
arch: win64_msvc2019_64
version: ${{ env.TINY_QT_VERSION }}
arch: win64_${{ env.TINY_QT_SPEC }}
source: true
src-archives: qtbase
cache: true
setup-python: false
extra: --external 7z.exe
dir: ${{ env.TinyRunnerWorkPath }}

- name: QMYSQL driver dlls initialize download (Qt 6.7.1)
id: downloads-initialize-qmysql-dlls
- name: QMYSQL driver DLLs initialize
id: compiles-initialize-qmysql-dlls
run: |
$filename = (Split-Path -Path $env:URL_QMYSQL_DLLS_MSVC_X64_6_7_1 -Leaf)
"Filename=$filename" >> $env:GITHUB_OUTPUT
$filepath = Join-Path -Path ${{ runner.temp }} -ChildPath $filename
"Filepath=$filepath" >> $env:GITHUB_OUTPUT
$response = Invoke-WebRequest -Uri $env:URL_CACHE_HASH_WINDOWS
"Hash=$($response.Content)" >> $env:GITHUB_OUTPUT
env:
URL_QMYSQL_DLLS_MSVC_X64_6_7_1: ${{ secrets.URL_QMYSQL_DLLS_MSVC_X64_6_7_1 }}
URL_CACHE_HASH_WINDOWS: ${{ secrets.URL_CACHE_HASH_WINDOWS }}
$qtVersion = $env:TINY_QT_VERSION.Replace('.', '')
"QtVersion=$qtVersion" >> $env:GITHUB_OUTPUT
- name: QMYSQL driver dlls restore cache (download)
- name: QMYSQL driver DLLs restore cache
uses: actions/cache@v3
id: downloads-cache-qmysql-dlls
id: compiles-cache-qmysql-dlls
with:
path: ${{ env.archive_filepath }}
key: ${{ runner.os }}-drivers-${{ env.cache_name }}-${{ env.cache_hash }}
path: |
${{ env.QT_PLUGIN_PATH }}/sqldrivers/qsqlmysql*.dll
${{ env.QT_PLUGIN_PATH }}/sqldrivers/qsqlmysql*.pdb
key: ${{ runner.os }}-drivers-${{ env.cache_name }}-${{ env.qt_version }}
env:
archive_filepath: ${{ steps.downloads-initialize-qmysql-dlls.outputs.Filepath }}
cache_hash: ${{ steps.downloads-initialize-qmysql-dlls.outputs.Hash }}
cache_name: qmysql-dlls-qt6
cache_name: qmysql-dlls-qt
qt_version: ${{ steps.compiles-initialize-qmysql-dlls.outputs.QtVersion }}

- name: QMYSQL driver dlls download (Qt 6.7.1)
if: steps.downloads-cache-qmysql-dlls.outputs.cache-hit != 'true'
- name: QMYSQL driver DLLs build and install 🚀 (Qt ${{ env.TINY_QT_VERSION }})
if: steps.compiles-cache-qmysql-dlls.outputs.cache-hit != 'true'
run: >-
$response = Invoke-WebRequest -Uri $env:URL_QMYSQL_DLLS_MSVC_X64_6_7_1
$response | Select-Object -ExpandProperty Content |
Set-Content -Path $env:archive_filepath -AsByteStream
env:
archive_filepath: ${{ steps.downloads-initialize-qmysql-dlls.outputs.Filepath }}
URL_QMYSQL_DLLS_MSVC_X64_6_7_1: ${{ secrets.URL_QMYSQL_DLLS_MSVC_X64_6_7_1 }}

- name: QMYSQL driver dlls install (Qt 6.7.1)
working-directory: ${{ runner.temp }}
run: |
7z.exe x -y -o"$env:QT_PLUGIN_PATH/sqldrivers" $env:archive_filepath
env:
archive_filepath: ${{ steps.downloads-initialize-qmysql-dlls.outputs.Filepath }}
./tools/qtbuild-qmysql-driver.ps1 -SkipInitializeBuildEnvironment
-QtRootPath (Get-Item -Path $env:QT_PLUGIN_PATH).Parent.Parent.Parent
-QtVersion $env:TINY_QT_VERSION -QtSpec $env:TINY_QT_SPEC
-MySQLServerPath $env:TinyMySQLInstallationPath
-BuildPath '${{ runner.workspace }}'
- name: Cache LLVM and Clang
id: llvm-cache
Expand Down Expand Up @@ -649,11 +643,6 @@ jobs:
ccache.exe --show-config
Write-Output '::endgroup::'
- name: Visual Studio 2022 pwsh shell setup
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

# Must be after the ilammy/msvc-dev-cmd@v1 because vcvars64 overrides the VCPKG_ROOT
- name: vcpkg prepare environment
run: |
Expand Down
76 changes: 33 additions & 43 deletions .github/workflows/msvc2022-qt6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:

runs-on: windows-2022

env:
TINY_QT_VERSION: 6.7.1
TINY_QT_SPEC: msvc2019_64

strategy:
matrix:
build-type:
Expand Down Expand Up @@ -548,59 +552,50 @@ jobs:
postgres.exe --version
Write-Output '::endgroup::'
- name: Qt 6.7.1 install base components
- name: Visual Studio 2022 pwsh shell setup
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- name: Qt ${{ env.TINY_QT_VERSION }} install base components
uses: jurplel/install-qt-action@v3
with:
archives: qtbase
version: 6.7.1
arch: win64_msvc2019_64
version: ${{ env.TINY_QT_VERSION }}
arch: win64_${{ env.TINY_QT_SPEC }}
source: true
src-archives: qtbase
cache: true
setup-python: false
extra: --external 7z.exe
dir: ${{ env.TinyRunnerWorkPath }}

- name: QMYSQL driver dlls initialize download (Qt 6.7.1)
id: downloads-initialize-qmysql-dlls
- name: QMYSQL driver DLLs initialize
id: compiles-initialize-qmysql-dlls
run: |
$filename = (Split-Path -Path $env:URL_QMYSQL_DLLS_MSVC_X64_6_7_1 -Leaf)
"Filename=$filename" >> $env:GITHUB_OUTPUT
$filepath = Join-Path -Path ${{ runner.temp }} -ChildPath $filename
"Filepath=$filepath" >> $env:GITHUB_OUTPUT
$response = Invoke-WebRequest -Uri $env:URL_CACHE_HASH_WINDOWS
"Hash=$($response.Content)" >> $env:GITHUB_OUTPUT
env:
URL_QMYSQL_DLLS_MSVC_X64_6_7_1: ${{ secrets.URL_QMYSQL_DLLS_MSVC_X64_6_7_1 }}
URL_CACHE_HASH_WINDOWS: ${{ secrets.URL_CACHE_HASH_WINDOWS }}
$qtVersion = $env:TINY_QT_VERSION.Replace('.', '')
"QtVersion=$qtVersion" >> $env:GITHUB_OUTPUT
- name: QMYSQL driver dlls restore cache (download)
- name: QMYSQL driver DLLs restore cache
uses: actions/cache@v3
id: downloads-cache-qmysql-dlls
id: compiles-cache-qmysql-dlls
with:
path: ${{ env.archive_filepath }}
key: ${{ runner.os }}-drivers-${{ env.cache_name }}-${{ env.cache_hash }}
path: |
${{ env.QT_PLUGIN_PATH }}/sqldrivers/qsqlmysql*.dll
${{ env.QT_PLUGIN_PATH }}/sqldrivers/qsqlmysql*.pdb
key: ${{ runner.os }}-drivers-${{ env.cache_name }}-${{ env.qt_version }}
env:
archive_filepath: ${{ steps.downloads-initialize-qmysql-dlls.outputs.Filepath }}
cache_hash: ${{ steps.downloads-initialize-qmysql-dlls.outputs.Hash }}
cache_name: qmysql-dlls-qt6
cache_name: qmysql-dlls-qt
qt_version: ${{ steps.compiles-initialize-qmysql-dlls.outputs.QtVersion }}

- name: QMYSQL driver dlls download (Qt 6.7.1)
if: steps.downloads-cache-qmysql-dlls.outputs.cache-hit != 'true'
- name: QMYSQL driver DLLs build and install 🚀 (Qt ${{ env.TINY_QT_VERSION }})
if: steps.compiles-cache-qmysql-dlls.outputs.cache-hit != 'true'
run: >-
$response = Invoke-WebRequest -Uri $env:URL_QMYSQL_DLLS_MSVC_X64_6_7_1
$response | Select-Object -ExpandProperty Content |
Set-Content -Path $env:archive_filepath -AsByteStream
env:
archive_filepath: ${{ steps.downloads-initialize-qmysql-dlls.outputs.Filepath }}
URL_QMYSQL_DLLS_MSVC_X64_6_7_1: ${{ secrets.URL_QMYSQL_DLLS_MSVC_X64_6_7_1 }}

- name: QMYSQL driver dlls install (Qt 6.7.1)
run: |
7z.exe x -y -o"$env:QT_PLUGIN_PATH/sqldrivers" $env:archive_filepath
env:
archive_filepath: ${{ steps.downloads-initialize-qmysql-dlls.outputs.Filepath }}
./tools/qtbuild-qmysql-driver.ps1 -SkipInitializeBuildEnvironment
-QtRootPath (Get-Item -Path $env:QT_PLUGIN_PATH).Parent.Parent.Parent
-QtVersion $env:TINY_QT_VERSION -QtSpec $env:TINY_QT_SPEC
-MySQLServerPath $env:TinyMySQLInstallationPath
-BuildPath '${{ runner.workspace }}'
- name: Ccache initialize
id: ccache-initialize-cache
Expand Down Expand Up @@ -647,11 +642,6 @@ jobs:
ccache.exe --show-config
Write-Output '::endgroup::'
- name: Visual Studio 2022 pwsh shell setup
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

# Must be after the ilammy/msvc-dev-cmd@v1 because vcvars64 overrides the VCPKG_ROOT
- name: vcpkg prepare environment
run: |
Expand Down
61 changes: 36 additions & 25 deletions tools/qtbuild-qmysql-driver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,37 @@ Param(
'The argument "{0}" does not match the "{1}" pattern.')]
[string] $MySQLVersion = '8.4',

[Parameter(HelpMessage = 'Clean CMake build (delete the $QtVersion build folder).')]
[switch] $CleanBuild,

[Parameter(
HelpMessage = 'Specifies the main Qt path, is $env:TINY_QT_ROOT or C:\Qt by default.')]
[ValidateNotNullOrEmpty()]
[string] $QtRootPath,

[Parameter(
HelpMessage = 'Specifies the MySQL server installation path, by default is guessed using ' +
'the MySQLVersion argument in the default $env:ProgramFiles installation location.')]
[ValidateNotNullOrEmpty()]
[string] $MySQLServerPath,

[Parameter(HelpMessage = 'Clean CMake build (delete the $QtVersion build folder).')]
[switch] $CleanBuild,

[Parameter(
HelpMessage = 'Specifies the parent path to the CMake build folders, is pwd by default.')]
HelpMessage = 'Specifies the parent path to the CMake build folders, ' +
'is $env:TINY_QT_QMYSQL_BUILD_PATH or pwd by default.')]
[ValidateNotNullOrEmpty()]
[string] $BuildPath,

[Parameter(
HelpMessage = 'Specifies the Qt spec and is used in the CMAKE_INSTALL_PREFIX, is msvc2019_64 by default.')]
HelpMessage = 'Specifies the Qt spec and is used in the CMAKE_INSTALL_PREFIX, ' +
'is msvc2019_64 by default.')]
[ValidateNotNullOrEmpty()]
[string] $QtSpec = 'msvc2019_64',

[Parameter(HelpMessage = 'Specifies whether to install the QMYSQL drivers.')]
[switch] $NoInstall
[switch] $NoInstall,

[Parameter(HelpMessage = 'Specifies whether to skip initializing Build and Qt environments.')]
[switch] $SkipInitializeBuildEnvironment
)

Set-StrictMode -Version 3.0
Expand All @@ -53,7 +63,9 @@ Set-StrictMode -Version 3.0
# ---
Set-Variable STACK_NAME -Option Constant -Value $MyInvocation.MyCommand.Name

$Script:QtRoot = $env:TINY_QT_ROOT ?? 'C:\Qt'
$Script:QtRoot = $PSBoundParameters.ContainsKey('QtRootPath') `
? $QtRootPath
: $env:TINY_QT_ROOT ?? 'C:\Qt'
$Script:QtRoot = Get-FullPath -Path $Script:QtRoot
$Script:QtRootAlt = $Script:QtRoot.Replace('\', '/')
$Script:QtMajorVersion = $null
Expand All @@ -66,8 +78,6 @@ $Script:BuildPath = $PSBoundParameters.ContainsKey('BuildPath') `
? $BuildPath
: $env:TINY_QT_QMYSQL_BUILD_PATH ?? $(Get-Location).Path
$Script:BuildPath = Get-FullPath -Path $Script:BuildPath
$Script:IsCWD = -not $PSBoundParameters.ContainsKey('BuildPath') -and
$null -eq $env:TINY_QT_QMYSQL_BUILD_PATH
$Script:QtSqlDriversBuildPath = $null
$Script:BOL = ' '

Expand Down Expand Up @@ -138,10 +148,10 @@ function Test-MySQLServerInstalled
"in the '$Script:MySqlServerPath' folder.")
}

# Create the root Qt sqldrivers build folder
# Create the main Qt sqldrivers build folder
function New-QtSqlDriversBuildPath
{
Write-Progress 'Creating the root Qt sqldrivers build folder'
Write-Progress 'Creating the main Qt sqldrivers build folder'

$Script:QtSqlDriversBuildPath = "${Script:BuildPath}\qt${Script:QtMajorVersion}_sqldrivers"

Expand Down Expand Up @@ -172,7 +182,7 @@ function New-BuildFolders
{
Write-Progress 'Creating build folders'

$relWithDebInfoPath = Join-Path -Path $PWD -ChildPath "./$QtVersion/$QtSpec/RelWithDebInfo"
$relWithDebInfoPath = Join-Path -Path $PWD -ChildPath "$QtVersion/$QtSpec/RelWithDebInfo"

if (-not (Test-Path $relWithDebInfoPath)) {
New-Item -Type Directory -Path $relWithDebInfoPath | Out-Null
Expand Down Expand Up @@ -245,7 +255,9 @@ function Initialize-QtEnvironment
# Preparations
# ---

# Clear-Host
if (-not (Test-Path env:RUNNER_ENVIRONMENT)) {
Clear-Host
}

Write-Header "Preparations"

Expand All @@ -256,18 +268,20 @@ Test-QtSourcesInstalled
Test-MySQLServerInstalled

# Initialize the Qt and MSVC build environment if it's not already there
Initialize-QtEnvironment
Test-BuildEnvironment
if (-not $SkipInitializeBuildEnvironment) {
Initialize-QtEnvironment
Test-BuildEnvironment
}
else {
Write-Error 'Skipping Qt and MSVC build environment initialization'
}

# Prepare the build folder
# Create the root Qt sqldrivers build folder
# Create the main Qt sqldrivers build folder
New-QtSqlDriversBuildPath

# Not needed if building in the CWD
if (-not $Script:IsCWD) {
Push-Location -StackName $STACK_NAME
Set-Location $Script:QtSqlDriversBuildPath
}
Push-Location -StackName $STACK_NAME
Set-Location $Script:QtSqlDriversBuildPath

# Remove $QtVersion build folder if the $CleanBuild was passed
Invoke-CleanBuild
Expand Down Expand Up @@ -335,10 +349,7 @@ cmake --build . --target ($NoInstall ? 'all' : 'install')
# Done
# ---

# Not needed if building in the CWD
if (-not $Script:IsCWD) {
Pop-Location -StackName $STACK_NAME
}
Pop-Location -StackName $STACK_NAME

Newline
Write-Progress 'Linked against the MySQL Server at: ' -NoNewline
Expand Down

0 comments on commit f7965bf

Please sign in to comment.