Skip to content

Commit 29566fc

Browse files
committed
Update build_windows.ps1
1 parent d47a515 commit 29566fc

File tree

2 files changed

+53
-21
lines changed

2 files changed

+53
-21
lines changed

.github/workflows/build_windows.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ jobs:
2222
- name: Cache installed dependencies
2323
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
2424
with:
25-
path: C:\mysql-connector-c++
25+
path: |
26+
dependencies
27+
C:\mysql-connector-c++
2628
key: win-deps-${{ hashFiles('build_windows.ps1') }}
2729
restore-keys: win-deps-
2830

@@ -47,7 +49,9 @@ jobs:
4749
- name: Cache installed dependencies
4850
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
4951
with:
50-
path: C:\mysql-connector-c++
52+
path: |
53+
dependencies
54+
C:\mysql-connector-c++
5155
key: win_arm-deps-${{ hashFiles('build_windows.ps1') }}
5256
restore-keys: win_arm-deps-
5357

build_windows.ps1

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# License, v. 2.0. If a copy of the MPL was not distributed with this
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

7+
$cacheDir = "dependencies\conan"
78
$buildDir = "build"
89
$installDir = ".\build\bin"
910
$buildType = "Debug"
@@ -41,21 +42,39 @@ $profilePath = (& conan profile path default).Trim()
4142
-replace '^(compiler\.cppstd=).*$', "compiler.cppstd=23" `
4243
| Set-Content $profilePath -Force
4344

44-
if (Test-Path Join-Path $buildDir "conan_cache.tzst") {
45-
conan cache restore $buildDir\conan_cache.tzst
45+
# Check if there's a conan cache to load
46+
if (Test-Path $cacheDir) {
47+
conan cache restore "$cacheDir\boost_cache.tzst"
48+
conan cache restore "$cacheDir\botan_cache.tzst"
49+
conan cache restore "$cacheDir\flatbuffers_cache.tzst"
50+
conan cache restore "$cacheDir\pcre_cache.tzst"
51+
conan cache restore "$cacheDir\zlib_cache.tzst"
4652
}
53+
else {
54+
if (-not (Test-Path $buildDir)) {
55+
New-Item -ItemType Directory -Path $buildDir | Out-Null
56+
}
4757

48-
# Dependencies to install via Conan.
49-
New-Item -ItemType Directory -Path $buildDir | Out-Null
50-
Write-Host "Running Conan install..."
51-
conan install -of $buildDir --build missing -g CMakeToolchain -g CMakeDeps --profile default `
52-
--requires boost/1.87.0 `
53-
--requires botan/3.6.1 `
54-
--requires flatbuffers/24.12.23 `
55-
--requires pcre/8.45 `
56-
--requires zlib/1.3.1 `
58+
# Dependencies to install via conan
59+
Write-Host "Running Conan install..."
60+
conan install -of $buildDir --build missing -g CMakeToolchain -g CMakeDeps --profile default `
61+
--requires boost/1.87.0 `
62+
--requires botan/3.6.1 `
63+
--requires flatbuffers/24.12.23 `
64+
--requires pcre/8.45 `
65+
--requires zlib/1.3.1
5766

58-
conan cache save -f $buildDir\conan_cache.tzst * --folder=$buildDir
67+
if (-not (Test-Path $cacheDir)) {
68+
New-Item -ItemType Directory -Path $cacheDir | Out-Null
69+
}
70+
71+
# Cache the dependencies installed via conan
72+
conan cache save --out-file "$cacheDir\boost_cache.tzst" "boost/1.87.0:*"
73+
conan cache save --out-file "$cacheDir\botan_cache.tzst" "botan/3.6.1:*"
74+
conan cache save --out-file "$cacheDir\flatbuffers_cache.tzst" "flatbuffers/24.12.23:*"
75+
conan cache save --out-file "$cacheDir\pcre_cache.tzst" "pcre/8.45:*"
76+
conan cache save --out-file "$cacheDir\zlib_cache.tzst" "zlib/1.3.1:*"
77+
}
5978

6079
####################################################
6180
# --- Patch Conan configuration ---
@@ -110,9 +129,9 @@ if (-not (Test-Path "C:\mysql-connector-c++\")) {
110129
# Determine architecture and set download parameters accordingly
111130
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
112131
Write-Host "ARM64 architecture detected. Downloading MySQL Connector/C++ source code."
113-
$url = "https://github.com/mysql/mysql-connector-cpp/archive/refs/tags/9.2.0.zip"
114-
$connectorSubDir = "mysql-connector-cpp-9.2.0"
115-
}
132+
$url = "https://github.com/mysql/mysql-connector-cpp/archive/refs/tags/9.3.0.zip"
133+
$connectorSubDir = "mysql-connector-cpp-9.3.0"
134+
}
116135
else {
117136
Write-Host "x86_64 architecture detected. Using prebuilt MySQL Connector/C++ binaries."
118137
$url = "https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-9.3.0-winx64-debug.zip"
@@ -123,11 +142,11 @@ if (-not (Test-Path "C:\mysql-connector-c++\")) {
123142
if (Get-Command curl -ErrorAction SilentlyContinue) {
124143
Write-Host "Downloading using curl..."
125144
curl -L $url -o $CACHE_ZIP
126-
}
145+
}
127146
elseif (Get-Command wget -ErrorAction SilentlyContinue) {
128147
Write-Host "Downloading using wget..."
129148
wget $url -O $CACHE_ZIP
130-
}
149+
}
131150
else {
132151
Write-Host "Downloading using Invoke-WebRequest..."
133152
Invoke-WebRequest -Uri $url -OutFile $CACHE_ZIP
@@ -155,10 +174,11 @@ if (-not (Test-Path "C:\mysql-connector-c++\")) {
155174
Write-Host "Installing MySQL Connector/C++ (prebuilt x86_64) to $mysqlconcppTargetDir..."
156175

157176
$sourceBase = Join-Path $extractDir "mysql-connector-c++-9.3.0-winx64"
158-
Copy-Item -Path (Join-Path $sourceBase "*") -Destination $mysqlconcppTargetDir -Recurse -Force
177+
Copy-Item -Path (Join-Path $sourceBase "*") `
178+
-Destination $mysqlconcppTargetDir -Recurse -Force
159179
}
160180
else {
161-
# For ARM64 (and others): Downloaded Source Build Required
181+
# For ARM64 (and others): Downloaded Source - Build Required
162182
New-Item -ItemType Directory -Path "$sourceBase\build" -Force | Out-Null
163183

164184
Push-Location "$sourceBase\build"
@@ -167,6 +187,7 @@ if (-not (Test-Path "C:\mysql-connector-c++\")) {
167187
cmake .. -G "Visual Studio 17 2022" -A $env:PROCESSOR_ARCHITECTURE `
168188
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>" `
169189
-DBUILD_STATIC=ON `
190+
-DOPENSSL_USE_STATIC_LIBS=TRUE `
170191
-DWITH_JDBC=ON `
171192
-DWITH_MYSQL="C:\Program Files\MySQL\MySQL Server 8.0" `
172193
-DWITH_SSL="C:\Program Files\OpenSSL-Win64" `
@@ -178,6 +199,11 @@ if (-not (Test-Path "C:\mysql-connector-c++\")) {
178199
Write-Host "Installing MySQL Connector/C++ to $mysqlconcppTargetDir..."
179200
cmake --install . --config $buildType
180201

202+
New-Item -ItemType Directory -Path "$mysqlconcppTargetDir\lib" -Force | Out-Null
203+
204+
Copy-Item -Path (Join-Path "$mysqlconcppTargetDir\lib64\debug\vs14" "*") `
205+
-Destination "$mysqlconcppTargetDir\lib" -Recurse -Force
206+
181207
Pop-Location
182208
}
183209
Write-Host "MySQL Connector/C++ installed at: $mysqlconcppTargetDir"
@@ -194,6 +220,8 @@ Write-Host "CMAKE_PREFIX_PATH set to: $env:CMAKE_PREFIX_PATH"
194220
####################################################
195221
Write-Host "=== Configuring project with CMake ==="
196222

223+
cmake --build $buildDir --target clean
224+
197225
cmake -S . -B $buildDir -G "Visual Studio 17 2022" `
198226
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>" `
199227
-DCMAKE_TOOLCHAIN_FILE="$buildDir\conan_toolchain.cmake" `

0 commit comments

Comments
 (0)