From 0942882b17d483c10c03f6c6993037b08ce5eded Mon Sep 17 00:00:00 2001 From: Matt Klein Date: Mon, 17 Apr 2017 14:20:12 -0700 Subject: [PATCH 1/3] bazel: fix consumer projects --- bazel/envoy_build_system.bzl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bazel/envoy_build_system.bzl b/bazel/envoy_build_system.bzl index dc7c11c7371a5..afacbf78b38e2 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. @@ -107,8 +109,8 @@ def envoy_cc_binary(name, repository = "", deps = []): # Implicit .stamped targets to obtain builds with the (truncated) git SHA1. - _git_stamped_genrule(name) - _git_stamped_genrule(name + ".stripped") + _git_stamped_genrule(repository, name) + _git_stamped_genrule(repository, name + ".stripped") native.cc_binary( name = name, srcs = srcs, From 195ed2773482dd497fa1d91a2c47a5d97b4971bc Mon Sep 17 00:00:00 2001 From: Matt Klein Date: Mon, 17 Apr 2017 14:48:05 -0700 Subject: [PATCH 2/3] comment --- ci/do_ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 3d4ecfb65f97aa2b0ce2232315f45d243c96c400 Mon Sep 17 00:00:00 2001 From: Matt Klein Date: Mon, 17 Apr 2017 15:19:26 -0700 Subject: [PATCH 3/3] fix --- bazel/envoy_build_system.bzl | 6 ++++-- source/exe/BUILD | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bazel/envoy_build_system.bzl b/bazel/envoy_build_system.bzl index ac2af9e5d6206..d1613eae85405 100644 --- a/bazel/envoy_build_system.bzl +++ b/bazel/envoy_build_system.bzl @@ -108,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(repository, name) - _git_stamped_genrule(repository, 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/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"], )