github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/hack/make/.go-autogen.ps1 (about) 1 <# 2 .NOTES 3 Author: @jhowardmsft 4 5 Summary: Windows native version of .go-autogen which generates the 6 .go source code for building, and performs resource compilation. 7 8 .PARAMETER CommitString 9 The commit string. This is calculated externally to this script. 10 11 .PARAMETER DockerVersion 12 The version such as 17.04.0-dev. This is calculated externally to this script. 13 14 .PARAMETER Platform 15 The platform name, such as "Docker Engine - Community". 16 17 .PARAMETER Product 18 The product name, used to set version.ProductName, which is used to set BuildKit's 19 ExportedProduct variable in order to show useful error messages to users when a 20 certain version of the product doesn't support a BuildKit feature. 21 22 .PARAMETER DefaultProductLicense 23 Sets the version.DefaultProductLicense string, such as "Community Engine". This field 24 can contain a summary of the product license of the daemon if a commercial license has 25 been applied to the daemon. 26 27 .PARAMETER PackagerName 28 The name of the packager (e.g. "Docker, Inc."). This used to set CompanyName in the manifest. 29 #> 30 31 param( 32 [Parameter(Mandatory=$true)][string]$CommitString, 33 [Parameter(Mandatory=$true)][string]$DockerVersion, 34 [Parameter(Mandatory=$false)][string]$Platform, 35 [Parameter(Mandatory=$false)][string]$Product, 36 [Parameter(Mandatory=$false)][string]$DefaultProductLicense, 37 [Parameter(Mandatory=$false)][string]$PackagerName 38 ) 39 40 $ErrorActionPreference = "Stop" 41 42 # Utility function to get the build date/time in UTC 43 Function Get-BuildDateTime() { 44 return $(Get-Date).ToUniversalTime() 45 } 46 47 Function Get-Year() { 48 return $(Get-Date).year 49 } 50 51 Function Get-FixQuadVersionNumber($number) { 52 if ($number -eq 0) { 53 return $number 54 } 55 return $number.TrimStart("0") 56 } 57 58 try { 59 $buildDateTime=Get-BuildDateTime 60 $currentYear=Get-Year 61 62 # Update PATH 63 $env:PATH="$env:GOPATH\bin;$env:PATH" 64 65 # Generate a version in the form major,minor,patch,build 66 $versionQuad=($DockerVersion -replace "[^0-9.]*") 67 if ($versionQuad -Match "^\d+`.\d+`.\d+$"){ 68 $versionQuad = $versionQuad + ".0" 69 } 70 $versionMatches = $($versionQuad | Select-String -AllMatches -Pattern "(\d+)`.(\d+)`.(\d+)`.(\d+)").Matches 71 72 $mkwinresContents = '{ 73 "RT_GROUP_ICON": { 74 "#1": { 75 "0409": "../../winresources/docker.ico" 76 } 77 }, 78 "RT_MANIFEST": { 79 "#1": { 80 "0409": { 81 "identity": {}, 82 "description": "Docker Engine", 83 "minimum-os": "vista", 84 "execution-level": "", 85 "ui-access": false, 86 "auto-elevate": false, 87 "dpi-awareness": "unaware", 88 "disable-theming": false, 89 "disable-window-filtering": false, 90 "high-resolution-scrolling-aware": false, 91 "ultra-high-resolution-scrolling-aware": false, 92 "long-path-aware": false, 93 "printer-driver-isolation": false, 94 "gdi-scaling": false, 95 "segment-heap": false, 96 "use-common-controls-v6": false 97 } 98 } 99 }, 100 "RT_MESSAGETABLE": { 101 "#1": { 102 "0409": "../../winresources/event_messages.bin" 103 } 104 }, 105 "RT_VERSION": { 106 "#1": { 107 "0409": { 108 "fixed": { 109 "file_version": "'+(Get-FixQuadVersionNumber($versionMatches.Groups[1].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[2].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[3].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[4].Value))+'", 110 "product_version": "'+(Get-FixQuadVersionNumber($versionMatches.Groups[1].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[2].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[3].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[4].Value))+'", 111 "type": "Unknown" 112 }, 113 "info": { 114 "0000": { 115 "CompanyName": "'+$PackagerName+'", 116 "FileVersion": "'+$DockerVersion+'", 117 "LegalCopyright": "Copyright (C) 2015-'+$currentYear+' Docker Inc.", 118 "OriginalFileName": "dockerd.exe", 119 "ProductName": "'+$Product+'", 120 "ProductVersion": "'+$DockerVersion+'", 121 "SpecialBuild": "'+$CommitString+'" 122 } 123 } 124 } 125 } 126 } 127 }' 128 129 # Write the file 130 $outputFile="$(Get-Location)\cli\winresources\dockerd\winres.json" 131 if (Test-Path $outputFile) { Remove-Item $outputFile } 132 [System.IO.File]::WriteAllText($outputFile, $mkwinresContents) 133 Get-Content $outputFile | Out-Host 134 135 # Create winresources package stub if removed while using tmpfs in Dockerfile 136 $stubPackage="$(Get-Location)\cli\winresources\dockerd\winresources.go" 137 if(![System.IO.File]::Exists($stubPackage)){ 138 Set-Content -NoNewline -Path $stubPackage -Value 'package winresources' 139 } 140 141 # Generate 142 go generate -v "github.com/docker/docker/cmd/dockerd" 143 if ($LASTEXITCODE -ne 0) { Throw "Failed to generate version info" } 144 } 145 Catch [Exception] { 146 # Throw the error onto the caller to display errors. We don't expect this script to be called directly 147 Throw ".go-autogen.ps1 failed with error $_" 148 } 149 Finally { 150 $env:_ag_dockerVersion="" 151 $env:_ag_gitCommit="" 152 }