From a114ac7c651cb0850cd251e14d23e4c851831e30 Mon Sep 17 00:00:00 2001 From: Tristan Labelle Date: Sun, 6 Oct 2024 20:24:11 -0400 Subject: [PATCH] Improve layout of swift files in nuget package (#328) --- Generator/Create-NuGetPackage.ps1 | 26 ++++++++++++++++++++++---- Support/Sources/CMakeLists.txt | 5 ++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Generator/Create-NuGetPackage.ps1 b/Generator/Create-NuGetPackage.ps1 index cc42a0b..beee496 100644 --- a/Generator/Create-NuGetPackage.ps1 +++ b/Generator/Create-NuGetPackage.ps1 @@ -1,3 +1,7 @@ +<# +.SYNOPSIS +Creates the Swift/WinRT nuget package, including the code generator executable and support module sources. +#> param( [string]$NativeExe = $null, [string]$X64BinPath = $null, @@ -57,12 +61,26 @@ if ($Arm64BinPath) { Write-Host " support module sources..." New-Item -ItemType Directory -Path $StagingDir\swift -Force | Out-Null -Copy-Item -Path $PSScriptRoot\..\Package.swift -Destination $StagingDir\swift\ -Force | Out-Null -Copy-Item -Path $PSScriptRoot\..\Package.resolved -Destination $StagingDir\swift\ -Force -ErrorAction Ignore | Out-Null # Might not have one -Copy-Item -Path $PSScriptRoot\..\Support -Destination $StagingDir\swift\Support\ -Recurse -Force | Out-Null +$RepoRoot = (& git.exe -C "$PSScriptRoot" rev-parse --path-format=absolute --show-toplevel).Trim() +$PackageSwift = Get-Content -Path $RepoRoot\Package.swift -Raw -Encoding UTF8 +$PackageSwift = $PackageSwift -replace "Support/Sources/", "" # Flatten directory structure +# Remove test targets +$PackageSwift = [Regex]::Replace($PackageSwift, " + # Match the first line of a test target + ^(?[ ]+) + \.testTarget\( + .*\n + # Match subsequent lines of the test target (further indented) + ( + \k .*\n + )* + ", "", "CultureInvariant,ExplicitCapture,IgnorePatternWhitespace,Multiline") +Out-File -FilePath $StagingDir\swift\Package.swift -InputObject $PackageSwift -Encoding UTF8 +Copy-Item -Path $RepoRoot\Package.resolved -Destination $StagingDir\swift\ -Force -ErrorAction Ignore | Out-Null # Might not have one +Copy-Item -Path $RepoRoot\Support\Sources\* -Destination $StagingDir\swift\ -Recurse -Force | Out-Null Write-Host " readme..." -Copy-Item -Path $PSScriptRoot\..\Readme.md -Destination $StagingDir\ -Force | Out-Null +Copy-Item -Path $RepoRoot\Readme.md -Destination $StagingDir\ -Force | Out-Null Write-Host "Creating NuGet package..." $NuGetArgs = @("pack", diff --git a/Support/Sources/CMakeLists.txt b/Support/Sources/CMakeLists.txt index a364ade..1045f1f 100644 --- a/Support/Sources/CMakeLists.txt +++ b/Support/Sources/CMakeLists.txt @@ -1,6 +1,5 @@ -add_subdirectory(COM_ABI) -add_subdirectory(WindowsRuntime_ABI) - add_subdirectory(ABIBindings) +add_subdirectory(COM_ABI) add_subdirectory(COM) +add_subdirectory(WindowsRuntime_ABI) add_subdirectory(WindowsRuntime) \ No newline at end of file