msquic/scripts/package-nuget.ps1

172 строки
4.7 KiB
PowerShell
Исходник Обычный вид История

<#
.SYNOPSIS
This script assembles the archives into a distribution.
.PARAMETER Config
The debug or release configuration to build for.
.PARAMETER Tls
The TLS library to use.
#>
param (
[Parameter(Mandatory = $false)]
[ValidateSet("Debug", "Release")]
[string]$Config = "Release",
[Parameter(Mandatory = $false)]
2023-02-02 21:43:49 +03:00
[ValidateSet("schannel", "openssl", "openssl3")]
[string]$Tls = "openssl",
[Parameter(Mandatory = $false)]
[switch]$UWP = $false,
[Parameter(Mandatory = $false)]
2023-07-06 14:36:16 +03:00
[switch]$ReleaseBuild = $false,
[Parameter(Mandatory = $false)]
[switch]$GHA = $false
)
Set-StrictMode -Version 'Latest'
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
function Get-GitHash {
param ($RepoDir)
$CurrentLoc = Get-Location
Set-Location -Path $RepoDir | Out-Null
$env:GIT_REDIRECT_STDERR = '2>&1'
$CurrentCommitHash = $null
try {
$CurrentCommitHash = git rev-parse HEAD
} catch {
Write-LogAndDebug "Failed to get commit hash from git"
}
Set-Location -Path $CurrentLoc | Out-Null
return $CurrentCommitHash
}
function Get-GitRemote {
param ($RepoDir)
$CurrentLoc = Get-Location
Set-Location -Path $RepoDir | Out-Null
$env:GIT_REDIRECT_STDERR = '2>&1'
$RepoRemote = $null
try {
$RepoRemote = git config --get remote.origin.url
} catch {
Write-LogAndDebug "Failed to get commit repo from git"
$RepoRemote = "https://github.com/microsoft/msquic.git"
}
Set-Location -Path $CurrentLoc | Out-Null
return $RepoRemote
}
# Root directory of the project.
$RootDir = Split-Path $PSScriptRoot -Parent
# Find all types we can archive
$BaseArtifactsDir = Join-Path $RootDir "artifacts"
if ($UWP) {
$PlatformDir = Join-Path $BaseArtifactsDir "bin/uwp"
} else {
$PlatformDir = Join-Path $BaseArtifactsDir "bin/windows"
}
$PackagingDir = Join-Path $BaseArtifactsDir "temp/nuget"
if ((Test-Path $PackagingDir)) {
Remove-Item -Path "$PackagingDir/*" -Recurse -Force
}
# Arm is ignored, as there are no shipping arm devices
$Architectures = "x64","x86","arm64"
Unify datapath (#3819) * Remove QUIC_USE_RAW_DATAPATH (logic only) * move logic to core side * remove QUIC_USE_RAW_DATAPATH from test * fix googletest version and add last line * replace from flag to function call * fix build error * fix build/test issues * implement CxPlatResolveRoute for normal socket * add Getter of Datapath feature * fix build issues * adopt comments * adopt comment and fix kernel build error * fix kernel build error * more fix for kernel build * Unify datapath * DatapathTest partially work * just unify build of both normal socket and xdp * SOCKET: RAW{...Socket{BASE{addr}}}, DATAPATH: XDP{RAW{DATAPATH*}} <-> DATAPATH{RAW*, BASE{callbacks}} * tmp * add preview_feature flag back * refactoring CxPlatIsRouteReady * fix linux code check * adjust func names * fix comments * fix IsRouteReady and clean ifdef for _KERNEL_MODE * kernel build error * Set RouteResolved for Rx * fix more tests * move global definition in header file * kernel to avoid calling helper function * move QuitTestIsFeatureSupported after RegistrationOpen * supress warning * remove QuitTestIsFeatureSupported from quic_gtest as it doesn't work as expected by dependency of MsQuicLib.Datapath * remove raw feature check as much as possible * ifdef for UseQTIP visibility * tmp * tmp * fix merge side effects * all tests passed * fix tests in msquicplatformtest * fix tcp with duonic * update clog * use xdp v1 * WIP cleanup * refactoring CXPLAT_SEND_DATA * remove mangling and function pointer * remove unnecessary change in test * fix comments * cleanup * move logic to _winuser * use dummy raw datapath for uwp build * dummy raw * remove double free * fix comments * update dummy func * fix perf run for TCP * partially fix comments * fix build error for uwp and remove duplicate variable in raw socket * set socket before start receiving * add dummy to clog * add clog files for dummy * fix dependency for cargo on windows * remove dummy clog files * remove AuxSocket * add pwsh for cargo setup * clog fix * add include dir for cargo * [WIP] fix cargo and qtip * fix clog, qtip, rename private raw functions and cleanup * experiment to avoid write overflow * use Config->Route->DatapathType for data allocation * more strict if conditions * fix comments * fix uwp build * fix clog and artifact name * fix back xdp dependency * Simply build automation * missed one * apply unification to linux and remove QUIC_USE_XDP flag * move types to any platform * add abstruction layer for linux * add clog * add clog dependencies * fix CodeCheck issues * remove xdp specific artifact dir name and always install xdp deps * add docs * More Fixes for XDP in automation (mostly OneBranch) --------- Co-authored-by: Nick Banks <nibanks@microsoft.com>
2023-09-23 22:45:17 +03:00
if ($Tls -ne "schannel") {
2023-02-10 02:22:20 +03:00
# OpenSSL doesn't support arm64 currently
$Architectures = "x64","x86"
}
# Copy artifacts to correct folders
$NativeDir = Join-Path $PackagingDir "build/native"
foreach ($Arch in $Architectures) {
$BuildPath = Join-Path $PlatformDir "$($Arch)_$($Config)_$($Tls)"
$LibPath = Join-Path $NativeDir "lib/$Arch"
$BinPath = Join-Path $NativeDir "bin/$Arch"
if (!(Test-Path $LibPath)) {
New-Item -Path $LibPath -ItemType Directory -Force | Out-Null
}
if (!(Test-Path $BinPath)) {
New-Item -Path $BinPath -ItemType Directory -Force | Out-Null
}
Copy-Item (Join-Path $BuildPath msquic.dll) $BinPath
Copy-Item (Join-Path $BuildPath msquic.pdb) $BinPath
Copy-Item (Join-Path $BuildPath msquic.lib) $LibPath
}
$HeaderDir = Join-Path $RootDir "src/inc"
$Headers = @(Join-Path $HeaderDir "msquic.h")
$Headers += Join-Path $HeaderDir "msquicp.h"
$Headers += Join-Path $HeaderDir "msquic.hpp"
$Headers += Join-Path $HeaderDir "msquic_winuser.h"
$IncludePath = Join-Path $NativeDir "include"
if (!(Test-Path $IncludePath)) {
New-Item -Path $IncludePath -ItemType Directory -Force | Out-Null
}
foreach ($Header in $Headers) {
$FileName = Split-Path -Path $Header -Leaf
$CopyToFolder = (Join-Path $IncludePath $FileName)
Copy-Item -LiteralPath $Header -Destination $CopyToFolder -Force
}
Copy-Item (Join-Path $RootDir LICENSE) $PackagingDir
if ($Tls -like "openssl") {
# Only need license, no 3rd party code
Copy-Item -Path (Join-Path $RootDir "THIRD-PARTY-NOTICES") -Destination $PackagingDir
}
$NugetSourceFolder = Join-Path $RootDir "src/distribution"
if ($UWP) {
$PackageName = "Microsoft.Native.Quic.MsQuic.UWP.$Tls"
} else {
Unify datapath (#3819) * Remove QUIC_USE_RAW_DATAPATH (logic only) * move logic to core side * remove QUIC_USE_RAW_DATAPATH from test * fix googletest version and add last line * replace from flag to function call * fix build error * fix build/test issues * implement CxPlatResolveRoute for normal socket * add Getter of Datapath feature * fix build issues * adopt comments * adopt comment and fix kernel build error * fix kernel build error * more fix for kernel build * Unify datapath * DatapathTest partially work * just unify build of both normal socket and xdp * SOCKET: RAW{...Socket{BASE{addr}}}, DATAPATH: XDP{RAW{DATAPATH*}} <-> DATAPATH{RAW*, BASE{callbacks}} * tmp * add preview_feature flag back * refactoring CxPlatIsRouteReady * fix linux code check * adjust func names * fix comments * fix IsRouteReady and clean ifdef for _KERNEL_MODE * kernel build error * Set RouteResolved for Rx * fix more tests * move global definition in header file * kernel to avoid calling helper function * move QuitTestIsFeatureSupported after RegistrationOpen * supress warning * remove QuitTestIsFeatureSupported from quic_gtest as it doesn't work as expected by dependency of MsQuicLib.Datapath * remove raw feature check as much as possible * ifdef for UseQTIP visibility * tmp * tmp * fix merge side effects * all tests passed * fix tests in msquicplatformtest * fix tcp with duonic * update clog * use xdp v1 * WIP cleanup * refactoring CXPLAT_SEND_DATA * remove mangling and function pointer * remove unnecessary change in test * fix comments * cleanup * move logic to _winuser * use dummy raw datapath for uwp build * dummy raw * remove double free * fix comments * update dummy func * fix perf run for TCP * partially fix comments * fix build error for uwp and remove duplicate variable in raw socket * set socket before start receiving * add dummy to clog * add clog files for dummy * fix dependency for cargo on windows * remove dummy clog files * remove AuxSocket * add pwsh for cargo setup * clog fix * add include dir for cargo * [WIP] fix cargo and qtip * fix clog, qtip, rename private raw functions and cleanup * experiment to avoid write overflow * use Config->Route->DatapathType for data allocation * more strict if conditions * fix comments * fix uwp build * fix clog and artifact name * fix back xdp dependency * Simply build automation * missed one * apply unification to linux and remove QUIC_USE_XDP flag * move types to any platform * add abstruction layer for linux * add clog * add clog dependencies * fix CodeCheck issues * remove xdp specific artifact dir name and always install xdp deps * add docs * More Fixes for XDP in automation (mostly OneBranch) --------- Co-authored-by: Nick Banks <nibanks@microsoft.com>
2023-09-23 22:45:17 +03:00
Copy-Item -Path (Join-Path $PSScriptRoot xdp.json) -Destination $PackagingDir
$PackageName = "Microsoft.Native.Quic.MsQuic.$Tls"
}
Copy-Item (Join-Path $NugetSourceFolder "$PackageName.nuspec") $PackagingDir
Copy-Item (Join-Path $NugetSourceFolder "$PackageName.targets") $NativeDir
Copy-Item (Join-Path $NugetSourceFolder "pkgicon.png") $PackagingDir
2023-03-15 19:52:46 +03:00
Copy-Item (Join-Path $RootDir "README.md") $PackagingDir
$DistDir = Join-Path $BaseArtifactsDir "dist"
$CurrentCommitHash = Get-GitHash -RepoDir $RootDir
$RepoRemote = Get-GitRemote -RepoDir $RootDir
$Version = "2.4.0"
$BuildId = $env:BUILD_BUILDID
if ($null -ne $BuildId) {
if ($ReleaseBuild) {
$Version += "+$BuildId"
} else {
$Version += "-ci.$BuildId"
}
} else {
$Version += "-local"
}
Write-Host $Version
nuget.exe pack (Join-Path $PackagingDir "$PackageName.nuspec") -OutputDirectory $DistDir -p CommitHash=$CurrentCommitHash -p RepoRemote=$RepoRemote -Version $Version