From 662e76f3dea6da30658ec86f649f8b005a379f3e Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Tue, 4 Dec 2018 14:53:18 -0500 Subject: [PATCH 1/9] build: external_cmake for cmake deps. This revives #4516, replacing all external cmake deps with the pending bazel foreign_cc support. To make use of this, with the current release Bazel version, it's necessary to set --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs on the CLI or in .bazelrc. Risk Level: Low Testing: bazel test //test/... Signed-off-by: Harvey Tuch --- WORKSPACE | 3 + bazel/EXTERNAL_DEPS.md | 17 +++- bazel/foreign_cc/BUILD | 82 ++++++++++++++++ bazel/foreign_cc/nghttp2.patch | 12 +++ bazel/repositories.bzl | 95 +++++++++++++++++++ bazel/repository_locations.bzl | 31 ++++++ bazel/target_recipes.bzl | 6 -- ci/WORKSPACE | 3 + ci/WORKSPACE.filter.example | 3 + ci/build_container/build_recipes/benchmark.sh | 30 ------ ci/build_container/build_recipes/cares.sh | 43 --------- ci/build_container/build_recipes/libevent.sh | 39 -------- ci/build_container/build_recipes/nghttp2.sh | 47 --------- ci/build_container/build_recipes/yaml-cpp.sh | 37 -------- ci/build_container/build_recipes/zlib.sh | 22 ----- ci/prebuilt/BUILD | 63 ------------ .../access_log_formatter_speed_test.cc | 2 +- test/common/common/utility_speed_test.cc | 2 +- test/common/http/codes_speed_test.cc | 2 +- test/common/network/lc_trie_speed_test.cc | 2 +- .../stats/thread_local_store_speed_test.cc | 2 +- .../upstream/load_balancer_benchmark.cc | 2 +- .../tls_inspector/tls_inspector_benchmark.cc | 2 +- test/run_envoy_bazel_coverage.sh | 1 + tools/bazel.rc | 1 + 25 files changed, 253 insertions(+), 296 deletions(-) create mode 100644 bazel/foreign_cc/BUILD create mode 100644 bazel/foreign_cc/nghttp2.patch delete mode 100644 ci/build_container/build_recipes/benchmark.sh delete mode 100755 ci/build_container/build_recipes/cares.sh delete mode 100755 ci/build_container/build_recipes/libevent.sh delete mode 100755 ci/build_container/build_recipes/nghttp2.sh delete mode 100755 ci/build_container/build_recipes/yaml-cpp.sh delete mode 100644 ci/build_container/build_recipes/zlib.sh diff --git a/WORKSPACE b/WORKSPACE index 32547b75780bc..995f45e3d23a6 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -4,6 +4,9 @@ load("//bazel:repositories.bzl", "envoy_dependencies", "GO_VERSION") load("//bazel:cc_configure.bzl", "cc_configure") envoy_dependencies() +load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies") +rules_foreign_cc_dependencies() + cc_configure() load("@envoy_api//bazel:repositories.bzl", "api_dependencies") diff --git a/bazel/EXTERNAL_DEPS.md b/bazel/EXTERNAL_DEPS.md index 89bfc08a1413b..f2d4cc48c3a4e 100644 --- a/bazel/EXTERNAL_DEPS.md +++ b/bazel/EXTERNAL_DEPS.md @@ -17,6 +17,18 @@ build process. `external_deps` attribute. 3. `bazel test //test/...` +# Adding external dependencies to Envoy (external cmake) + +This is the preferred style of adding dependencies that use cmake for their build system. + +1. Define a the source Bazel repository in [`bazel/repositories.bzl`](repositories.bzl), in the + `envoy_dependencies()` function. +2. Add a `cmake_external` rule to [`bazel/foreign_cc/BUILD`](bazel/foreign_cc/BUILD). This will + reference the source repository in step 1. +3. Reference your new external dependency in some `envoy_cc_library` via Y in the + `external_deps` attribute. +4. `bazel test //test/...` + # Adding external dependencies to Envoy (genrule repository) This is the newer style of adding dependencies with no upstream Bazel configs. @@ -44,8 +56,9 @@ to binaries, libraries, headers, etc. # Adding external dependencies to Envoy (build recipe) -This is the older style of adding dependencies. It uses shell scripts to build -and install dependencies into a shared directory prefix. +This is the older style of adding dependencies. It uses shell scripts to build and install +dependencies into a shared directory prefix. This should no longer be used unless there are +extenuating circumstances. 1. Add a build recipe X in [`ci/build_container/build_recipes`](../ci/build_container/build_recipes) for developer-local and CI external dependency build flows. diff --git a/bazel/foreign_cc/BUILD b/bazel/foreign_cc/BUILD new file mode 100644 index 0000000000000..a2529485ea137 --- /dev/null +++ b/bazel/foreign_cc/BUILD @@ -0,0 +1,82 @@ +licenses(["notice"]) # Apache 2 + +load("//bazel:envoy_build_system.bzl", "envoy_package") +load("@rules_foreign_cc//tools/build_defs:cmake.bzl", "cmake_external") +load("@foreign_cc_platform_utils//:tools.bzl", "NINJA_COMMAND", "NINJA_DEP") + +envoy_package() + +cmake_external( + name = "ares", + cache_entries = { + "CARES_SHARED": "no", + "CARES_STATIC": "on", + }, + cmake_options = ["-GNinja"], + lib_source = "@com_github_c_ares_c_ares//:all", + make_commands = [ + NINJA_COMMAND, + NINJA_COMMAND + " install", + ], + static_libraries = ["libcares.a"], + tools_deps = NINJA_DEP, +) + +cmake_external( + name = "event", + cache_entries = { + "EVENT__DISABLE_OPENSSL": "on", + "EVENT__DISABLE_REGRESS": "on", + }, + cmake_options = ["-GNinja"], + lib_source = "@com_github_libevent_libevent//:all", + make_commands = [ + NINJA_COMMAND, + NINJA_COMMAND + " install", + ], + static_libraries = ["libevent.a"], + tools_deps = NINJA_DEP, +) + +cmake_external( + name = "nghttp2", + cache_entries = { + "ENABLE_STATIC_LIB": "on", + "ENABLE_LIB_ONLY": "on", + }, + cmake_options = ["-GNinja"], + lib_source = "@com_github_nghttp2_nghttp2//:all", + make_commands = [ + NINJA_COMMAND, + NINJA_COMMAND + " install", + ], + static_libraries = ["libnghttp2.a"], + tools_deps = NINJA_DEP, +) + +cmake_external( + name = "yaml", + cache_entries = { + "YAML_CPP_BUILD_TESTS": "off", + }, + cmake_options = ["-GNinja"], + lib_source = "@com_github_jbeder_yaml_cpp//:all", + make_commands = [ + NINJA_COMMAND, + NINJA_COMMAND + " install", + ], + static_libraries = ["libyaml-cpp.a"], + tools_deps = NINJA_DEP, +) + +cmake_external( + name = "zlib", + cmake_options = ["-GNinja"], + lib_source = "@com_github_madler_zlib//:all", + make_commands = [ + NINJA_COMMAND, + NINJA_COMMAND + " install", + ], + static_libraries = ["libz.a"], + tools_deps = NINJA_DEP, +) diff --git a/bazel/foreign_cc/nghttp2.patch b/bazel/foreign_cc/nghttp2.patch new file mode 100644 index 0000000000000..4cc4ea7b32ae0 --- /dev/null +++ b/bazel/foreign_cc/nghttp2.patch @@ -0,0 +1,12 @@ +diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt +index 17e422b2..e58070f5 100644 +--- a/lib/CMakeLists.txt ++++ b/lib/CMakeLists.txt +@@ -52,6 +52,7 @@ + COMPILE_FLAGS "${WARNCFLAGS}" + VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION} + ARCHIVE_OUTPUT_NAME nghttp2 ++ ARCHIVE_OUTPUT_DIRECTORY static + ) + target_compile_definitions(nghttp2_static PUBLIC "-DNGHTTP2_STATICLIB") + if(ENABLE_STATIC_LIB) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 4c32dab853eac..23b618cb75b6b 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -15,6 +15,10 @@ PPC_SKIP_TARGETS = {"luajit": "envoy.filters.http.lua"} # go version for rules_go GO_VERSION = "1.10.4" +# Make all contents of an external repository accessible under a filegroup. Used for external HTTP +# archives, e.g. cares. +BUILD_ALL_CONTENT = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])""" + def _repository_impl(name, **kwargs): # `existing_rule_keys` contains the names of repositories that have already # been defined in the Bazel workspace. By skipping repos with existing keys, @@ -265,6 +269,9 @@ def envoy_dependencies(path = "@envoy_deps//", skip_targets = []): if "envoy_build_config" not in native.existing_rules().keys(): _default_envoy_build_config(name = "envoy_build_config") + # Setup rules_foreign_cc + _foreign_cc_dependencies() + # The long repo names (`com_github_fmtlib_fmt` instead of `fmtlib`) are # semi-standard in the Bazel community, intended to avoid both duplicate # dependencies and name conflicts. @@ -272,6 +279,7 @@ def envoy_dependencies(path = "@envoy_deps//", skip_targets = []): _com_google_absl() _com_github_bombela_backward() _com_github_circonus_labs_libcircllhist() + _com_github_c_ares_c_ares() _com_github_cyan4973_xxhash() _com_github_eile_tclap() _com_github_fmtlib_fmt() @@ -282,8 +290,13 @@ def envoy_dependencies(path = "@envoy_deps//", skip_targets = []): _com_lightstep_tracer_cpp() _com_github_datadog_dd_opentracing_cpp() _com_github_grpc_grpc() + _com_github_google_benchmark() _com_github_google_jwt_verify() + _com_github_jbeder_yaml_cpp() + _com_github_libevent_libevent() + _com_github_madler_zlib() _com_github_nanopb_nanopb() + _com_github_nghttp2_nghttp2() _com_github_nodejs_http_parser() _com_github_tencent_rapidjson() _com_google_googletest() @@ -324,6 +337,18 @@ def _com_github_circonus_labs_libcircllhist(): actual = "@com_github_circonus_labs_libcircllhist//:libcircllhist", ) +def _com_github_c_ares_c_ares(): + location = REPOSITORY_LOCATIONS["com_github_c_ares_c_ares"] + http_archive( + name = "com_github_c_ares_c_ares", + build_file_content = BUILD_ALL_CONTENT, + **location + ) + native.bind( + name = "ares", + actual = "//bazel/foreign_cc:ares", + ) + def _com_github_cyan4973_xxhash(): _repository_impl( name = "com_github_cyan4973_xxhash", @@ -374,6 +399,17 @@ def _com_github_gcovr_gcovr(): actual = "@com_github_gcovr_gcovr//:gcovr", ) +def _com_github_google_benchmark(): + location = REPOSITORY_LOCATIONS["com_github_google_benchmark"] + http_archive( + name = "com_github_google_benchmark", + **location + ) + native.bind( + name = "benchmark", + actual = "@com_github_google_benchmark//:benchmark", + ) + def _com_github_google_libprotobuf_mutator(): _repository_impl( name = "com_github_google_libprotobuf_mutator", @@ -384,6 +420,57 @@ def _com_github_google_libprotobuf_mutator(): actual = "@com_github_google_libprotobuf_mutator//:libprotobuf_mutator", ) +def _com_github_jbeder_yaml_cpp(): + location = REPOSITORY_LOCATIONS["com_github_jbeder_yaml_cpp"] + http_archive( + name = "com_github_jbeder_yaml_cpp", + build_file_content = BUILD_ALL_CONTENT, + **location + ) + native.bind( + name = "yaml_cpp", + actual = "//bazel/foreign_cc:yaml", + ) + +def _com_github_libevent_libevent(): + location = REPOSITORY_LOCATIONS["com_github_libevent_libevent"] + http_archive( + name = "com_github_libevent_libevent", + build_file_content = BUILD_ALL_CONTENT, + **location + ) + native.bind( + name = "event", + actual = "//bazel/foreign_cc:event", + ) + +def _com_github_madler_zlib(): + location = REPOSITORY_LOCATIONS["com_github_madler_zlib"] + http_archive( + name = "com_github_madler_zlib", + build_file_content = BUILD_ALL_CONTENT, + **location + ) + native.bind( + name = "zlib", + actual = "//bazel/foreign_cc:zlib", + ) + +def _com_github_nghttp2_nghttp2(): + location = REPOSITORY_LOCATIONS["com_github_nghttp2_nghttp2"] + http_archive( + name = "com_github_nghttp2_nghttp2", + build_file_content = BUILD_ALL_CONTENT, + patch_args = ["-p1"], + patch_cmds = ["find . -name '*.sh' -exec sed -i.orig '1s|#!/usr/bin/env sh\$|/bin/sh\$|' {} +"], + patches = ["//bazel/foreign_cc:nghttp2.patch"], + **location + ) + native.bind( + name = "nghttp2", + actual = "//bazel/foreign_cc:nghttp2", + ) + def _io_opentracing_cpp(): _repository_impl("io_opentracing_cpp") native.bind( @@ -575,6 +662,14 @@ def _com_github_google_jwt_verify(): actual = "@com_github_google_jwt_verify//:jwt_verify_lib", ) +def _foreign_cc_dependencies(): + http_archive( + name = "rules_foreign_cc", + strip_prefix = "rules_foreign_cc-master", + # TODO(htuch): Pin to SHA or release. + url = "https://github.com/bazelbuild/rules_foreign_cc/archive/master.zip", + ) + def _apply_dep_blacklist(ctxt, recipes): newlist = [] skip_list = dict() diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index e82b9c299cee3..1204f6de79903 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -26,6 +26,11 @@ REPOSITORY_LOCATIONS = dict( strip_prefix = "backward-cpp-1.4", urls = ["https://github.com/bombela/backward-cpp/archive/v1.4.tar.gz"], ), + com_github_c_ares_c_ares = dict( + sha256 = "7deb7872cbd876c29036d5f37e30c4cbc3cc068d59d8b749ef85bb0736649f04", + strip_prefix = "c-ares-cares-1_15_0", + urls = ["https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz"], + ), com_github_circonus_labs_libcircllhist = dict( sha256 = "9949e2864b8ad00ee5c3e9c1c3c01e51b6b68bb442a919652fc66b9776477987", strip_prefix = "libcircllhist-fd8a14463739d247b414825cc56ca3946792a3b9", @@ -74,6 +79,11 @@ REPOSITORY_LOCATIONS = dict( strip_prefix = "nanopb-f8ac463766281625ad710900479130c7fcb4d63b", urls = ["https://github.com/nanopb/nanopb/archive/f8ac463766281625ad710900479130c7fcb4d63b.tar.gz"], ), + com_github_nghttp2_nghttp2 = dict( + sha256 = "8889399ddd38aa0405f6e84f1c050a292286089441686b8a9c5e937de4f5b61d", + strip_prefix = "nghttp2-1.34.0", + urls = ["https://github.com/nghttp2/nghttp2/releases/download/v1.34.0/nghttp2-1.34.0.tar.gz"], + ), io_opentracing_cpp = dict( sha256 = "4455ca507936bc4b658ded10a90d8ebbbd61c58f06207be565a4ffdc885687b5", strip_prefix = "opentracing-cpp-1.5.0", @@ -95,6 +105,27 @@ REPOSITORY_LOCATIONS = dict( strip_prefix = "dd-opentracing-cpp-0.3.6", urls = ["https://github.com/DataDog/dd-opentracing-cpp/archive/v0.3.6.tar.gz"], ), + com_github_google_benchmark = dict( + # TODO (moderation) change back to tarball method on next benchmark release + sha256 = "0de43b6eaddd356f1d6cd164f73f37faf2f6c96fd684e1f7ea543ce49c1d144e", + strip_prefix = "benchmark-505be96ab23056580a3a2315abba048f4428b04e", + urls = ["https://github.com/google/benchmark/archive/505be96ab23056580a3a2315abba048f4428b04e.tar.gz"], + ), + com_github_libevent_libevent = dict( + sha256 = "316ddb401745ac5d222d7c529ef1eada12f58f6376a66c1118eee803cb70f83d", + strip_prefix = "libevent-release-2.1.8-stable", + urls = ["https://github.com/libevent/libevent/archive/release-2.1.8-stable.tar.gz"], + ), + com_github_madler_zlib = dict( + sha256 = "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff", + strip_prefix = "zlib-1.2.11", + urls = ["https://github.com/madler/zlib/archive/v1.2.11.tar.gz"], + ), + com_github_jbeder_yaml_cpp = dict( + sha256 = "53dcffd55f3433b379fcc694f45c54898711c0e29159a7bd02e82a3e0253bac3", + strip_prefix = "yaml-cpp-0f9a586ca1dc29c2ecb8dd715a315b93e3f40f79", + urls = ["https://github.com/jbeder/yaml-cpp/archive/0f9a586ca1dc29c2ecb8dd715a315b93e3f40f79.tar.gz"], + ), com_github_msgpack_msgpack_c = dict( sha256 = "bda49f996a73d2c6080ff0523e7b535917cd28c8a79c3a5da54fc29332d61d1e", strip_prefix = "msgpack-c-cpp-3.1.1", diff --git a/bazel/target_recipes.bzl b/bazel/target_recipes.bzl index 6260336887927..888246f5a03ed 100644 --- a/bazel/target_recipes.bzl +++ b/bazel/target_recipes.bzl @@ -2,12 +2,6 @@ # target in //ci/prebuilt/BUILD to the underlying build recipe in # ci/build_container/build_recipes. TARGET_RECIPES = { - "ares": "cares", - "benchmark": "benchmark", - "event": "libevent", "tcmalloc_and_profiler": "gperftools", "luajit": "luajit", - "nghttp2": "nghttp2", - "yaml_cpp": "yaml-cpp", - "zlib": "zlib", } diff --git a/ci/WORKSPACE b/ci/WORKSPACE index b22222ef37bd3..1ea227e75771c 100644 --- a/ci/WORKSPACE +++ b/ci/WORKSPACE @@ -12,6 +12,9 @@ local_repository( envoy_dependencies( path = "@envoy//ci/prebuilt", ) +# TODO(htuch): Roll this into envoy_dependencies() +load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies") +rules_foreign_cc_dependencies() cc_configure() diff --git a/ci/WORKSPACE.filter.example b/ci/WORKSPACE.filter.example index 632e35eac78d7..c528e921e3e68 100644 --- a/ci/WORKSPACE.filter.example +++ b/ci/WORKSPACE.filter.example @@ -11,6 +11,9 @@ load("//bazel:cc_configure.bzl", "cc_configure") envoy_dependencies( path = "@envoy//ci/prebuilt", ) +# TODO(htuch): Roll this into envoy_dependencies() +load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies") +rules_foreign_cc_dependencies() cc_configure() diff --git a/ci/build_container/build_recipes/benchmark.sh b/ci/build_container/build_recipes/benchmark.sh deleted file mode 100644 index 19a1f7ce02c5f..0000000000000 --- a/ci/build_container/build_recipes/benchmark.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -set -e - -# use commit where cmake 3.6 feature removed. Unblocks Ubuntu 16.xx or below builds -# TODO (moderation) change back to tarball method on next benchmark release -export COMMIT="505be96ab23056580a3a2315abba048f4428b04e" - -git clone https://github.com/google/benchmark.git -(cd benchmark; git reset --hard "$COMMIT") -mkdir build - -cd build - -cmake -G "Ninja" ../benchmark \ - -DCMAKE_BUILD_TYPE=RELEASE \ - -DBENCHMARK_ENABLE_GTEST_TESTS=OFF -ninja - -benchmark_lib="libbenchmark.a" -if [[ "${OS}" == "Windows_NT" ]]; then - benchmark_lib="benchmark.lib" -fi - -cp "src/$benchmark_lib" "$THIRDPARTY_BUILD"/lib -cd ../benchmark - -INCLUDE_DIR="$THIRDPARTY_BUILD/include/testing/base/public" -mkdir -p "$INCLUDE_DIR" -cp include/benchmark/benchmark.h "$INCLUDE_DIR" diff --git a/ci/build_container/build_recipes/cares.sh b/ci/build_container/build_recipes/cares.sh deleted file mode 100755 index 6a0f905252dc6..0000000000000 --- a/ci/build_container/build_recipes/cares.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -set -e - -TAG=cares-1_15_0 -VERSION=c-ares-1.15.0 -SHA256=6cdb97871f2930530c97deb7cf5c8fa4be5a0b02c7cea6e7c7667672a39d6852 - -# cares is fussy over whether -D appears inside CFLAGS vs. CPPFLAGS, oss-fuzz -# sets CFLAGS with -D, so we need to impedance match here. In turn, OS X automake -# is fussy about newlines in CFLAGS/CPPFLAGS, so translate them into spaces. -CPPFLAGS="$(for f in $CXXFLAGS; do if [[ $f =~ -D.* ]]; then echo $f; fi; done | tr '\n' ' ')" -CFLAGS="$(for f in $CXXFLAGS; do if [[ ! $f =~ -D.* ]]; then echo $f; fi; done | tr '\n' ' ')" - -curl https://github.com/c-ares/c-ares/releases/download/"$TAG"/"$VERSION".tar.gz -sLo "$VERSION".tar.gz \ - && echo "$SHA256" "$VERSION".tar.gz | sha256sum --check -tar xf "$VERSION".tar.gz -cd "$VERSION" - -mkdir build -cd build - -build_type=RelWithDebInfo -if [[ "${OS}" == "Windows_NT" ]]; then - # On Windows, every object file in the final executable needs to be compiled to use the - # same version of the C Runtime Library. If Envoy is built with '-c dbg', then it will - # use the Debug C Runtime Library. Setting CMAKE_BUILD_TYPE to Debug will cause c-ares - # to use the debug version as well - # TODO: when '-c fastbuild' and '-c opt' work for Windows builds, set this appropriately - build_type=Debug -fi - -cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX="$THIRDPARTY_BUILD" \ - -DCARES_SHARED=no \ - -DCARES_STATIC=on \ - -DCMAKE_BUILD_TYPE="$build_type" \ - .. -ninja -ninja install - -if [[ "${OS}" == "Windows_NT" ]]; then - cp "CMakeFiles/c-ares.dir/c-ares.pdb" "$THIRDPARTY_BUILD/lib/c-ares.pdb" -fi diff --git a/ci/build_container/build_recipes/libevent.sh b/ci/build_container/build_recipes/libevent.sh deleted file mode 100755 index 7ae3f2b4c09b9..0000000000000 --- a/ci/build_container/build_recipes/libevent.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -set -e - -VERSION=2.1.8-stable -SHA256=316ddb401745ac5d222d7c529ef1eada12f58f6376a66c1118eee803cb70f83d - -# Maintainer provided source tarball does not contain cmake content so using Github tarball. -curl https://github.com/libevent/libevent/archive/release-"$VERSION".tar.gz -sLo libevent-release-"$VERSION".tar.gz \ - && echo "$SHA256" libevent-release-"$VERSION".tar.gz | sha256sum --check -tar xf libevent-release-"$VERSION".tar.gz -cd libevent-release-"$VERSION" - -mkdir build -cd build - -# libevent defaults CMAKE_BUILD_TYPE to Release -build_type=Release -if [[ "${OS}" == "Windows_NT" ]]; then - # On Windows, every object file in the final executable needs to be compiled to use the - # same version of the C Runtime Library. If Envoy is built with '-c dbg', then it will - # use the Debug C Runtime Library. Setting CMAKE_BUILD_TYPE to Debug will cause libevent - # to use the debug version as well - # TODO: when '-c fastbuild' and '-c opt' work for Windows builds, set this appropriately - build_type=Debug -fi - -cmake -G "Ninja" \ - -DCMAKE_INSTALL_PREFIX="$THIRDPARTY_BUILD" \ - -DEVENT__DISABLE_OPENSSL:BOOL=on \ - -DEVENT__DISABLE_REGRESS:BOOL=on \ - -DCMAKE_BUILD_TYPE="$build_type" \ - .. -ninja -ninja install - -if [[ "${OS}" == "Windows_NT" ]]; then - cp "CMakeFiles/event.dir/event.pdb" "$THIRDPARTY_BUILD/lib/event.pdb" -fi diff --git a/ci/build_container/build_recipes/nghttp2.sh b/ci/build_container/build_recipes/nghttp2.sh deleted file mode 100755 index dea7cd7493123..0000000000000 --- a/ci/build_container/build_recipes/nghttp2.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -set -e - -VERSION=1.34.0 -SHA256=8889399ddd38aa0405f6e84f1c050a292286089441686b8a9c5e937de4f5b61d - -curl https://github.com/nghttp2/nghttp2/releases/download/v"$VERSION"/nghttp2-"$VERSION".tar.gz -sLo nghttp2-"$VERSION".tar.gz \ - && echo "$SHA256" nghttp2-"$VERSION".tar.gz | sha256sum --check -tar xf nghttp2-"$VERSION".tar.gz -cd nghttp2-"$VERSION" - -# Allow nghttp2 to build as static lib on Windows -# TODO: remove once https://github.com/nghttp2/nghttp2/pull/1198 is merged -cat > nghttp2_cmakelists.diff << 'EOF' -diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt -index 17e422b2..e58070f5 100644 ---- a/lib/CMakeLists.txt -+++ b/lib/CMakeLists.txt -@@ -56,6 +56,7 @@ if(HAVE_CUNIT OR ENABLE_STATIC_LIB) - COMPILE_FLAGS "${WARNCFLAGS}" - VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION} - ARCHIVE_OUTPUT_NAME nghttp2 -+ ARCHIVE_OUTPUT_DIRECTORY static - ) - target_compile_definitions(nghttp2_static PUBLIC "-DNGHTTP2_STATICLIB") - if(ENABLE_STATIC_LIB) -EOF - -if [[ "${OS}" == "Windows_NT" ]]; then - git apply nghttp2_cmakelists.diff -fi - -mkdir build -cd build - -cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX="$THIRDPARTY_BUILD" \ - -DCMAKE_INSTALL_LIBDIR="$THIRDPARTY_BUILD/lib" \ - -DENABLE_STATIC_LIB=on \ - -DENABLE_LIB_ONLY=on \ - .. -ninja -ninja install - -if [[ "${OS}" == "Windows_NT" ]]; then - cp "lib/CMakeFiles/nghttp2_static.dir/nghttp2_static.pdb" "$THIRDPARTY_BUILD/lib/nghttp2_static.pdb" -fi diff --git a/ci/build_container/build_recipes/yaml-cpp.sh b/ci/build_container/build_recipes/yaml-cpp.sh deleted file mode 100755 index 59253e93798ff..0000000000000 --- a/ci/build_container/build_recipes/yaml-cpp.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -set -e - -# Pin to this commit to pick up fix for building on Visual Studio 15.8 -COMMIT=0f9a586ca1dc29c2ecb8dd715a315b93e3f40f79 # 2018-06-30 -SHA256=53dcffd55f3433b379fcc694f45c54898711c0e29159a7bd02e82a3e0253bac3 - -curl https://github.com/jbeder/yaml-cpp/archive/"$COMMIT".tar.gz -sLo yaml-cpp-"$COMMIT".tar.gz \ - && echo "$SHA256" yaml-cpp-"$COMMIT".tar.gz | sha256sum --check -tar xf yaml-cpp-"$COMMIT".tar.gz -cd yaml-cpp-"$COMMIT" - -mkdir build -cd build - -build_type=RelWithDebInfo -if [[ "${OS}" == "Windows_NT" ]]; then - # On Windows, every object file in the final executable needs to be compiled to use the - # same version of the C Runtime Library. If Envoy is built with '-c dbg', then it will - # use the Debug C Runtime Library. Setting CMAKE_BUILD_TYPE to Debug will cause yaml-cpp - # to use the debug version as well - # TODO: when '-c fastbuild' and '-c opt' work for Windows builds, set this appropriately - build_type=Debug -fi - -cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="$THIRDPARTY_BUILD" \ - -DCMAKE_CXX_FLAGS:STRING="${CXXFLAGS} ${CPPFLAGS}" \ - -DCMAKE_C_FLAGS:STRING="${CFLAGS} ${CPPFLAGS}" \ - -DYAML_CPP_BUILD_TESTS=off \ - -DCMAKE_BUILD_TYPE="$build_type" \ - .. -ninja install - -if [[ "${OS}" == "Windows_NT" ]]; then - cp "CMakeFiles/yaml-cpp.dir/yaml-cpp.pdb" "$THIRDPARTY_BUILD/lib/yaml-cpp.pdb" -fi diff --git a/ci/build_container/build_recipes/zlib.sh b/ci/build_container/build_recipes/zlib.sh deleted file mode 100644 index c29aeee7dea81..0000000000000 --- a/ci/build_container/build_recipes/zlib.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -set -e - -VERSION=1.2.11 -SHA256=629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff - -curl https://github.com/madler/zlib/archive/v"$VERSION".tar.gz -sLo zlib-"$VERSION".tar.gz \ - && echo "$SHA256" zlib-"$VERSION".tar.gz | sha256sum --check -tar xf zlib-"$VERSION".tar.gz -cd zlib-"$VERSION" - -mkdir build -cd build - -cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="$THIRDPARTY_BUILD" .. -ninja -ninja install - -if [[ "${OS}" == "Windows_NT" ]]; then - cp "CMakeFiles/zlibstatic.dir/zlibstatic.pdb" "$THIRDPARTY_BUILD/lib/zlibstatic.pdb" -fi diff --git a/ci/prebuilt/BUILD b/ci/prebuilt/BUILD index 8997736ea30ae..94dee2344f391 100644 --- a/ci/prebuilt/BUILD +++ b/ci/prebuilt/BUILD @@ -7,36 +7,6 @@ config_setting( values = {"cpu": "x64_windows"}, ) -cc_library( - name = "ares", - srcs = select({ - ":windows_x86_64": ["thirdparty_build/lib/cares.lib"], - "//conditions:default": ["thirdparty_build/lib/libcares.a"], - }), - hdrs = glob(["thirdparty_build/include/ares*.h"]), - includes = ["thirdparty_build/include"], -) - -cc_library( - name = "benchmark", - srcs = select({ - ":windows_x86_64": ["thirdparty_build/lib/benchmark.lib"], - "//conditions:default": ["thirdparty_build/lib/libbenchmark.a"], - }), - hdrs = ["thirdparty_build/include/testing/base/public/benchmark.h"], - includes = ["thirdparty_build/include"], -) - -cc_library( - name = "event", - srcs = select({ - ":windows_x86_64": ["thirdparty_build/lib/event.lib"], - "//conditions:default": ["thirdparty_build/lib/libevent.a"], - }), - hdrs = glob(["thirdparty_build/include/event2/**/*.h"]), - includes = ["thirdparty_build/include"], -) - cc_library( name = "luajit", srcs = select({ @@ -49,42 +19,9 @@ cc_library( # the headers get included using -I vs. -isystem which then causes old-style-cast warnings. ) -cc_library( - name = "nghttp2", - srcs = select({ - ":windows_x86_64": ["thirdparty_build/lib/nghttp2.lib"], - "//conditions:default": ["thirdparty_build/lib/libnghttp2.a"], - }), - hdrs = glob(["thirdparty_build/include/nghttp2/**/*.h"]), - includes = ["thirdparty_build/include"], -) - cc_library( name = "tcmalloc_and_profiler", srcs = ["thirdparty_build/lib/libtcmalloc_and_profiler.a"], hdrs = glob(["thirdparty_build/include/gperftools/**/*.h"]), strip_include_prefix = "thirdparty_build/include", ) - -cc_library( - name = "yaml_cpp", - srcs = select({ - ":windows_x86_64": glob(["thirdparty_build/lib/libyaml-cpp*.lib"]), - "//conditions:default": ["thirdparty_build/lib/libyaml-cpp.a"], - }), - hdrs = glob(["thirdparty_build/include/yaml-cpp/**/*.h"]), - includes = ["thirdparty_build/include"], -) - -cc_library( - name = "zlib", - srcs = select({ - ":windows_x86_64": glob(["thirdparty_build/lib/zlibstaticd.lib"]), - "//conditions:default": ["thirdparty_build/lib/libz.a"], - }), - hdrs = [ - "thirdparty_build/include/zconf.h", - "thirdparty_build/include/zlib.h", - ], - includes = ["thirdparty_build/include"], -) diff --git a/test/common/access_log/access_log_formatter_speed_test.cc b/test/common/access_log/access_log_formatter_speed_test.cc index 32c8f53f90dc4..595f6e1f5c87c 100644 --- a/test/common/access_log/access_log_formatter_speed_test.cc +++ b/test/common/access_log/access_log_formatter_speed_test.cc @@ -4,7 +4,7 @@ #include "test/common/stream_info/test_util.h" #include "test/mocks/http/mocks.h" -#include "testing/base/public/benchmark.h" +#include "benchmark/benchmark.h" namespace { diff --git a/test/common/common/utility_speed_test.cc b/test/common/common/utility_speed_test.cc index 54a2bc5354b9b..878e8c1d9473e 100644 --- a/test/common/common/utility_speed_test.cc +++ b/test/common/common/utility_speed_test.cc @@ -7,7 +7,7 @@ #include "common/common/utility.h" #include "absl/strings/string_view.h" -#include "testing/base/public/benchmark.h" +#include "benchmark/benchmark.h" static const char TextToTrim[] = "\t the quick brown fox jumps over the lazy dog\n\r\n"; static size_t TextToTrimLength = sizeof(TextToTrim) - 1; diff --git a/test/common/http/codes_speed_test.cc b/test/common/http/codes_speed_test.cc index 10ec27b230971..625a9289b7372 100644 --- a/test/common/http/codes_speed_test.cc +++ b/test/common/http/codes_speed_test.cc @@ -12,7 +12,7 @@ #include "common/http/codes.h" #include "common/stats/isolated_store_impl.h" -#include "testing/base/public/benchmark.h" +#include "benchmark/benchmark.h" namespace Envoy { namespace Http { diff --git a/test/common/network/lc_trie_speed_test.cc b/test/common/network/lc_trie_speed_test.cc index 95136c37a709e..632754af8cdee 100644 --- a/test/common/network/lc_trie_speed_test.cc +++ b/test/common/network/lc_trie_speed_test.cc @@ -1,7 +1,7 @@ #include "common/network/lc_trie.h" #include "common/network/utility.h" -#include "testing/base/public/benchmark.h" +#include "benchmark/benchmark.h" namespace { diff --git a/test/common/stats/thread_local_store_speed_test.cc b/test/common/stats/thread_local_store_speed_test.cc index 86ab8f30fa580..8a77d039bfb9c 100644 --- a/test/common/stats/thread_local_store_speed_test.cc +++ b/test/common/stats/thread_local_store_speed_test.cc @@ -13,7 +13,7 @@ #include "test/common/stats/stat_test_utility.h" #include "test/test_common/simulated_time_system.h" -#include "testing/base/public/benchmark.h" +#include "benchmark/benchmark.h" namespace Envoy { diff --git a/test/common/upstream/load_balancer_benchmark.cc b/test/common/upstream/load_balancer_benchmark.cc index 723f0b4d84469..46e7fae7a4f6f 100644 --- a/test/common/upstream/load_balancer_benchmark.cc +++ b/test/common/upstream/load_balancer_benchmark.cc @@ -10,7 +10,7 @@ #include "test/common/upstream/utility.h" #include "test/mocks/upstream/mocks.h" -#include "testing/base/public/benchmark.h" +#include "benchmark/benchmark.h" namespace Envoy { namespace Upstream { diff --git a/test/extensions/filters/listener/tls_inspector/tls_inspector_benchmark.cc b/test/extensions/filters/listener/tls_inspector/tls_inspector_benchmark.cc index db5b91c7f2c80..46fb617534123 100644 --- a/test/extensions/filters/listener/tls_inspector/tls_inspector_benchmark.cc +++ b/test/extensions/filters/listener/tls_inspector/tls_inspector_benchmark.cc @@ -10,9 +10,9 @@ #include "test/test_common/threadsafe_singleton_injector.h" #include "test/test_common/tls_utility.h" +#include "benchmark/benchmark.h" #include "gtest/gtest.h" #include "openssl/ssl.h" -#include "testing/base/public/benchmark.h" using testing::_; using testing::AtLeast; diff --git a/test/run_envoy_bazel_coverage.sh b/test/run_envoy_bazel_coverage.sh index 73098b8b89d30..2b4dd3bac5d89 100755 --- a/test/run_envoy_bazel_coverage.sh +++ b/test/run_envoy_bazel_coverage.sh @@ -35,6 +35,7 @@ BAZEL_TEST_OPTIONS="${BAZEL_TEST_OPTIONS} -c dbg --copt=-DNDEBUG" # a single coverage test binary and do not require the "bazel coverage" support # for collecting multiple traces and glueing them together. "${BAZEL_COVERAGE}" --batch test "${COVERAGE_TARGET}" ${BAZEL_TEST_OPTIONS} \ + --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs \ --cache_test_results=no --cxxopt="--coverage" --cxxopt="-DENVOY_CONFIG_COVERAGE=1" \ --linkopt="--coverage" --define ENVOY_CONFIG_COVERAGE=1 --test_output=streamed \ --strategy=Genrule=standalone --spawn_strategy=standalone --test_timeout=1000 \ diff --git a/tools/bazel.rc b/tools/bazel.rc index cd54e667b1c0f..ab4fb60c9315b 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -1,6 +1,7 @@ # Envoy specific Bazel build/test options. build --workspace_status_command=bazel/get_workspace_status +build --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs # Basic ASAN/UBSAN that works for gcc build:asan --define ENVOY_CONFIG_ASAN=1 From 1c88f277dca321ce1e4cae45a05b9d4652373cb1 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Tue, 18 Dec 2018 01:14:53 -0500 Subject: [PATCH 2/9] Add @foreign_cc_impl and pin to SHA. Signed-off-by: Harvey Tuch --- bazel/repositories.bzl | 7 +------ bazel/repository_locations.bzl | 5 +++++ tools/bazel.rc | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 23b618cb75b6b..94da2d896829e 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -663,12 +663,7 @@ def _com_github_google_jwt_verify(): ) def _foreign_cc_dependencies(): - http_archive( - name = "rules_foreign_cc", - strip_prefix = "rules_foreign_cc-master", - # TODO(htuch): Pin to SHA or release. - url = "https://github.com/bazelbuild/rules_foreign_cc/archive/master.zip", - ) + _repository_impl("rules_foreign_cc") def _apply_dep_blacklist(ctxt, recipes): newlist = [] diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index 1204f6de79903..23ce60fbb81ef 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -210,6 +210,11 @@ REPOSITORY_LOCATIONS = dict( sha256 = "ee5fe78fe417c685ecb77a0a725dc9f6040ae5beb44a0ba4ddb55453aad23a8a", urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.16.0/rules_go-0.16.0.tar.gz"], ), + rules_foreign_cc = dict( + sha256 = "e7f1a286479ed6499eb2e68a063f9d0aadcca0de7d6d710a10b8a3c3042f9c5a", + strip_prefix = "rules_foreign_cc-8ec19f39590871a4176be7edf76acecad9acd7be", + urls = ["https://github.com/bazelbuild/rules_foreign_cc/archive/8ec19f39590871a4176be7edf76acecad9acd7be.tar.gz"], + ), six_archive = dict( sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", urls = ["https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55"], diff --git a/tools/bazel.rc b/tools/bazel.rc index aaf23f9de3d46..8f2ac19da2c40 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -1,7 +1,7 @@ # Envoy specific Bazel build/test options. build --workspace_status_command=bazel/get_workspace_status -build --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs +build --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs,@foreign_cc_impl # Basic ASAN/UBSAN that works for gcc build:asan --define ENVOY_CONFIG_ASAN=1 From 35545270f5bfab26255c82fd140db3020f6e3683 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Tue, 18 Dec 2018 01:24:58 -0500 Subject: [PATCH 3/9] fix_format Signed-off-by: Harvey Tuch --- WORKSPACE | 2 ++ ci/WORKSPACE | 2 ++ 2 files changed, 4 insertions(+) diff --git a/WORKSPACE b/WORKSPACE index 23d0e01c59ced..ecd0a358f1639 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -4,7 +4,9 @@ load("//bazel:repositories.bzl", "GO_VERSION", "envoy_dependencies") load("//bazel:cc_configure.bzl", "cc_configure") envoy_dependencies() + load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies") + rules_foreign_cc_dependencies() cc_configure() diff --git a/ci/WORKSPACE b/ci/WORKSPACE index 20fd11eabf415..2f2197641d11f 100644 --- a/ci/WORKSPACE +++ b/ci/WORKSPACE @@ -12,8 +12,10 @@ local_repository( envoy_dependencies( path = "@envoy//ci/prebuilt", ) + # TODO(htuch): Roll this into envoy_dependencies() load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies") + rules_foreign_cc_dependencies() cc_configure() From 4d2adea787fe9eb339a904d81006b8624d4fb32e Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Mon, 28 Jan 2019 16:55:14 -0500 Subject: [PATCH 4/9] Bump rules_foreign_cc. Signed-off-by: Harvey Tuch --- bazel/repository_locations.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index 95891f400aba4..99a2c1c6c251b 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -219,9 +219,9 @@ REPOSITORY_LOCATIONS = dict( urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.16.5/rules_go-0.16.5.tar.gz"], ), rules_foreign_cc = dict( - sha256 = "e7f1a286479ed6499eb2e68a063f9d0aadcca0de7d6d710a10b8a3c3042f9c5a", - strip_prefix = "rules_foreign_cc-8ec19f39590871a4176be7edf76acecad9acd7be", - urls = ["https://github.com/bazelbuild/rules_foreign_cc/archive/8ec19f39590871a4176be7edf76acecad9acd7be.tar.gz"], + sha256 = "78cbd1a8134b2f0ead8e637228d8ac1ac7c0ab3f0fbcd149a85e55330697d9a3", + strip_prefix = "rules_foreign_cc-216ded8acb95d81e312b228dce3c39872c7a7c34", + urls = ["https://github.com/bazelbuild/rules_foreign_cc/archive/216ded8acb95d81e312b228dce3c39872c7a7c34.tar.gz"], ), six_archive = dict( sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", From 8e7747e54c597b2befb9edd3a8dc688f35b6a49e Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Mon, 28 Jan 2019 17:35:20 -0500 Subject: [PATCH 5/9] benchmark.h fixes. Signed-off-by: Harvey Tuch --- test/common/buffer/buffer_speed_test.cc | 2 +- test/common/http/header_map_impl_speed_test.cc | 2 +- test/common/network/address_impl_speed_test.cc | 2 +- test/common/stats/symbol_table_speed_test.cc | 2 +- .../filters/network/redis_proxy/command_lookup_speed_test.cc | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/common/buffer/buffer_speed_test.cc b/test/common/buffer/buffer_speed_test.cc index cc15536366d10..e74203fc802ee 100644 --- a/test/common/buffer/buffer_speed_test.cc +++ b/test/common/buffer/buffer_speed_test.cc @@ -2,7 +2,7 @@ #include "common/common/assert.h" #include "absl/strings/string_view.h" -#include "testing/base/public/benchmark.h" +#include "benchmark/benchmark.h" namespace Envoy { diff --git a/test/common/http/header_map_impl_speed_test.cc b/test/common/http/header_map_impl_speed_test.cc index ae332f7bb897b..b8b67b2c155f2 100644 --- a/test/common/http/header_map_impl_speed_test.cc +++ b/test/common/http/header_map_impl_speed_test.cc @@ -1,6 +1,6 @@ #include "common/http/header_map_impl.h" -#include "testing/base/public/benchmark.h" +#include "benchmark/benchmark.h" namespace Envoy { namespace Http { diff --git a/test/common/network/address_impl_speed_test.cc b/test/common/network/address_impl_speed_test.cc index 48c6614d8d344..481bc9a9d9f8a 100644 --- a/test/common/network/address_impl_speed_test.cc +++ b/test/common/network/address_impl_speed_test.cc @@ -5,7 +5,7 @@ #include "common/common/fmt.h" #include "common/network/address_impl.h" -#include "testing/base/public/benchmark.h" +#include "benchmark/benchmark.h" namespace Envoy { namespace Network { diff --git a/test/common/stats/symbol_table_speed_test.cc b/test/common/stats/symbol_table_speed_test.cc index 3d310f8e4a9bb..beefeadc3e94e 100644 --- a/test/common/stats/symbol_table_speed_test.cc +++ b/test/common/stats/symbol_table_speed_test.cc @@ -10,7 +10,7 @@ #include "test/test_common/utility.h" #include "absl/synchronization/blocking_counter.h" -#include "testing/base/public/benchmark.h" +#include "benchmark/benchmark.h" static void BM_CreateRace(benchmark::State& state) { Envoy::Thread::ThreadFactory& thread_factory = Envoy::Thread::threadFactoryForTest(); diff --git a/test/extensions/filters/network/redis_proxy/command_lookup_speed_test.cc b/test/extensions/filters/network/redis_proxy/command_lookup_speed_test.cc index be3237e32398a..a84bef53253f1 100644 --- a/test/extensions/filters/network/redis_proxy/command_lookup_speed_test.cc +++ b/test/extensions/filters/network/redis_proxy/command_lookup_speed_test.cc @@ -15,7 +15,7 @@ #include "test/test_common/printers.h" #include "test/test_common/simulated_time_system.h" -#include "testing/base/public/benchmark.h" +#include "benchmark/benchmark.h" namespace Envoy { namespace Extensions { From 344ed297d7926e247b7f7b4ece3cb6ea8e55eef9 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Mon, 28 Jan 2019 17:48:07 -0500 Subject: [PATCH 6/9] Piotr feedback. Signed-off-by: Harvey Tuch --- bazel/EXTERNAL_DEPS.md | 4 ++-- bazel/foreign_cc/BUILD | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bazel/EXTERNAL_DEPS.md b/bazel/EXTERNAL_DEPS.md index f2d4cc48c3a4e..4a7b08d14cad5 100644 --- a/bazel/EXTERNAL_DEPS.md +++ b/bazel/EXTERNAL_DEPS.md @@ -17,9 +17,9 @@ build process. `external_deps` attribute. 3. `bazel test //test/...` -# Adding external dependencies to Envoy (external cmake) +# Adding external dependencies to Envoy (external CMake) -This is the preferred style of adding dependencies that use cmake for their build system. +This is the preferred style of adding dependencies that use CMake for their build system. 1. Define a the source Bazel repository in [`bazel/repositories.bzl`](repositories.bzl), in the `envoy_dependencies()` function. diff --git a/bazel/foreign_cc/BUILD b/bazel/foreign_cc/BUILD index a2529485ea137..bb56958089dfe 100644 --- a/bazel/foreign_cc/BUILD +++ b/bazel/foreign_cc/BUILD @@ -11,6 +11,7 @@ cmake_external( cache_entries = { "CARES_SHARED": "no", "CARES_STATIC": "on", + "CMAKE_BUILD_TYPE": "RelWithDebInfo", }, cmake_options = ["-GNinja"], lib_source = "@com_github_c_ares_c_ares//:all", @@ -27,6 +28,7 @@ cmake_external( cache_entries = { "EVENT__DISABLE_OPENSSL": "on", "EVENT__DISABLE_REGRESS": "on", + "CMAKE_BUILD_TYPE": "RelWithDebInfo", }, cmake_options = ["-GNinja"], lib_source = "@com_github_libevent_libevent//:all", @@ -43,6 +45,7 @@ cmake_external( cache_entries = { "ENABLE_STATIC_LIB": "on", "ENABLE_LIB_ONLY": "on", + "CMAKE_BUILD_TYPE": "RelWithDebInfo", }, cmake_options = ["-GNinja"], lib_source = "@com_github_nghttp2_nghttp2//:all", @@ -58,6 +61,7 @@ cmake_external( name = "yaml", cache_entries = { "YAML_CPP_BUILD_TESTS": "off", + "CMAKE_BUILD_TYPE": "RelWithDebInfo", }, cmake_options = ["-GNinja"], lib_source = "@com_github_jbeder_yaml_cpp//:all", @@ -71,6 +75,9 @@ cmake_external( cmake_external( name = "zlib", + cache_entries = { + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + }, cmake_options = ["-GNinja"], lib_source = "@com_github_madler_zlib//:all", make_commands = [ From 2e500bbed93ab00366b114544a8ebe73b1bfadc6 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Mon, 28 Jan 2019 18:32:47 -0500 Subject: [PATCH 7/9] Fix rules_foreign_cc complaints, bump CI image to hopefulyl get 0.22. Signed-off-by: Harvey Tuch --- .circleci/config.yml | 2 +- bazel/foreign_cc/BUILD | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d1c82334df5b9..ec51b3655ae0f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ executors: ubuntu-build: description: "A regular build executor based on ubuntu image" docker: - - image: envoyproxy/envoy-build:5c97e3a4a12bd438a66d3016873d201fd3c5e702 + - image: envoyproxy/envoy-build:111781fa2823535762e9c514db0c5c41a119b4b1 resource_class: xlarge working_directory: /source diff --git a/bazel/foreign_cc/BUILD b/bazel/foreign_cc/BUILD index bb56958089dfe..bce243108005e 100644 --- a/bazel/foreign_cc/BUILD +++ b/bazel/foreign_cc/BUILD @@ -2,7 +2,6 @@ licenses(["notice"]) # Apache 2 load("//bazel:envoy_build_system.bzl", "envoy_package") load("@rules_foreign_cc//tools/build_defs:cmake.bzl", "cmake_external") -load("@foreign_cc_platform_utils//:tools.bzl", "NINJA_COMMAND", "NINJA_DEP") envoy_package() @@ -16,11 +15,10 @@ cmake_external( cmake_options = ["-GNinja"], lib_source = "@com_github_c_ares_c_ares//:all", make_commands = [ - NINJA_COMMAND, - NINJA_COMMAND + " install", + "ninja", + "ninja install", ], static_libraries = ["libcares.a"], - tools_deps = NINJA_DEP, ) cmake_external( @@ -33,11 +31,10 @@ cmake_external( cmake_options = ["-GNinja"], lib_source = "@com_github_libevent_libevent//:all", make_commands = [ - NINJA_COMMAND, - NINJA_COMMAND + " install", + "ninja", + "ninja install", ], static_libraries = ["libevent.a"], - tools_deps = NINJA_DEP, ) cmake_external( @@ -50,11 +47,10 @@ cmake_external( cmake_options = ["-GNinja"], lib_source = "@com_github_nghttp2_nghttp2//:all", make_commands = [ - NINJA_COMMAND, - NINJA_COMMAND + " install", + "ninja", + "ninja install", ], static_libraries = ["libnghttp2.a"], - tools_deps = NINJA_DEP, ) cmake_external( @@ -66,11 +62,10 @@ cmake_external( cmake_options = ["-GNinja"], lib_source = "@com_github_jbeder_yaml_cpp//:all", make_commands = [ - NINJA_COMMAND, - NINJA_COMMAND + " install", + "ninja", + "ninja install", ], static_libraries = ["libyaml-cpp.a"], - tools_deps = NINJA_DEP, ) cmake_external( @@ -81,9 +76,8 @@ cmake_external( cmake_options = ["-GNinja"], lib_source = "@com_github_madler_zlib//:all", make_commands = [ - NINJA_COMMAND, - NINJA_COMMAND + " install", + "ninja", + "ninja install", ], static_libraries = ["libz.a"], - tools_deps = NINJA_DEP, ) From 97879c21662d837e2755074cfddb3111dc040702 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Mon, 28 Jan 2019 18:37:59 -0500 Subject: [PATCH 8/9] Remove experimental in coverage. Signed-off-by: Harvey Tuch --- test/run_envoy_bazel_coverage.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test/run_envoy_bazel_coverage.sh b/test/run_envoy_bazel_coverage.sh index e0137d29e8dc2..252266a027196 100755 --- a/test/run_envoy_bazel_coverage.sh +++ b/test/run_envoy_bazel_coverage.sh @@ -35,7 +35,6 @@ BAZEL_TEST_OPTIONS="${BAZEL_TEST_OPTIONS} -c dbg --copt=-DNDEBUG" # a single coverage test binary and do not require the "bazel coverage" support # for collecting multiple traces and glueing them together. "${BAZEL_COVERAGE}" --batch test "${COVERAGE_TARGET}" ${BAZEL_TEST_OPTIONS} \ - --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs \ --cache_test_results=no --cxxopt="--coverage" --cxxopt="-DENVOY_CONFIG_COVERAGE=1" \ --linkopt="--coverage" --define ENVOY_CONFIG_COVERAGE=1 --test_output=streamed \ --strategy=Genrule=standalone --spawn_strategy=standalone --test_timeout=2000 \ From c5aadf87474126f4a08c3599bd1c7e25d6e72a59 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Mon, 28 Jan 2019 20:20:45 -0500 Subject: [PATCH 9/9] More review feedback. Signed-off-by: Harvey Tuch --- bazel/EXTERNAL_DEPS.md | 2 +- bazel/foreign_cc/BUILD | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bazel/EXTERNAL_DEPS.md b/bazel/EXTERNAL_DEPS.md index 4a7b08d14cad5..e6d2c67545e6c 100644 --- a/bazel/EXTERNAL_DEPS.md +++ b/bazel/EXTERNAL_DEPS.md @@ -25,7 +25,7 @@ This is the preferred style of adding dependencies that use CMake for their buil `envoy_dependencies()` function. 2. Add a `cmake_external` rule to [`bazel/foreign_cc/BUILD`](bazel/foreign_cc/BUILD). This will reference the source repository in step 1. -3. Reference your new external dependency in some `envoy_cc_library` via Y in the +3. Reference your new external dependency in some `envoy_cc_library` via the name bound in step 1 `external_deps` attribute. 4. `bazel test //test/...` diff --git a/bazel/foreign_cc/BUILD b/bazel/foreign_cc/BUILD index bce243108005e..4754703329b9a 100644 --- a/bazel/foreign_cc/BUILD +++ b/bazel/foreign_cc/BUILD @@ -26,7 +26,7 @@ cmake_external( cache_entries = { "EVENT__DISABLE_OPENSSL": "on", "EVENT__DISABLE_REGRESS": "on", - "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CMAKE_BUILD_TYPE": "Release", }, cmake_options = ["-GNinja"], lib_source = "@com_github_libevent_libevent//:all",