|
| 1 | +[CmdletBinding()] |
| 2 | +param( |
| 3 | + [Parameter(Mandatory=$true)][string]$SourcesRef, |
| 4 | + [Parameter(Mandatory=$false)][string]$PortDirectory = $PSScriptRoot, |
| 5 | + [Parameter(Mandatory=$false)][string]$vcpkg = "$PSScriptRoot/../../vcpkg" |
| 6 | +) |
| 7 | + |
| 8 | +$ErrorActionPreference = "Stop" |
| 9 | + |
| 10 | +$ManifestIn = "$PortDirectory/vcpkg.in.json" |
| 11 | +$ManifestOut = "$PortDirectory/vcpkg.json" |
| 12 | + |
| 13 | +$ExtractedSources = "${env:TEMP}/aws-sdk-cpp-generateFeatures-$SourcesRef" |
| 14 | +if (-not (Test-Path $ExtractedSources)) { |
| 15 | + if (Test-Path "$ExtractedSources.tmp") { |
| 16 | + Remove-Item -Force "$ExtractedSources.tmp" |
| 17 | + } |
| 18 | + git clone --depth=1 "https://github.com/aws/aws-sdk-cpp" "$ExtractedSources.tmp" | Out-Host |
| 19 | + git -c "$ExtractedSources.tmp" checkout $SourcesRef |
| 20 | + Move-Item "$ExtractedSources.tmp" "$ExtractedSources" |
| 21 | +} |
| 22 | +Write-Host "Using sources directory: $ExtractedSources" |
| 23 | + |
| 24 | + |
| 25 | +$subfolders = Get-ChildItem -Path "$ExtractedSources\generated\src\aws-cpp-sdk-*", "$ExtractedSources\src\aws-cpp-sdk*" | Sort-Object -Property Name |
| 26 | + |
| 27 | +$manifest = Get-Content $ManifestIn | ConvertFrom-Json |
| 28 | +$manifest | Add-Member ` |
| 29 | + -NotePropertyName '$note' ` |
| 30 | + -NotePropertyValue 'Automatically generated by generateFeatures.ps1' |
| 31 | +$manifest | Add-Member -NotePropertyName 'features' -NotePropertyValue @{} |
| 32 | + |
| 33 | +function GetDescription($dir, $modulename) |
| 34 | +{ |
| 35 | + if (Test-Path "$dir\CMakeLists.txt") |
| 36 | + { |
| 37 | + $descs = @(Select-String -Path "$dir\CMakeLists.txt" -Pattern "`"C\+\+ SDK for the AWS [^`"]*`"") |
| 38 | + if ($descs.count -eq 1) { |
| 39 | + $desc = $descs[0].Matches.Value -replace "`"","" |
| 40 | + "$desc" |
| 41 | + } |
| 42 | + else { "C++ SDK for the AWS $modulename service" } |
| 43 | + } |
| 44 | + else { "C++ SDK for the AWS $modulename service" } |
| 45 | +} |
| 46 | + |
| 47 | +$featureDependencies = @{} |
| 48 | +Select-String -Path "$ExtractedSources\cmake\sdksCommon.cmake" -Pattern "list\(APPEND SDK_DEPENDENCY_LIST `"([\w-]+):([\w-,]+)`"\)" -AllMatches ` |
| 49 | +| ForEach-Object { $_.Matches } ` |
| 50 | +| ForEach-Object { $featureDependencies[$_.Groups[1].Value] = @($_.Groups[2].Value -split "," ` |
| 51 | +| Where-Object { $_ -ne "core" }) } |
| 52 | + |
| 53 | +foreach ($subfolder in $subfolders) |
| 54 | +{ |
| 55 | + $modulename = $subfolder.name -replace "^aws-cpp-sdk-","" |
| 56 | + if ($modulename -match "-tests`$") { continue } |
| 57 | + if ($modulename -match "-sample`$") { continue } |
| 58 | + if ($modulename -eq "core") { continue } |
| 59 | + |
| 60 | + $lowermodulename = $modulename.ToLower() |
| 61 | + |
| 62 | + $featureObj = @{ description = (GetDescription $subfolder $modulename) } |
| 63 | + |
| 64 | + if ($featureDependencies.ContainsKey($lowermodulename)) { |
| 65 | + $featureObj.dependencies = ,@{ name = "aws-sdk-cpp"; "default-features" = $false; "features" = $featureDependencies[$lowermodulename] } |
| 66 | + } |
| 67 | + |
| 68 | + $manifest.features.Add("$lowermodulename", $featureObj) |
| 69 | +} |
| 70 | + |
| 71 | +[IO.File]::WriteAllText($ManifestOut, (ConvertTo-Json -Depth 10 -InputObject $manifest)) |
| 72 | + |
| 73 | +& $vcpkg format-manifest --feature-flags=-manifests $ManifestOut |
0 commit comments