Skip to content

Commit

Permalink
Improve layout of swift files in nuget package (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlabelle authored Oct 7, 2024
1 parent 0c03c6f commit 5983764
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
26 changes: 22 additions & 4 deletions Generator/Create-NuGetPackage.ps1
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
^(?<indentation>[ ]+)
\.testTarget\(
.*\n
# Match subsequent lines of the test target (further indented)
(
\k<indentation> .*\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",
Expand Down
5 changes: 2 additions & 3 deletions Support/Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 5983764

Please sign in to comment.