github.com/containers/podman/v5@v5.1.0-rc1/winmake.ps1 (about)

     1  
     2  . ./contrib/cirrus/win-lib.ps1
     3  
     4  # Targets
     5  function Podman-Remote{
     6      New-Item -ItemType Directory -Force -Path "./bin/windows"
     7  
     8      $buildInfo = Get-Date -UFormat %s -Millisecond 0
     9      $buildInfo = "-X github.com/containers/podman/v5/libpod/define.buildInfo=$buildInfo "
    10      $commit = Git-Commit
    11      $commit = "-X github.com/containers/podman/v5/libpod/define.gitCommit=$commit "
    12  
    13      Run-Command "go build --ldflags `"$commit $buildInfo `" --tags `"$remotetags`" --o ./bin/windows/podman.exe ./cmd/podman/."
    14  }
    15  
    16  function Make-Clean{
    17       Remove-Item ./bin -Recurse -Force -Confirm:$false
    18  }
    19  
    20  function Local-Machine {
    21      param (
    22      [string]$files
    23      );
    24      Build-Ginkgo
    25      if ($files) {
    26           $files = " --focus-file $files "
    27      }
    28  
    29      Run-Command "./test/tools/build/ginkgo.exe -vv  --tags `"$remotetags`" -timeout=90m --trace --no-color $files pkg/machine/e2e/."
    30  }
    31  
    32  # Expect starting directory to be /podman
    33  function Win-SSHProxy {
    34      param (
    35          [string]$Version
    36      );
    37  
    38      New-Item -ItemType Directory -Force -Path "./bin/windows"
    39      if (-Not $Version) {
    40          $Version = "v0.7.2"
    41      }
    42      curl.exe -sSL -o "./bin/windows/gvproxy.exe" --retry 5 "https://github.com/containers/gvisor-tap-vsock/releases/download/$Version/gvproxy-windowsgui.exe"
    43      curl.exe -sSL -o "./bin/windows/win-sshproxy.exe" --retry 5 "https://github.com/containers/gvisor-tap-vsock/releases/download/$Version/win-sshproxy.exe"
    44  }
    45  
    46  # Helpers
    47  function Build-Ginkgo{
    48      if (Test-Path -Path ./test/tools/build/ginkgo.exe -PathType Leaf) {
    49          return
    50      }
    51      Write-Host "Building Ginkgo"
    52      Push-Location ./test/tools
    53      Run-Command "go build -o build/ginkgo.exe ./vendor/github.com/onsi/ginkgo/v2/ginkgo"
    54      Pop-Location
    55  }
    56  
    57  function Git-Commit{
    58      # git is not installed by default on windows,
    59      # so if we can't get the commit, we don't include this info
    60      Get-Command git  -ErrorAction SilentlyContinue  | out-null
    61      if(!$?){
    62          return
    63      }
    64      $commit = git rev-parse HEAD
    65      $dirty = git status --porcelain --untracked-files=no
    66      if ($dirty){
    67          $commit = "$commit-dirty"
    68      }
    69      return $commit
    70  }
    71  
    72  # Init script
    73  $target = $args[0]
    74  
    75  $remotetags = "remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp"
    76  
    77  switch ($target) {
    78      {$_ -in '', 'podman-remote', 'podman'} {
    79          Podman-Remote
    80      }
    81      'localmachine' {
    82          if ($args.Count -gt 1) {
    83              $files = $args[1]
    84          }
    85          Local-Machine  -files $files
    86      }
    87      'clean' {
    88          Make-Clean
    89      }
    90      {$_ -in 'win-sshproxy', 'win-gvproxy'} {
    91          if ($args.Count -gt 1) {
    92              $ref = $args[1]
    93          }
    94          Win-SSHProxy -Ref $ref
    95      }
    96      default {
    97          Write-Host "Usage: " $MyInvocation.MyCommand.Name "<target> [options]"
    98          Write-Host
    99          Write-Host "Example: Build podman-remote "
   100          Write-Host " .\winmake podman-remote"
   101          Write-Host
   102          Write-Host "Example: Run all machine tests "
   103          Write-Host " .\winmake localmachine"
   104          Write-Host
   105          Write-Host "Example: Run specfic machine tests "
   106          Write-Host " .\winmake localmachine "basic_test.go""
   107          Write-Host
   108          Write-Host "Example: Download win-gvproxy and win-sshproxy helpers"
   109          Write-Host " .\winmake win-gvproxy"
   110      }
   111  }