2009-11-14 16:29:09 -07:00
|
|
|
#!/usr/bin/env bash
|
2009-05-18 19:42:47 -06:00
|
|
|
# Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
2010-09-28 21:51:55 -06:00
|
|
|
eval $(gomake --no-print-directory -f ../Make.inc go-env)
|
|
|
|
|
2009-05-18 19:42:47 -06:00
|
|
|
OUT="Make.deps"
|
|
|
|
TMP="Make.deps.tmp"
|
|
|
|
|
2009-05-23 20:39:25 -06:00
|
|
|
if [ -f $OUT ] && ! [ -w $OUT ]; then
|
|
|
|
echo "$0: $OUT is read-only; aborting." 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2009-05-18 19:42:47 -06:00
|
|
|
# Get list of directories from Makefile
|
2010-12-15 16:46:25 -07:00
|
|
|
dirs=$(gomake --no-print-directory echo-dirs)
|
2011-06-15 22:04:24 -06:00
|
|
|
dirpat=$(echo $dirs C | awk '{
|
|
|
|
for(i=1;i<=NF;i++){
|
|
|
|
x=$i
|
|
|
|
gsub("/", "\\/", x)
|
|
|
|
printf("/^(%s)$/\n", x)
|
|
|
|
}
|
2011-11-03 13:19:07 -06:00
|
|
|
}')
|
|
|
|
|
2009-05-18 19:42:47 -06:00
|
|
|
for dir in $dirs; do (
|
2011-11-03 12:39:52 -06:00
|
|
|
cd $dir >/dev/null || exit 1
|
2009-05-18 19:42:47 -06:00
|
|
|
|
2010-04-06 11:53:48 -06:00
|
|
|
sources=$(sed -n 's/^[ ]*\([^ ]*\.go\)[ ]*\\*[ ]*$/\1/p' Makefile)
|
2010-03-19 15:17:07 -06:00
|
|
|
sources=$(echo $sources | sed 's/\$(GOOS)/'$GOOS'/g')
|
|
|
|
sources=$(echo $sources | sed 's/\$(GOARCH)/'$GOARCH'/g')
|
2010-04-06 11:53:48 -06:00
|
|
|
# /dev/null here means we get an empty dependency list if $sources is empty
|
|
|
|
# instead of listing every file in the directory.
|
|
|
|
sources=$(ls $sources /dev/null 2> /dev/null) # remove .s, .c, etc.
|
2009-05-18 19:42:47 -06:00
|
|
|
|
|
|
|
deps=$(
|
|
|
|
sed -n '/^import.*"/p; /^import[ \t]*(/,/^)/p' $sources /dev/null |
|
|
|
|
cut -d '"' -f2 |
|
2011-06-15 22:04:24 -06:00
|
|
|
awk "$dirpat" |
|
2009-05-18 19:42:47 -06:00
|
|
|
grep -v "^$dir\$" |
|
|
|
|
sed 's/$/.install/' |
|
2010-12-08 12:33:17 -07:00
|
|
|
sed 's;^C\.install;runtime/cgo.install;' |
|
2009-05-18 19:42:47 -06:00
|
|
|
sort -u
|
|
|
|
)
|
|
|
|
|
|
|
|
echo $dir.install: $deps
|
|
|
|
) done > $TMP
|
|
|
|
|
|
|
|
mv $TMP $OUT
|
2011-10-12 11:55:42 -06:00
|
|
|
|
|
|
|
if (egrep -v '^(exp|old)/' $OUT | egrep -q " (exp|old)/"); then
|
|
|
|
echo "$0: $OUT contains dependencies to exp or old packages"
|
|
|
|
exit 1
|
|
|
|
fi
|