Skip to content

Commit 05aa747

Browse files
committed
Add ci scripts
1 parent a48c06a commit 05aa747

File tree

3 files changed

+199
-0
lines changed

3 files changed

+199
-0
lines changed

scripts/ci/Build.ps1

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
param(
2+
[Parameter(Mandatory = $true)]
3+
[ValidateSet("dev", "alpha", "beta", "release")]
4+
[string]$BuildType,
5+
6+
[Parameter(Mandatory = $true)]
7+
[ValidateNotNullOrEmpty()]
8+
[string]$VcpkgRootDir,
9+
10+
[string]$VersionIdentifier = "0"
11+
)
12+
13+
if (-not (Test-Path $VcpkgRootDir)) {
14+
Write-Error "Vcpkg root directory does not exist: $VcpkgRootDir"
15+
exit 1
16+
}
17+
18+
Write-Host "Build type: $BuildType"
19+
Write-Host "Commit: $Commit"
20+
Write-Host "Vcpkg root directory: $VcpkgRootDir"
21+
22+
$cmakeListsPath = "CMakeLists.txt"
23+
24+
$cmakeContent = Get-Content $cmakeListsPath -Raw
25+
$projectMatch = [regex]::Match($cmakeContent, 'project\s*\(\s*(\w+)\s+VERSION\s+([\d.]+)')
26+
27+
if (-not $projectMatch.Success) {
28+
Write-Error "Could not find project declaration with VERSION in CMakeLists.txt"
29+
exit 1
30+
}
31+
32+
$projectName = $projectMatch.Groups[1].Value
33+
$version = $projectMatch.Groups[2].Value
34+
35+
Write-Host "Project name: $projectName"
36+
Write-Host "Project version: $version"
37+
38+
$applicationName = $projectName
39+
$applicationDisplayName = $projectName
40+
$semver = $version
41+
42+
switch ($BuildType) {
43+
"dev" {
44+
$applicationName += "_dev"
45+
$applicationDisplayName += " (Dev)"
46+
$semver += "+$VersionIdentifier"
47+
}
48+
"alpha" {
49+
$applicationName += "_alpha"
50+
$applicationDisplayName += " (Alpha)"
51+
$semver += "-alpha.$VersionIdentifier"
52+
}
53+
"beta" {
54+
$semver += "-beta.$VersionIdentifier"
55+
}
56+
"release" {
57+
# No changes needed for release
58+
}
59+
}
60+
61+
Write-Host "Application name: $applicationName"
62+
Write-Host "Application display name: $applicationDisplayName"
63+
Write-Host "Semver: $semver"
64+
65+
$installerFileBase = "${applicationName}_$($semver -replace '[\.\-\+]', '_')_installer"
66+
67+
cmake -B build -G Ninja `
68+
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
69+
"-DCMAKE_TOOLCHAIN_FILE=$(Join-Path $VcpkgRootDir scripts/buildsystems/vcpkg.cmake)" `
70+
-DCK_ENABLE_CONSOLE:BOOL=FALSE `
71+
-DAPPLICATION_INSTALL:BOOL=ON `
72+
-DAPPLICATION_CONFIGURE_INSTALLER:BOOL=ON `
73+
-DINNOSETUP_USE_UNOFFICIAL_LANGUAGE:BOOL=ON `
74+
"-DAPPLICATION_INSTALLER_OUTPUT_DIR=$(Resolve-Path .)" `
75+
"-DAPPLICATION_INSTALLER_FILE_BASE=$installerFileBase" `
76+
"-DAPPLICATION_NAME=$applicationName" `
77+
"-DAPPLICATION_DISPLAY_NAME=$applicationDisplayName" `
78+
"-DAPPLICATION_SEMVER=$semver" `
79+
-DCMAKE_INSTALL_PREFIX=installed
80+
81+
cmake --build build --target all
82+
cmake --build build --target install
83+
84+
$buildResult = @{
85+
ProjectName = $projectName
86+
Version = $version
87+
ApplicationName = $applicationName
88+
ApplicationDisplayName = $applicationDisplayName
89+
Semver = $semver
90+
BuildDir = $(Resolve-Path "build")
91+
InstalledDir = $(Resolve-Path "installed")
92+
InstallerFileBase = $installerFileBase
93+
}
94+
95+
Write-Output $buildResult
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
param(
2+
[Parameter(Mandatory = $true)]
3+
[ValidateNotNullOrEmpty()]
4+
[string]$VcpkgRootDir,
5+
6+
[Parameter(Mandatory = $true)]
7+
[ValidateNotNullOrEmpty()]
8+
[string]$InstalledDir
9+
)
10+
11+
$symbolFilesDirectory = [System.IO.Path]::GetTempPath() + "DiffScope-Symbols"
12+
New-Item -ItemType Directory -Force -Path $symbolFilesDirectory
13+
14+
if ($IsWindows) {
15+
$PATTERN = "PDB file found at.*'(.*)'"
16+
$env:_NT_ALT_SYMBOL_PATH = $(Join-Path $VcpkgRootDir "/installed/x64-windows/bin")
17+
18+
Push-Location $InstalledDir
19+
$dllFiles = Get-ChildItem -Path . -Recurse | Where-Object { $_.Extension -eq '.exe' -or $_.Extension -eq '.dll' }
20+
foreach ($dllFile in $dllFiles) {
21+
dumpbin /PDBPATH:VERBOSE $dllFile.FullName
22+
$dumpbinOutput = dumpbin /PDBPATH $dllFile.FullName
23+
$matches = [regex]::Matches($dumpbinOutput, $PATTERN)
24+
if ($matches.Count -gt 0) {
25+
$pdbPath = $matches.Groups[1].Value
26+
Write-Output "$dllFile -> $pdbPath"
27+
$pdbTargetDirectory = "$symbolFilesDirectory/$(Split-Path $(Resolve-Path $dllFile.FullName -Relative))"
28+
if (!(Test-Path $pdbTargetDirectory)) {
29+
New-Item $pdbTargetDirectory -ItemType directory
30+
}
31+
Copy-Item $pdbPath $pdbTargetDirectory
32+
} else {
33+
Write-Output "No PDB file: $dllFile"
34+
}
35+
}
36+
Pop-Location
37+
} elseif ($IsMacOS) {
38+
Push-Location $InstalledDir
39+
$dllFiles = Get-ChildItem -Path . -Recurse | Where-Object { (file $_) -match "Mach-O 64-bit" }
40+
foreach ($dllFile in $dllFiles) {
41+
$dsymutilOutput = dsymutil -s $dllFile.FullName
42+
if ($dsymutilOutput -match "N_OSO") {
43+
Write-Output "Copy and strip debug_info: $dllFile"
44+
$pdbTargetDirectory = "$symbolFilesDirectory/$(Split-Path $(Resolve-Path $dllFile.FullName -Relative))"
45+
if (!(Test-Path $pdbTargetDirectory)) {
46+
New-Item $pdbTargetDirectory -ItemType directory
47+
}
48+
dsymutil $dllFile.FullName -o "$pdbTargetDirectory/$($dllFile.Name).dSYM"
49+
strip -S $dllFile.FullName
50+
} else {
51+
Write-Output "Skip: $dllFile"
52+
}
53+
}
54+
Pop-Location
55+
} else {
56+
Push-Location $InstalledDir
57+
$dllFiles = Get-ChildItem -Path . -Recurse | Where-Object { (file $_) -match "ELF 64-bit" }
58+
foreach ($dllFile in $dllFiles) {
59+
file $dllFile.FullName
60+
$fileOutput = file $dllFile.FullName
61+
if ($fileOutput -match "with debug_info") {
62+
Write-Output "Copy and strip debug_info: $dllFile"
63+
$pdbTargetDirectory = "$symbolFilesDirectory/$(Split-Path $(Resolve-Path $dllFile.FullName -Relative))"
64+
if (!(Test-Path $pdbTargetDirectory)) {
65+
New-Item $pdbTargetDirectory -ItemType directory
66+
}
67+
objcopy --only-keep-debug $dllFile.FullName "$pdbTargetDirectory/$($dllFile.Name).debug"
68+
strip --strip-debug $dllFile.FullName
69+
} else {
70+
Write-Output "Skip: $dllFile"
71+
}
72+
}
73+
Pop-Location
74+
}
75+
76+
7z a -t7z -mx=9 -ms=on symbol_files.7z $symbolFilesDirectory
77+
Remove-Item -Recurse -Force $symbolFilesDirectory
78+
Write-Output $(Resolve-Path symbol_files.7z)

scripts/ci/Pack.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
param(
2+
[Parameter(Mandatory = $true)]
3+
[ValidateNotNullOrEmpty()]
4+
[string]$BuildDir,
5+
6+
[Parameter(Mandatory = $true)]
7+
[ValidateNotNullOrEmpty()]
8+
[string]$InstallerFileBase,
9+
10+
[Parameter(Mandatory = $true)]
11+
[ValidateNotNullOrEmpty()]
12+
[string]$InnoSetupCommit
13+
)
14+
15+
if ($IsWindows) {
16+
$env:INNOSETUP_MESSAGE_FILES_DIR = [System.IO.Path]::GetTempPath() + "Unofficial-InnoSetup-Languages"
17+
New-Item -ItemType Directory -Force -Path $env:INNOSETUP_MESSAGE_FILES_DIR
18+
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/jrsoftware/issrc/$InnoSetupCommit/Files/Languages/Unofficial/ChineseSimplified.isl" -OutFile "$env:INNOSETUP_MESSAGE_FILES_DIR\ChineseSimplified.isl"
19+
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/jrsoftware/issrc/$InnoSetupCommit/Files/Languages/Unofficial/ChineseTraditional.isl" -OutFile "$env:INNOSETUP_MESSAGE_FILES_DIR\ChineseTraditional.isl"
20+
ISCC $BuildDir/dist/installer/windows/setup.iss
21+
if (! (Test-Path "${InstallerFileBase}.exe")) {
22+
Write-Error "Installer file was not created: ${InstallerFileBase}.exe"
23+
exit 1
24+
}
25+
Write-Output $(Resolve-Path "${InstallerFileBase}.exe")
26+
}

0 commit comments

Comments
 (0)