| 1 |
#!/bin/sh |
| 2 |
set -eu |
| 3 |
|
| 4 |
PROJECT=gitlab.com/ubports/development/core/lomiri-push-service |
| 5 |
|
| 6 |
mktpl () { |
| 7 |
for f in GoFiles CgoFiles; do |
| 8 |
echo '{{join .'$f' "\\n"}}' |
| 9 |
done |
| 10 |
} |
| 11 |
|
| 12 |
directs () { |
| 13 |
go list -f "$(mktpl)" $1 | sed -e "s|^|$1|" |
| 14 |
} |
| 15 |
|
| 16 |
indirects () { |
| 17 |
for i in $(go list -f '{{join .Deps "\n"}}' $1 | grep ^$PROJECT ); do |
| 18 |
directs $i/ |
| 19 |
done |
| 20 |
wait |
| 21 |
} |
| 22 |
|
| 23 |
norm () { |
| 24 |
tr "\n" " " | sed -r -e "s|$PROJECT/?||g" -e 's/ *$//' |
| 25 |
} |
| 26 |
|
| 27 |
out="$1.deps" |
| 28 |
( echo -n "${1%.go} ${out} dependencies.tsv: "; indirects $(echo $1 | norm) | norm ) > "$out" |