mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-30 08:49:00 +08:00
532db1d8f7
* [qt5] Add more dependent Linux packages for https://github.com/microsoft/vcpkg/pull/11596/ * [vcpkg] Add LLVM 10 to Windows CI machines for https://github.com/microsoft/vcpkg/pull/11655/ * [vcpkg] Add missing Param block to InstallLLVM function. * [vcpkg] Add throw after all Write-Error calls for consistency with https://github.com/microsoft/vcpkg/pull/12172
64 lines
1.5 KiB
PowerShell
64 lines
1.5 KiB
PowerShell
<#
|
|
#>
|
|
[CmdletBinding(PositionalBinding=$False)]
|
|
Param(
|
|
[Parameter(Mandatory=$True)]
|
|
[string]$Commit,
|
|
|
|
[Parameter()]
|
|
[string]$GithubRepository = "spdx/license-list-data",
|
|
|
|
[Parameter()]
|
|
[string]$LicensesOutFile = "$PSScriptRoot/../toolsrc/src/vcpkg/spdx-licenses.inc",
|
|
|
|
[Parameter()]
|
|
[string]$ExceptionsOutFile = "$PSScriptRoot/../toolsrc/src/vcpkg/spdx-exceptions.inc"
|
|
)
|
|
|
|
function Transform-JsonFile {
|
|
[CmdletBinding()]
|
|
Param(
|
|
[string]$Uri,
|
|
[string]$OutFile,
|
|
[string]$OuterName,
|
|
[string]$Id
|
|
)
|
|
|
|
$req = Invoke-WebRequest -Uri $Uri
|
|
|
|
if ($req.StatusCode -ne 200)
|
|
{
|
|
Write-Error "Failed to GET $Uri"
|
|
throw
|
|
}
|
|
|
|
$json = $req.Content | ConvertFrom-Json -Depth 10
|
|
Write-Verbose "Writing output to $OutFile"
|
|
|
|
$fileContent = @(
|
|
"// Data downloaded from $Uri",
|
|
"// Generated by scripts/Generate-SpdxLicenseList.ps1",
|
|
"{")
|
|
$json.$OuterName | ForEach-Object {
|
|
$fileContent += " `"$($_.$Id)`","
|
|
}
|
|
$fileContent += "}"
|
|
|
|
$fileContent -join "`n" | Out-File -FilePath $OutFile -Encoding 'utf8'
|
|
}
|
|
|
|
$baseUrl = "https://raw.githubusercontent.com/$GithubRepository/$Commit/json"
|
|
Write-Verbose "Getting json files from $baseUrl"
|
|
|
|
Transform-JsonFile `
|
|
-Uri "$baseUrl/licenses.json" `
|
|
-OutFile $LicensesOutFile `
|
|
-OuterName 'licenses' `
|
|
-Id 'licenseId'
|
|
|
|
Transform-JsonFile `
|
|
-Uri "$baseUrl/exceptions.json" `
|
|
-OutFile $ExceptionsOutFile `
|
|
-OuterName 'exceptions' `
|
|
-Id 'licenseExceptionId'
|