Skip to content

Instantly share code, notes, and snippets.

@ptxmac
Created February 24, 2024 16:07
Show Gist options
  • Save ptxmac/75620c520c75d32e7cc74836f67b863b to your computer and use it in GitHub Desktop.
Save ptxmac/75620c520c75d32e7cc74836f67b863b to your computer and use it in GitHub Desktop.
bazel wrapper to automatically trigger gazelle
#!/usr/bin/env bash
# Small bazel wrapper than will trigger gazelle if bazel returns a missing dependencies error.
tempfile=$($BAZEL_REAL info command_log)
$BAZEL_REAL "$@"
res=$?
if [[ $res -gt 0 ]]; then
if grep "missing strict dependencies" $tempfile; then
echo "Bazel failed with missing strict dependencies. Running gazelle, then rerunning."
$BAZEL_REAL run //:gazelle
$BAZEL_REAL "$@"
res=$?
fi
exit $res
else
exit $res
fi
@ptxmac
Copy link
Author

ptxmac commented Feb 24, 2024

Save this as tools/bazel. All calls to bazel will automatically be replaced by this script.

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