Home | History | Annotate | Download | only in dist
      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 # We need to test enough GOOS/GOARCH combinations to pick up all the
      9 # package dependencies.
     10 gooslist="windows linux darwin solaris"
     11 goarchlist="386 amd64 arm arm64 ppc64"
     12 
     13 echo NOTE: errors about loading internal/syscall/windows are ok
     14 
     15 deps_of() {
     16 	for goos in $gooslist
     17 	do
     18 		for goarch in $goarchlist
     19 		do
     20 			GOOS=$goos GOARCH=$goarch go list -tags cmd_go_bootstrap -f '{{range .Deps}}{{$.ImportPath}} {{.}}
     21 {{end}}' $*
     22 		done
     23 	done | sort -u | grep . | grep -v ' unsafe$'
     24 }
     25 
     26 all="$(deps_of cmd/go | awk '{print $2}') cmd/go"
     27 deps_of $all >tmp.all.deps
     28 
     29 (
     30 	echo '// generated by mkdeps.bash'
     31 	echo
     32 	echo 'package main'
     33 	echo
     34 	echo 'var builddeps = map[string][]string{'
     35 	for pkg in $all
     36 	do
     37 		echo -n "\"$pkg\": {"
     38 		for dep in $(awk -v pkg=$pkg '$1==pkg {print $2}' tmp.all.deps)
     39 		do
     40 			echo -n "\"$dep\","
     41 		done
     42 		echo '},'
     43 	done
     44 	echo '}'
     45 ) |gofmt >deps.go
     46 
     47 rm -f tmp.all.deps
     48