Last active
February 27, 2019 17:56
-
-
Save dprotaso/3162e9952ac1f93b6cab50de6b6dd8f1 to your computer and use it in GitHub Desktop.
Print the external dependencies for an envoy target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o errexit | |
set -o pipefail | |
if [[ -z "$(which jq)" ]]; then | |
echo "jq is required" | |
exit 1 | |
fi | |
readonly target_dep_output=$(mktemp) | |
readonly repos=$(mktemp) | |
readonly recipies=$(mktemp) | |
readonly all_deps=$(mktemp) | |
bazel query 'deps('"$1"')' 1> $target_dep_output 2> /dev/null | |
# Capture a list of explicit repositories | |
grep "^@" $target_dep_output | awk -F "//" '{ print $1 }' | sort | uniq | cut -d@ -f2 1> $repos | |
# Capture a list of implicit repositories (build recipies) | |
grep "^@envoy_deps" $target_dep_output | grep -v thirdparty | cut -d: -f2 | sort | uniq 1> $recipies | |
# Resolve the recipe repository name to the dependency name | |
cat $recipies | python -c " | |
import imp | |
import sys | |
MAP=imp.load_source('deps', 'bazel/target_recipes.bzl') | |
print('\n'.join([MAP.TARGET_RECIPES[recipe.strip()] for recipe in sys.stdin])) | |
" | sort | uniq >> $repos | |
./tools/print_dependencies.py 1> $all_deps | |
cat $repos | xargs -n1 -I{} jq '.[] | select(.identifier == "{}")' $all_deps | jq --slurp 'sort_by(.identifier)' 2>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From the envoyproxy/envoy root directory run