Skip to content

Commit

Permalink
build: undo some protobuf hacks, put some new ones in. (#1311)
Browse files Browse the repository at this point in the history
* build: undo some protobuf hacks, put some new ones in.

* Remove the workaround for protocolbuffers/protobuf#3327
  in do_ci.sh.

* Remove the multiple protobuf versions that existed because
  protocolbuffers/protobuf#2508 wasn't merged.

* Add some evil symlink stuff to get @protobuf_bzl inferred from
  wherever WORKSPACE points the envoy_dependencies path at.

As a bonus, enabled more verbose build of external deps so we don't sit
around for minutes on initial checkout with no activity indicator. This
can be done safely now as everyone should be at Bazel 0.5.2.

* Don't put verbose Bazel spew into query targets for coverage.

* Always start from a clean test/coverage/BUILD, don't include it in the query.
  • Loading branch information
htuch authored Jul 23, 2017
1 parent f247380 commit 7153327
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 48 deletions.
45 changes: 26 additions & 19 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ def _repository_impl(ctxt):
result = ctxt.execute(
["./repositories.sh"] + ctxt.attr.recipes,
environment = environment,
# Ideally we would print progress, but instead this hangs on "INFO: Loading
# complete. Analyzing.." today, see
# https://github.com/bazelbuild/bazel/issues/1289. We could set quiet=False
# as well to indicate progress, but that isn't supported in versions folks
# are using right now (0.4.5).
# TODO(htuch): Revisit this when everyone is on newer Bazel versions.
#
# quiet = False,
quiet = False,
)
print("External dep build exited with return code: %d" % result.return_code)
print(result.stdout)
print(result.stderr)
if result.return_code != 0:
fail("External dep build failed")

def _protobuf_repository_impl(ctxt):
deps_path = ctxt.attr.envoy_deps_path
if not deps_path.endswith("/"):
deps_path += "/"
ctxt.symlink(Label(deps_path + "thirdparty/protobuf:protobuf.bzl"), "protobuf.bzl")
ctxt.symlink(Label(deps_path + "thirdparty/protobuf:BUILD"), "BUILD")
ctxt.symlink(ctxt.path(Label(deps_path + "thirdparty/protobuf:BUILD")).dirname.get_child("src"),
"src")

def py_jinja2_dep():
BUILD = """
py_library(
Expand Down Expand Up @@ -126,17 +128,6 @@ def envoy_api_deps(skip_targets):
)

def envoy_dependencies(path = "@envoy_deps//", skip_protobuf_bzl = False, skip_targets = []):
if not skip_protobuf_bzl:
native.git_repository(
name = "protobuf_bzl",
# Using a non-canonical repository/branch here. This is a workaround to the lack of
# merge on https://github.com/google/protobuf/pull/2508, which is needed for supporting
# arbitrary CC compiler locations from the environment. The branch is
# https://github.com/htuch/protobuf/tree/v3.2.0-default-shell-env, which is the 3.2.0
# release with the above mentioned PR cherry picked.
commit = "d490587268931da78c942a6372ef57bb53db80da",
remote = REPO_LOCATIONS["protobuf"],
)
native.bind(
name = "cc_wkt_protos",
actual = "@protobuf_bzl//:cc_wkt_protos",
Expand Down Expand Up @@ -173,6 +164,22 @@ def envoy_dependencies(path = "@envoy_deps//", skip_protobuf_bzl = False, skip_t
recipes = recipes.to_list(),
)

protobuf_repository = repository_rule(
implementation = _protobuf_repository_impl,
attrs = {
"envoy_deps_path": attr.string(),
},
)

# If the WORKSPACE hasn't already supplied @protobuf_bzl and told us to skip it, we need to map in the
# full repo into @protobuf_bzl so that we can depend on this in envoy_build_system.bzl and for things
# like @protobuf_bzl//:cc_wkt_protos in envoy-api. We do this by some evil symlink stuff.
if not skip_protobuf_bzl:
protobuf_repository(
name = "protobuf_bzl",
envoy_deps_path = path,
)

for t in TARGET_RECIPES:
if t not in skip_targets:
native.bind(
Expand Down
6 changes: 0 additions & 6 deletions ci/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ load("//bazel:cc_configure.bzl", "cc_configure")

envoy_dependencies(
path = "//ci/prebuilt",
skip_protobuf_bzl = True,
)

local_repository(
name = "protobuf_bzl",
path = "/thirdparty/protobuf",
)

cc_configure()
Expand Down
6 changes: 0 additions & 6 deletions ci/WORKSPACE.filter.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ load("//bazel:cc_configure.bzl", "cc_configure")

envoy_dependencies(
path = "@envoy//ci/prebuilt",
skip_protobuf_bzl = True,
)

local_repository(
name = "protobuf_bzl",
path = "/thirdparty/protobuf",
)

cc_configure()
Expand Down
14 changes: 0 additions & 14 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ echo "building using ${NUM_CPUS} CPUs"

function bazel_release_binary_build() {
echo "Building..."
BUILD_TYPE=opt protobuf_3322_workaround
cd "${ENVOY_CI_DIR}"
bazel --batch build ${BAZEL_BUILD_OPTIONS} -c opt //source/exe:envoy-static.stamped
# Copy the envoy-static binary somewhere that we can access outside of the
Expand All @@ -21,7 +20,6 @@ function bazel_release_binary_build() {

function bazel_debug_binary_build() {
echo "Building..."
BUILD_TYPE=dbg protobuf_3322_workaround
cd "${ENVOY_CI_DIR}"
bazel --batch build ${BAZEL_BUILD_OPTIONS} -c dbg //source/exe:envoy-static.stamped
# Copy the envoy-static binary somewhere that we can access outside of the
Expand All @@ -31,11 +29,6 @@ function bazel_debug_binary_build() {
"${ENVOY_DELIVERY_DIR}"/envoy-debug
}

# See https://github.com/google/protobuf/issues/3322
function protobuf_3322_workaround() {
ln -sf /thirdparty_build_"${BUILD_TYPE}" "${ENVOY_SRCDIR}"/ci/prebuilt/thirdparty_build
}

if [[ "$1" == "bazel.release" ]]; then
setup_gcc_toolchain
echo "bazel release build with tests..."
Expand All @@ -62,7 +55,6 @@ elif [[ "$1" == "bazel.debug.server_only" ]]; then
exit 0
elif [[ "$1" == "bazel.asan" ]]; then
setup_clang_toolchain
BUILD_TYPE=dbg protobuf_3322_workaround
echo "bazel ASAN/UBSAN debug build with tests..."
cd "${ENVOY_FILTER_EXAMPLE_SRCDIR}"
echo "Building and testing..."
Expand All @@ -71,7 +63,6 @@ elif [[ "$1" == "bazel.asan" ]]; then
exit 0
elif [[ "$1" == "bazel.tsan" ]]; then
setup_clang_toolchain
BUILD_TYPE=dbg protobuf_3322_workaround
echo "bazel TSAN debug build with tests..."
cd "${ENVOY_FILTER_EXAMPLE_SRCDIR}"
echo "Building and testing..."
Expand All @@ -80,7 +71,6 @@ elif [[ "$1" == "bazel.tsan" ]]; then
exit 0
elif [[ "$1" == "bazel.dev" ]]; then
setup_clang_toolchain
BUILD_TYPE=dbg protobuf_3322_workaround
# This doesn't go into CI but is available for developer convenience.
echo "bazel fastbuild build with tests..."
cd "${ENVOY_CI_DIR}"
Expand All @@ -96,10 +86,6 @@ elif [[ "$1" == "bazel.dev" ]]; then
exit 0
elif [[ "$1" == "bazel.coverage" ]]; then
setup_gcc_toolchain
# Technically test/run_envoy_bazel_coverage.sh is doing a -c dbg build, but it
# also sets -DNDEBUG, so for protobuf #3322 purposes, we need to setup for
# opt.
BUILD_TYPE=opt protobuf_3322_workaround
echo "bazel coverage build with tests..."
export GCOVR="/thirdparty/gcovr/scripts/gcovr"
export GCOVR_DIR="${ENVOY_BUILD_DIR}/bazel-envoy"
Expand Down
2 changes: 1 addition & 1 deletion ci/envoy_build_sha.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ENVOY_BUILD_SHA=373f1151ac4e87e5e2083375c55013d4a67e08b0
ENVOY_BUILD_SHA=a49b57007b6459209deee02059bd5ec7d0575762
6 changes: 4 additions & 2 deletions test/coverage/gen_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ set -e
# E.g., "//envoy-lyft/test/..."
[ -z "${EXTRA_QUERY_PATHS}" ] && EXTRA_QUERY_PATHS=""

TARGETS=$("${BAZEL_BIN}" query ${BAZEL_QUERY_OPTIONS} "attr('tags', 'coverage_test_lib', ${REPOSITORY}//test/...)")
rm -f "${BUILD_PATH}"

TARGETS=$("${BAZEL_BIN}" query ${BAZEL_QUERY_OPTIONS} "attr('tags', 'coverage_test_lib', ${REPOSITORY}//test/...)" | grep "^//")
if [ -n "${EXTRA_QUERY_PATHS}" ]; then
TARGETS="$TARGETS $("${BAZEL_BIN}" query ${BAZEL_QUERY_OPTIONS} "attr('tags', 'coverage_test_lib', ${EXTRA_QUERY_PATHS})")"
TARGETS="$TARGETS $("${BAZEL_BIN}" query ${BAZEL_QUERY_OPTIONS} "attr('tags', 'coverage_test_lib', ${EXTRA_QUERY_PATHS})" | grep "^//")"
fi

(
Expand Down

0 comments on commit 7153327

Please sign in to comment.