2020-07-24 21:39:27 +03:00
|
|
|
<#
|
|
|
|
|
|
|
|
.SYNOPSIS
|
|
|
|
This script assembles the archives into a distribution.
|
|
|
|
|
|
|
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
Set-StrictMode -Version 'Latest'
|
|
|
|
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
|
|
|
|
|
|
|
|
# Root directory of the project.
|
|
|
|
$RootDir = Split-Path $PSScriptRoot -Parent
|
|
|
|
|
|
|
|
# Find all types we can archive
|
|
|
|
$BaseArtifactsDir = Join-Path $RootDir "artifacts"
|
|
|
|
$ArtifactsBinDir = Join-Path $BaseArtifactsDir "bin"
|
|
|
|
|
|
|
|
# All direct subfolders are OS's
|
|
|
|
$Platforms = Get-ChildItem -Path $ArtifactsBinDir
|
|
|
|
|
|
|
|
$WindowsBuilds = @()
|
|
|
|
$AllBuilds = @()
|
|
|
|
|
|
|
|
foreach ($Platform in $Platforms) {
|
2021-08-05 22:08:01 +03:00
|
|
|
$PlatBuilds = Get-ChildItem -Path $Platform.FullName
|
2020-07-24 21:39:27 +03:00
|
|
|
foreach ($PlatBuild in $PlatBuilds) {
|
2021-08-09 21:22:08 +03:00
|
|
|
if (!(Test-Path $PlatBuild -PathType Container)) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-07-24 21:39:27 +03:00
|
|
|
$AllBuilds += $PlatBuild
|
|
|
|
if ($Platform.Name -eq "windows") {
|
|
|
|
$WindowsBuilds += $PlatBuild
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($Build in $AllBuilds) {
|
|
|
|
$BuildBaseName = $Build.Name
|
2021-08-05 22:08:01 +03:00
|
|
|
$Platform = Split-Path -Path (Split-Path -Path $Build.FullName -Parent) -Leaf
|
2020-07-24 21:39:27 +03:00
|
|
|
|
|
|
|
if ($Platform -eq "winkernel") {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
# Important directory paths.
|
|
|
|
$ArtifactsDir = $Build.FullName
|
|
|
|
|
|
|
|
$DistDir = Join-Path $BaseArtifactsDir "dist"
|
|
|
|
|
2021-08-05 22:08:01 +03:00
|
|
|
$TempDir = Join-Path $BaseArtifactsDir "temp/zip/$Platform"
|
2020-07-24 21:39:27 +03:00
|
|
|
$TempDir = Join-Path $TempDir $BuildBaseName
|
|
|
|
|
|
|
|
# Initialize directories needed for building.
|
|
|
|
if (!(Test-Path $DistDir)) {
|
|
|
|
New-Item -Path $DistDir -ItemType Directory -Force | Out-Null
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Test-Path $TempDir)) {
|
|
|
|
Remove-Item -Path "$TempDir/*" -Recurse -Force
|
|
|
|
}
|
|
|
|
|
|
|
|
New-Item -Path $TempDir -ItemType Directory -Force | Out-Null
|
|
|
|
|
2021-08-05 22:08:01 +03:00
|
|
|
$HeaderDir = Join-Path $RootDir "src/inc"
|
2020-07-24 21:39:27 +03:00
|
|
|
|
|
|
|
# Find Headers
|
|
|
|
|
|
|
|
$Headers = @(Join-Path $HeaderDir "msquic.h")
|
|
|
|
|
|
|
|
if ($Platform -eq "windows" -or $Platform -eq "uwp") {
|
|
|
|
$Headers += Join-Path $HeaderDir "msquic_winuser.h"
|
|
|
|
} else {
|
2021-02-12 23:29:22 +03:00
|
|
|
$Headers += Join-Path $HeaderDir "msquic_posix.h"
|
2020-07-24 21:39:27 +03:00
|
|
|
$Headers += Join-Path $HeaderDir "quic_sal_stub.h"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Find Binaries
|
|
|
|
|
|
|
|
$Binaries = @()
|
|
|
|
|
|
|
|
if ($Platform -eq "windows" -or $Platform -eq "uwp") {
|
|
|
|
$Binaries += Join-Path $ArtifactsDir "msquic.dll"
|
|
|
|
$Binaries += Join-Path $ArtifactsDir "msquic.pdb"
|
2021-02-12 23:29:22 +03:00
|
|
|
} elseif ($Platform -eq "linux") {
|
2020-07-24 21:39:27 +03:00
|
|
|
$Binaries += Join-Path $ArtifactsDir "libmsquic.so"
|
2020-07-30 17:33:11 +03:00
|
|
|
$LttngBin = Join-Path $ArtifactsDir "libmsquic.lttng.so"
|
|
|
|
if (Test-Path $LttngBin) {
|
|
|
|
$Binaries += $LttngBin
|
|
|
|
}
|
2021-02-12 23:29:22 +03:00
|
|
|
} else {
|
|
|
|
# macos
|
|
|
|
$Binaries += Join-Path $ArtifactsDir "libmsquic.dylib"
|
2020-07-24 21:39:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$Libraries = @()
|
|
|
|
|
|
|
|
if ($Platform -eq "windows" -or $Platform -eq "uwp") {
|
|
|
|
$Libraries += Join-Path $ArtifactsDir "msquic.lib"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Copy items into temp folder that can be zipped in 1 command
|
|
|
|
|
|
|
|
$IncludeDir = Join-Path $TempDir "include"
|
|
|
|
New-Item -Path $IncludeDir -ItemType Directory -Force | Out-Null
|
|
|
|
|
|
|
|
$BinFolder = Join-Path $TempDir "bin"
|
|
|
|
New-Item -Path $BinFolder -ItemType Directory -Force | Out-Null
|
|
|
|
|
|
|
|
$LibFolder = Join-Path $TempDir "lib"
|
|
|
|
New-Item -Path $LibFolder -ItemType Directory -Force | Out-Null
|
|
|
|
|
|
|
|
foreach ($Header in $Headers) {
|
|
|
|
$FileName = Split-Path -Path $Header -Leaf
|
|
|
|
$CopyToFolder = (Join-Path $IncludeDir $FileName)
|
|
|
|
Copy-Item -LiteralPath $Header -Destination $CopyToFolder -Force
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($Binary in $Binaries) {
|
|
|
|
$FileName = Split-Path -Path $Binary -Leaf
|
|
|
|
$CopyToFolder = (Join-Path $BinFolder $FileName)
|
|
|
|
Copy-Item -LiteralPath $Binary -Destination $CopyToFolder -Force
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($Library in $Libraries) {
|
|
|
|
$FileName = Split-Path -Path $Library -Leaf
|
|
|
|
$CopyToFolder = (Join-Path $LibFolder $FileName)
|
|
|
|
Copy-Item -LiteralPath $Library -Destination $CopyToFolder -Force
|
|
|
|
}
|
|
|
|
|
2021-01-15 23:53:25 +03:00
|
|
|
# Copy License
|
|
|
|
Copy-Item -Path (Join-Path $RootDir "LICENSE") -Destination $TempDir
|
2021-08-07 02:48:45 +03:00
|
|
|
if (!($BuildBaseName -like "*schannel*")) {
|
2021-01-15 23:53:25 +03:00
|
|
|
# Only need license, no 3rd party code
|
|
|
|
Copy-Item -Path (Join-Path $RootDir "THIRD-PARTY-NOTICES") -Destination $TempDir
|
|
|
|
}
|
2020-07-24 21:39:27 +03:00
|
|
|
# Package zip archive
|
|
|
|
Compress-Archive -Path "$TempDir/*" -DestinationPath (Join-Path $DistDir "msquic_$($Platform)_$BuildBaseName.zip") -Force
|
2021-06-14 21:29:21 +03:00
|
|
|
|
|
|
|
# For now, package only x64 Release binaries
|
2021-08-05 22:08:01 +03:00
|
|
|
if ($Platform -eq "linux" -and $BuildBaseName -like "*x64_Release*") {
|
2021-06-14 21:29:21 +03:00
|
|
|
Write-Output "Packaging $Build"
|
|
|
|
scripts/make-packages.sh --output $DistDir
|
|
|
|
}
|
2020-07-24 21:39:27 +03:00
|
|
|
}
|