godeps.sh 823 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. # Copyright 2011 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. # The godeps.sh script outputs a dependency file for a package. The
  6. # dependency file is then included in the libgo Makefile. This is
  7. # automatic dependency generation, Go style.
  8. # The first parameter is the name of the file being generated. The
  9. # remaining parameters are the names of Go files which are scanned for
  10. # imports.
  11. set -e
  12. if test $# = 0; then
  13. echo 1>&2 "Usage: godeps.sh OUTPUT INPUTS..."
  14. exit 1
  15. fi
  16. output=$1
  17. shift
  18. deps=`for f in $*; do cat $f; done |
  19. sed -n -e '/^import.*"/p; /^import[ ]*(/,/^)/p' |
  20. grep '"' |
  21. grep -v '"unsafe"' |
  22. sed -e 's/^.*"\([^"]*\)".*$/\1/' -e 's/$/.gox/' |
  23. sort -u`
  24. echo $output: $deps