2017-06-09 Thomas Koenig <tkoenig@gcc.gnu.org>
[official-gcc.git] / libgo / godeps.sh
blob0da5d07bdf9db53a44b5657f86482f67b6252a60
1 #!/bin/sh
3 # Copyright 2011 The Go Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style
5 # license that can be found in the LICENSE file.
7 # The godeps.sh script outputs a dependency file for a package. The
8 # dependency file is then included in the libgo Makefile. This is
9 # automatic dependency generation, Go style.
11 # The first parameter is the name of the file being generated. The
12 # remaining parameters are the names of Go files which are scanned for
13 # imports.
15 set -e
17 if test $# = 0; then
18 echo 1>&2 "Usage: godeps.sh OUTPUT INPUTS..."
19 exit 1
22 output=$1
23 shift
25 files=$*
26 deps=`for f in $files; do cat $f; done |
27 sed -n -e '/^import.*"/p; /^import[ ]*(/,/^)/p' |
28 grep '"' |
29 grep -v '"unsafe"' |
30 sed -e 's/^.*"\([^"]*\)".*$/\1/' -e 's/$/.gox/' |
31 sort -u`
33 echo $output: $files $deps