godeps.sh 909 B

1234567891011121314151617181920212223242526272829303132333435
  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. files=$*
  19. deps=`for f in $files; do cat $f; done |
  20. sed -n -e '/^import.*"/p; /^import[ ]*(/,/^)/p' |
  21. sed -e 's/^import //' -e 's/^[^"]*"/"/' |
  22. grep '^[ ]*"' |
  23. grep -v '"unsafe"' |
  24. grep -v '%' |
  25. sed -e 's/^.*"\([^"]*\)".*$/\1/' -e 's/$/.gox/' |
  26. sort -u`
  27. echo $output: $files $deps