Skip to content

Commit 60bcf1d

Browse files
fix(windows-build): copy changes from origin/fix-find_conan-dep-script-windows to fix windows release build
1 parent cfd5348 commit 60bcf1d

File tree

4 files changed

+130
-131
lines changed

4 files changed

+130
-131
lines changed

conanfile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from conan import ConanFile
44
from conan.tools.cmake import CMakeToolchain, cmake_layout
55
from conan.tools.cmake.toolchain.blocks import VSRuntimeBlock
6+
from conan.tools.env import VirtualRunEnv
67

78

89
class KDriveDesktop(ConanFile):
@@ -11,7 +12,7 @@ class KDriveDesktop(ConanFile):
1112
url = "https://github.com/Infomaniak/desktop-kdrive"
1213

1314
settings = "os", "compiler", "build_type", "arch"
14-
generators = "CMakeDeps"
15+
generators = "CMakeDeps", "VirtualRunEnv"
1516

1617
def generate(self):
1718
"""

infomaniak-build-tools/conan/build_dependencies.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ if ($LASTEXITCODE -ne 0) {
201201
}
202202

203203
Log "Installing Conan dependencies..."
204-
& $ConanExe install . --output-folder="$OutputDir" --build=missing -s build_type=$BuildType --profile:all="$ConanProfile" -r $LocalRemoteName -r conancenter
204+
& $ConanExe install . --output-folder="$OutputDir" --build=missing -s build_type=$BuildType --profile:all="$ConanProfile" -r $LocalRemoteName -r conancenter -c tools.env.virtualenv:powershell=powershell
205205
if ($LASTEXITCODE -ne 0) {
206206
Err "Failed to install Conan dependencies."
207207
}

infomaniak-build-tools/conan/find_conan_dep.ps1

Lines changed: 25 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -16,87 +16,39 @@
1616
along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
#>
1818
param(
19-
[Parameter(Mandatory=$true)][string]$Package,
20-
[Parameter(Mandatory=$true)][string]$Version,
21-
[Parameter(Mandatory=$false)][switch]$CI = $false,
22-
[Parameter(Mandatory=$false)][switch]$VerboseLogging = $false,
23-
[Parameter(Mandatory=$false)][string]$PythonVenvPath = "C:\Program Files\Python313\.venv"
19+
[Parameter(Mandatory=$true)][string]$BuildDir,
20+
[Parameter(Mandatory=$true)][string]$Package
2421
)
2522

2623
function Log { Write-Host "[INFO] $($args -join ' ')" }
2724
function Err { Write-Error "[ERROR] $($args -join ' ')" ; exit 1 }
28-
function Get-ConanExePath {
29-
try {
30-
$cmd = Get-Command conan.exe -ErrorAction Stop
31-
return $cmd.Path
32-
} catch { }
3325

34-
try {
35-
$pythonCmd = Get-Command python -ErrorAction Stop
36-
if ($VerboseLogging) { Write-Error "python interpreter found at: $($pythonCmd.Path)" }
37-
} catch {
38-
Err "Interpreter 'python' not found. Please install Python 3 and/or add it to the PATH."
39-
return $null
40-
}
41-
42-
$pythonCode = @"
43-
import os, sys
44-
try:
45-
import conans
46-
except ImportError:
47-
sys.exit(1)
48-
modpath = conans.__file__
49-
prefix = modpath.split(os.sep + 'Lib' + os.sep)[0]
50-
exe = os.path.join(prefix, 'Scripts', 'conan.exe')
51-
print(exe)
52-
"@
53-
54-
$rawPath = & $pythonCmd.Path -c $pythonCode 2>$null
55-
$exePath = $rawPath.Trim()
56-
if ($LASTEXITCODE -ne 0 -or -not (Test-Path $exePath)) {
57-
Err "Unable to locate 'conan.exe' via Python."
58-
return $null
59-
}
60-
if ($VerboseLogging) { Write-Error "Conan executable found at: $($cmd.Path)" }
61-
return $exePath
26+
$runScript = Get-ChildItem -Path $BuildDir -Recurse -File -ErrorAction SilentlyContinue |
27+
Where-Object { $_.Name -ieq 'conanrun.ps1' } |
28+
Select-Object -First 1 -ExpandProperty FullName
29+
if (-not $runScript) {
30+
Err "Unable to recursively find conanrun.ps1 in '$BuildDir'."
6231
}
63-
64-
if ($CI) {
65-
& "$PythonVenvPath\Scripts\activate.ps1"
66-
if ($VerboseLogging) { Write-Error "CI Mode enabled." }
32+
& $runScript *> $null
33+
34+
$pathEntries = $env:PATH -split ';'
35+
$conanEntries = $pathEntries | Where-Object { $_ -match '\\.conan2\\p\\' }
36+
if (-not $conanEntries) { Err "No directories in PATH contain '.conan2/p/'." }
37+
$pkgValue = if ($Package.Length -ge 5) { $Package.Substring(0,5) } else { $Package }
38+
$matchingDirs = $conanEntries | Where-Object {
39+
(Split-Path (Split-Path (Split-Path $_ -Parent) -Parent) -Leaf) -like "$pkgValue*"
6740
}
68-
69-
$reference = "$Package/$Version"
70-
71-
# Vérification de sqlite3
72-
if (-not (Get-Command sqlite3 -ErrorAction SilentlyContinue)) {
73-
Err "Please install sqlite3 and add it to the PATH."
41+
if (-not $matchingDirs) {
42+
Err "No directories found in PATH matching the package '$Package' (prefix '$pkgValue')."
7443
}
75-
76-
$conan_exe = Get-ConanExePath
77-
if (-not $conan_exe) { Err "Conan executable not found." }
78-
if ($CI) {
79-
$conan_home = "C:\Windows\System32\config\systemprofile\.conan2"
80-
} else {
81-
$conan_home = & "$conan_exe" config home | Select-Object -First 1
82-
if ($VerboseLogging) { Write-Error "conan config home: $(conan_home)" }
44+
if ($matchingDirs.Count -gt 1) {
45+
Err "Multiple directories found in PATH matching the package '$Package' (prefix '$pkgValue'). Please specify a more precise package name."
8346
}
84-
$conan_db = Join-Path $conan_home "p\cache.sqlite3"
8547

86-
if (-not (Test-Path $conan_db)) {
87-
Err "Conan database not found at $conan_db. Please execute this script from the root of the project: ./infomaniak-build-tools/conan/build_dependencies.ps1"
88-
}
89-
90-
$sql_req = "SELECT path FROM packages WHERE reference='$reference' ORDER BY timestamp DESC LIMIT 1;"
91-
92-
$subpath = & sqlite3 "$conan_db" "$sql_req" 2>$null
93-
94-
if (-not $subpath) {
95-
Err "The reference '$reference' does not exists in the conan cache.."
96-
}
48+
$packageDir = $matchingDirs
49+
Write-Output $packageDir
9750

98-
if (-not (Test-Path (Join-Path $conan_home "p\$subpath\p"))) {
99-
Err "The path to the folder found, does not exists. : $(Join-Path $conan_home "p\$subpath\p")"
100-
} else {
101-
Write-Output (Join-Path $conan_home "p\$subpath\p")
102-
}
51+
$deactivateRunScript = Get-ChildItem -Path $BuildDir -Recurse -File -ErrorAction SilentlyContinue |
52+
Where-Object { $_.Name -ieq 'deactivate_conanrun.ps1' } |
53+
Select-Object -First 1 -ExpandProperty FullName
54+
& $deactivateRunScript *> $null

0 commit comments

Comments
 (0)