Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions source/exe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ alias(

envoy_cc_binary(
name = "envoy-static",
stamped = True,
deps = ["envoy_main_lib"],
)

Expand Down