github.com/hlts2/go@v0.0.0-20170904000733-812b34efaed8/src/cmd/dist/mkdeps.bash (about) 1 #!/bin/bash 2 # Copyright 2015 The Go Authors. All rights reserved. 3 # Use of this source code is governed by a BSD-style 4 # license that can be found in the LICENSE file. 5 6 set -e 7 8 output="$1" 9 if test -z "$output"; then 10 output=deps.go 11 fi 12 13 # We need to test enough GOOS/GOARCH combinations to pick up all the 14 # package dependencies. 15 gooslist="windows linux darwin solaris" 16 goarchlist="386 amd64 arm arm64 ppc64" 17 18 echo NOTE: errors about loading internal/syscall/windows are ok 19 20 deps_of() { 21 for goos in $gooslist 22 do 23 for goarch in $goarchlist 24 do 25 GOOS=$goos GOARCH=$goarch go list -tags cmd_go_bootstrap -f '{{range .Deps}}{{$.ImportPath}} {{.}} 26 {{end}}' $* 27 done 28 done | sort -u | grep . | grep -v ' unsafe$' 29 } 30 31 all="$(deps_of cmd/go | awk '{print $2}') cmd/go" 32 deps_of $all >tmp.all.deps 33 34 ( 35 echo '// generated by mkdeps.bash' 36 echo 37 echo 'package main' 38 echo 39 echo 'var builddeps = map[string][]string{' 40 for pkg in $all 41 do 42 echo -n "\"$pkg\": {" 43 for dep in $(awk -v pkg=$pkg '$1==pkg {print $2}' tmp.all.deps) 44 do 45 echo -n "\"$dep\"," 46 done 47 echo '},' 48 done 49 echo '}' 50 ) |gofmt >$output 51 52 rm -f tmp.all.deps