Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Print the external dependencies for an envoy target
#!/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
@dprotaso
Copy link
Author

dprotaso commented Feb 27, 2019

From the envoyproxy/envoy root directory run

$ tools/print_deps_for_target.sh //source/exe:envoy
[
  {
    "file-prefix": "boringssl-a7d9ef75919900bf4dca947ad3d5d03f0dee3f2a",
    "file-sha256": "de3fc9ff61e2fa736681b401ac94ea016f6ff522da419c312eca6aec60ad6f50",
    "file-url": "https://github.com/google/boringssl/archive/a7d9ef75919900bf4dca947ad3d5d03f0dee3f2a.tar.gz",
    "identifier": "boringssl"
  },
  {
    "file-prefix": "",
    "file-sha256": "b12ad676ee533824f698741bd127f6fbc82c46344398a6d78d25e62c6c418c73",
    "file-url": "https://commondatastorage.googleapis.com/chromium-boringssl-docs/fips/boringssl-66005f41fbc3529ffe8d007708756720529da20d.tar.xz",
    "identifier": "boringssl_fips"
  },
  {
    "file-prefix": "c-ares-cares-1_15_0",
    "file-sha256": "7deb7872cbd876c29036d5f37e30c4cbc3cc068d59d8b749ef85bb0736649f04",
    "file-url": "https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz",
    "identifier": "com_github_c_ares_c_ares"
  },
  {
    "file-prefix": "libcircllhist-63a16dd6f2fc7bc841bb17ff92be8318df60e2e1",
    "file-sha256": "8165aa25e529d7d4b9ae849d3bf30371255a99d6db0421516abcff23214cdc2c",
    "file-url": "https://github.com/circonus-labs/libcircllhist/archive/63a16dd6f2fc7bc841bb17ff92be8318df60e2e1.tar.gz",
    "identifier": "com_github_circonus_labs_libcircllhist"
  },
  {
    "file-prefix": "xxHash-0.6.5",
    "file-sha256": "19030315f4fc1b4b2cdb9d7a317069a109f90e39d1fe4c9159b7aaa39030eb95",
    "file-url": "https://github.com/Cyan4973/xxHash/archive/v0.6.5.tar.gz",
    "identifier": "com_github_cyan4973_xxhash"
  },
  {
    "file-prefix": "dd-opentracing-cpp-0.4.2",
    "file-sha256": "a3d1c03e7af570fa64c01df259e6e9bb78637a6bd9c65c6bf7e8703e466dc22f",
    "file-url": "https://github.com/DataDog/dd-opentracing-cpp/archive/v0.4.2.tar.gz",
    "identifier": "com_github_datadog_dd_opentracing_cpp"
  },
  {
    "file-prefix": "tclap-tclap-1-2-1-release-final",
    "file-sha256": "f0ede0721dddbb5eba3a47385a6e8681b14f155e1129dd39d1a959411935098f",
    "file-url": "https://github.com/eile/tclap/archive/tclap-1-2-1-release-final.tar.gz",
    "identifier": "com_github_eile_tclap"
  },
  {
    "file-prefix": "sql-parser-5f50c68bdf5f107692bb027d1c568f67597f4d7f",
    "file-sha256": "425dfee0c4fe9aff8acf2365cde3dd2ba7fb878d2ba37562d33920e34c40c05e",
    "file-url": "https://github.com/envoyproxy/sql-parser/archive/5f50c68bdf5f107692bb027d1c568f67597f4d7f.tar.gz",
    "identifier": "com_github_envoyproxy_sqlparser"
  },
  {
    "file-prefix": "fmt-5.3.0",
    "file-sha256": "4c0741e10183f75d7d6f730b8708a99b329b2f942dad5a9da3385ab92bb4a15c",
    "file-url": "https://github.com/fmtlib/fmt/releases/download/5.3.0/fmt-5.3.0.zip",
    "identifier": "com_github_fmtlib_fmt"
  },
  {
    "file-prefix": "spdlog-1.3.0",
    "file-sha256": "78786c641ca278388107e30f1f0fa0307e7e98e1c5279c3d29f71a143f9176b6",
    "file-url": "https://github.com/gabime/spdlog/archive/v1.3.0.tar.gz",
    "identifier": "com_github_gabime_spdlog"
  },
  {
    "file-prefix": "protobuf-1.2.0",
    "file-sha256": "957c8f03cf595525d2a667035d9865a0930b3d446be0ab6eb76972934f925b00",
    "file-url": "https://github.com/gogo/protobuf/archive/v1.2.0.tar.gz",
    "identifier": "com_github_gogo_protobuf"
  },
  {
    "file-prefix": "protobuf-31e0d063dd98c052257e5b69eeb006818133f45c",
    "file-sha256": "4cbd5303a5cf85791b3c310a50a479027c035d75091bb90c482ba67b0a2cf5b4",
    "file-url": "https://github.com/golang/protobuf/archive/31e0d063dd98c052257e5b69eeb006818133f45c.tar.gz",
    "identifier": "com_github_golang_protobuf"
  },
  {
    "file-prefix": "jwt_verify_lib-85cf0edf1f1bc507ff7d96a8d6a9bc20307b0fcf",
    "file-sha256": "700be26170c1917e83d1319b88a2112dccd1179cd78c5672940483e7c45ca6ae",
    "file-url": "https://github.com/google/jwt_verify_lib/archive/85cf0edf1f1bc507ff7d96a8d6a9bc20307b0fcf.tar.gz",
    "identifier": "com_github_google_jwt_verify"
  },
  {
    "file-prefix": "grpc-1.16.1",
    "file-sha256": "a5342629fe1b689eceb3be4d4f167b04c70a84b9d61cf8b555e968bc500bdb5a",
    "file-url": "https://github.com/grpc/grpc/archive/v1.16.1.tar.gz",
    "identifier": "com_github_grpc_grpc"
  },
  {
    "file-prefix": "yaml-cpp-0f9a586ca1dc29c2ecb8dd715a315b93e3f40f79",
    "file-sha256": "53dcffd55f3433b379fcc694f45c54898711c0e29159a7bd02e82a3e0253bac3",
    "file-url": "https://github.com/jbeder/yaml-cpp/archive/0f9a586ca1dc29c2ecb8dd715a315b93e3f40f79.tar.gz",
    "identifier": "com_github_jbeder_yaml_cpp"
  },
  {
    "file-prefix": "libevent-release-2.1.8-stable",
    "file-sha256": "316ddb401745ac5d222d7c529ef1eada12f58f6376a66c1118eee803cb70f83d",
    "file-url": "https://github.com/libevent/libevent/archive/release-2.1.8-stable.tar.gz",
    "identifier": "com_github_libevent_libevent"
  },
  {
    "file-prefix": "zlib-1.2.11",
    "file-sha256": "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff",
    "file-url": "https://github.com/madler/zlib/archive/v1.2.11.tar.gz",
    "identifier": "com_github_madler_zlib"
  },
  {
    "file-prefix": "msgpack-c-cpp-3.1.1",
    "file-sha256": "bda49f996a73d2c6080ff0523e7b535917cd28c8a79c3a5da54fc29332d61d1e",
    "file-url": "https://github.com/msgpack/msgpack-c/archive/cpp-3.1.1.tar.gz",
    "identifier": "com_github_msgpack_msgpack_c"
  },
  {
    "file-prefix": "nanopb-0.3.9.2",
    "file-sha256": "b8dd5cb0d184d424ddfea13ddee3f7b0920354334cbb44df434d55e5f0086b12",
    "file-url": "https://github.com/nanopb/nanopb/archive/0.3.9.2.tar.gz",
    "identifier": "com_github_nanopb_nanopb"
  },
  {
    "file-prefix": "nghttp2-1.35.1",
    "file-sha256": "cb70261634c33dc5adbe780afcfc5dab17838ee303631a02b983c6a217bc16ba",
    "file-url": "https://github.com/nghttp2/nghttp2/releases/download/v1.35.1/nghttp2-1.35.1.tar.gz",
    "identifier": "com_github_nghttp2_nghttp2"
  },
  {
    "file-prefix": "http-parser-2.9.0",
    "file-sha256": "ef26268c54c8084d17654ba2ed5140bffeffd2a040a895ffb22a6cca3f6c613f",
    "file-url": "https://github.com/nodejs/http-parser/archive/v2.9.0.tar.gz",
    "identifier": "com_github_nodejs_http_parser"
  },
  {
    "file-prefix": "rapidjson-1.1.0",
    "file-sha256": "bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e",
    "file-url": "https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz",
    "identifier": "com_github_tencent_rapidjson"
  },
  {
    "file-prefix": "abseil-cpp-cc8dcd307b76a575d2e3e0958a4fe4c7193c2f68",
    "file-sha256": "e35082e88b9da04f4d68094c05ba112502a5063712f3021adfa465306d238c76",
    "file-url": "https://github.com/abseil/abseil-cpp/archive/cc8dcd307b76a575d2e3e0958a4fe4c7193c2f68.tar.gz",
    "identifier": "com_google_absl"
  },
  {
    "file-prefix": "protobuf-7492b5681231c79f0265793fa57dc780ae2481d6",
    "file-sha256": "46f1da3a6a6db66dd240cf95a5553198f7c6e98e6ac942fceb8a1cf03291d96e",
    "file-url": "https://github.com/protocolbuffers/protobuf/archive/7492b5681231c79f0265793fa57dc780ae2481d6.tar.gz",
    "identifier": "com_google_protobuf"
  },
  {
    "file-prefix": "lightstep-tracer-cpp-0.8.0",
    "file-sha256": "defbf471facfebde6523ca1177529b63784893662d4ef2c60db074be8aef0634",
    "file-url": "https://github.com/lightstep/lightstep-tracer-cpp/archive/v0.8.0.tar.gz",
    "identifier": "com_lightstep_tracer_cpp"
  },
  {
    "file-prefix": "protoc-gen-validate-0.0.13",
    "file-sha256": "dce6c8a43849d2abe4d5e40f16e9a476bca6b7a47e128db4458a52d748f4a5eb",
    "file-url": "https://github.com/lyft/protoc-gen-validate/archive/v0.0.13.tar.gz",
    "identifier": "com_lyft_protoc_gen_validate"
  },
  {
    "file-prefix": "googleapis-d642131a6e6582fc226caf9893cb7fe7885b3411",
    "file-sha256": "16f5b2e8bf1e747a32f9a62e211f8f33c94645492e9bbd72458061d9a9de1f63",
    "file-url": "https://github.com/googleapis/googleapis/archive/d642131a6e6582fc226caf9893cb7fe7885b3411.tar.gz",
    "identifier": "googleapis"
  },
  {
    "file-prefix": "gperftools-fc00474ddc21fff618fc3f009b46590e241e425e",
    "file-sha256": "18574813a062eee487bc1b761e8024a346075a7cb93da19607af362dc09565ef",
    "file-url": "https://github.com/gperftools/gperftools/archive/fc00474ddc21fff618fc3f009b46590e241e425e.tar.gz",
    "identifier": "gperftools"
  },
  {
    "file-prefix": "grpc-httpjson-transcoding-64d6ac985360b624d8e95105701b64a3814794cd",
    "file-sha256": "dedd76b0169eb8c72e479529301a1d9b914a4ccb4d2b5ddb4ebe92d63a7b2152",
    "file-url": "https://github.com/grpc-ecosystem/grpc-httpjson-transcoding/archive/64d6ac985360b624d8e95105701b64a3814794cd.tar.gz",
    "identifier": "grpc_httpjson_transcoding"
  },
  {
    "file-prefix": "",
    "file-sha256": "7be7dc01f1e0afdba6c8eb2b43d2fa01c743be1b9273ab1eaf6c233df078d705",
    "file-url": "https://github.com/bazelbuild/rules_go/releases/download/0.16.5/rules_go-0.16.5.tar.gz",
    "identifier": "io_bazel_rules_go"
  },
  {
    "file-prefix": "opentracing-cpp-1.5.1",
    "file-sha256": "015c4187f7a6426a2b5196f0ccd982aa87f010cf61f507ae3ce5c90523f92301",
    "file-url": "https://github.com/opentracing/opentracing-cpp/archive/v1.5.1.tar.gz",
    "identifier": "io_opentracing_cpp"
  },
  {
    "file-prefix": "googleapis-d6f78d948c53f3b400bb46996eb3084359914f9b",
    "file-sha256": "d1ef4f790eeaa805e7b364de05b91f9eed66bd6ae46f1483bbf49c33d86998e5",
    "file-url": "https://github.com/googleapis/googleapis/archive/d6f78d948c53f3b400bb46996eb3084359914f9b.tar.gz",
    "identifier": "lightstep_vendored_googleapis"
  },
  {
    "file-prefix": "LuaJIT-2.1.0-beta3",
    "file-sha256": "409f7fe570d3c16558e594421c47bdd130238323c9d6fd6c83dedd2aaeb082a8",
    "file-url": "https://github.com/LuaJIT/LuaJIT/archive/v2.1.0-beta3.tar.gz",
    "identifier": "luajit"
  },
  {
    "file-prefix": "client_model-99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c",
    "file-sha256": "783bdaf8ee0464b35ec0c8704871e1e72afa0005c3f3587f65d9d6694bf3911b",
    "file-url": "https://github.com/prometheus/client_model/archive/99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c.tar.gz",
    "identifier": "prometheus_metrics_model"
  }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment