File: update-xtools.sh

package info (click to toggle)
golang-1.12 1.12.7-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, experimental, sid
  • size: 113,080 kB
  • sloc: asm: 97,488; ansic: 8,245; perl: 2,243; sh: 1,895; xml: 623; python: 349; makefile: 127; cpp: 22; f90: 8; awk: 7
file content (31 lines) | stat: -rwxr-xr-x 973 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
#
# update-xtools.sh: idempotently update the vendored
# copy of the x/tools repository used by cmd/vet.

set -u

analysis=$(go list -f {{.Dir}} golang.org/x/tools/go/analysis) ||
  { echo "Add golang.org/x/tools to your GOPATH"; exit 1; } >&2
xtools=$(dirname $(dirname $analysis))

vendor=$(dirname $0)

# Find the x/tools packages directly imported by cmd/vet.
go list -f '{{range $k, $v := .ImportMap}}{{$k}} {{end}}' cmd/vet |
  grep golang.org/x/tools |
  # Vendor their transitive closure of dependencies.
  xargs go list -f '{{.ImportPath}} {{.Dir}}' -deps |
  grep golang.org/x/tools |
  while read path dir
  do
    mkdir -p $vendor/$path
    cp $dir/* -t $vendor/$path 2>/dev/null # ignore errors from subdirectories
    rm -f $vendor/$path/*_test.go
    git add $vendor/$path
  done

echo "Copied $xtools@$(cd $analysis && git rev-parse --short HEAD) to $vendor" >&2

go build -o /dev/null cmd/vet ||
  { echo "Failed to build cmd/vet"; exit 1; } >&2