diff --git a/bazel/envoy_build_system.bzl b/bazel/envoy_build_system.bzl index 16755a95450f5..d1613eae85405 100644 --- a/bazel/envoy_build_system.bzl +++ b/bazel/envoy_build_system.bzl @@ -81,22 +81,24 @@ def envoy_cc_library(name, alwayslink = 1, ) -def _git_stamped_genrule(name): +def _git_stamped_genrule(repository, name): # To workaround https://github.com/bazelbuild/bazel/issues/2805, we # do binary rewriting to replace the linker produced MD5 hash with the # version_generated.cc git SHA1 hash (truncated). + version_generated = repository + "//:version_generated.cc" + rewriter = repository + "//tools:git_sha_rewriter.py" native.genrule( name = name + "_stamped", srcs = [ name, - "//source/version_generated:version_generated.cc", + version_generated, ], outs = [name + ".stamped"], cmd = "cp $(location " + name + ") $@ && " + "chmod u+w $@ && " + - "$(location //tools:git_sha_rewriter.py) " + - "$(location //source/version_generated:version_generated.cc) $@", - tools = ["//tools:git_sha_rewriter.py"], + "$(location " + rewriter + ") " + + "$(location " + version_generated + ") $@", + tools = [rewriter], ) # Envoy C++ binary targets should be specified with this function. @@ -106,10 +108,12 @@ def envoy_cc_binary(name, testonly = 0, visibility = None, repository = "", + stamped = False, deps = []): # Implicit .stamped targets to obtain builds with the (truncated) git SHA1. - _git_stamped_genrule(name) - _git_stamped_genrule(name + ".stripped") + if stamped: + _git_stamped_genrule(repository, name) + _git_stamped_genrule(repository, name + ".stripped") native.cc_binary( name = name, srcs = srcs, diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 7b412517e1b8c..27cd291ebc0b4 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -11,7 +11,7 @@ if [[ "$1" == "bazel.debug" ]]; then echo "bazel debug build with tests..." cd "${ENVOY_CONSUMER_SRCDIR}" echo "Building..." - bazel build ${BAZEL_BUILD_OPTIONS} @envoy//source/exe:envoy-static + bazel build ${BAZEL_BUILD_OPTIONS} @envoy//source/exe:envoy-static.stamped echo "Testing..." bazel test ${BAZEL_BUILD_OPTIONS} --test_output=all \ --cache_test_results=no @envoy//test/... //:echo2_integration_test diff --git a/source/exe/BUILD b/source/exe/BUILD index 8bfb04b120fb3..a72a2b13053e2 100644 --- a/source/exe/BUILD +++ b/source/exe/BUILD @@ -9,6 +9,7 @@ alias( envoy_cc_binary( name = "envoy-static", + stamped = True, deps = ["envoy_main_lib"], )