44[CmdletBinding (DefaultParameterSetName = " none" )]
55param (
66 [string ]$OutputPath ,
7+ [Parameter (ParameterSetName = ' Named' )]
78 [string []]$PackageNames ,
9+ [Parameter (ParameterSetName = ' Named' )]
810 [switch ]$RequireDependencies ,
11+ [Parameter (ParameterSetName = ' PackageInfo' )]
12+ [string ]$PackageInfoDirectory ,
913 [switch ]$NoVerify
1014)
1115
@@ -22,6 +26,39 @@ if ($OutputPath) {
2226 $OutputPath = New-Item - ItemType Directory - Path $OutputPath - Force | Select-Object - ExpandProperty FullName
2327}
2428
29+ function Get-OutputPackageNames ($workspacePackages ) {
30+ $packablePackages = $workspacePackages | Where-Object - Property publish -NE - Value @ ()
31+ $packablePackageNames = $packablePackages.name
32+
33+ $names = @ ()
34+ switch ($PsCmdlet.ParameterSetName ) {
35+ ' Named' {
36+ $names = $PackageNames
37+ }
38+
39+ ' PackageInfo' {
40+ $packageInfoFiles = Get-ChildItem - Path $PackageInfoDirectory - Filter ' *.json' - File
41+ foreach ($packageInfoFile in $packageInfoFiles ) {
42+ $packageInfo = Get-Content - Path $packageInfoFile.FullName | ConvertFrom-Json
43+ $names += $packageInfo.name
44+ }
45+ }
46+
47+ default {
48+ return $packablePackageNames
49+ }
50+ }
51+
52+ foreach ($name in $names ) {
53+ if (-not $packablePackageNames.Contains ($name )) {
54+ Write-Error " Package '$name ' is not in the workspace or does not publish"
55+ exit 1
56+ }
57+ }
58+
59+ return $names
60+ }
61+
2562function Get-CargoMetadata () {
2663 cargo metadata -- no- deps -- format-version 1 -- manifest- path " $RepoRoot /Cargo.toml" | ConvertFrom-Json - Depth 100 - AsHashtable
2764}
@@ -46,9 +83,10 @@ function Get-CargoPackages() {
4683
4784function Get-PackagesToBuild () {
4885 $packages = Get-CargoPackages
86+ $outputPackageNames = Get-OutputPackageNames $packages
4987
5088 # We start with output packages, then recursively add unreleased dependencies to the list of packages that need to be built
51- [array ]$packagesToBuild = $packages | Where-Object { $PackageNames .Contains ($_.name ) }
89+ [array ]$packagesToBuild = $packages | Where-Object { $outputPackageNames .Contains ($_.name ) }
5290
5391 $toProcess = $packagesToBuild
5492 while ($toProcess.Length -gt 0 ) {
@@ -82,7 +120,7 @@ function Get-PackagesToBuild() {
82120 exit 1
83121 }
84122
85- $package.OutputPackage = $PackageNames .Contains ($package.name )
123+ $package.OutputPackage = $outputPackageNames .Contains ($package.name )
86124 $buildOrder += $package
87125 $packagesToBuild = @ ($packagesToBuild -ne $package )
88126
0 commit comments