Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: support Envoy native Bazel build. #210

Merged
merged 3 commits into from
Apr 1, 2017
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
34 changes: 0 additions & 34 deletions src/envoy/BUILD
Original file line number Diff line number Diff line change
@@ -1,34 +0,0 @@
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
#
cc_test(
name = "envoy_test",
data = [
"@envoy_git//:envoy-testdata",
],
copts = [
"-include ./external/envoy_git/test/precompiled/precompiled_test.h",
],
deps = [
"@envoy_git//:envoy-test-lib",
"//external:googletest_main",
],
args = [
#TODO: Make all test pass
"--gtest_filter=RouterTest.*",
],
linkstatic=1,
)
5 changes: 3 additions & 2 deletions src/envoy/mixer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,19 @@ cc_library(
deps = [
":string_map_proto",
"//external:mixer_client_lib",
"@envoy_git//:envoy-common",
"@envoy//source/exe:envoy_common_lib",
],
alwayslink = 1,
)

cc_binary(
name = "envoy",
linkstatic = 1,
linkopts = ["-lrt"],
visibility = [":__subpackages__"],
deps = [
":filter_lib",
"@envoy_git//:envoy-main",
"@envoy//source/exe:envoy_main_lib",
],
)

Expand Down
18 changes: 10 additions & 8 deletions src/envoy/mixer/http_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,19 @@ class MixerConfig : public HttpFilterConfigFactory {

Http::Mixer::ConfigPtr mixer_config(
new Http::Mixer::Config(config, server));
return [mixer_config](
Http::FilterChainFactoryCallbacks& callbacks) -> void {
std::shared_ptr<Http::Mixer::Instance> instance(
new Http::Mixer::Instance(mixer_config));
callbacks.addStreamDecoderFilter(Http::StreamDecoderFilterPtr(instance));
callbacks.addAccessLogHandler(Http::AccessLog::InstancePtr(instance));
};
return
[mixer_config](Http::FilterChainFactoryCallbacks& callbacks) -> void {
std::shared_ptr<Http::Mixer::Instance> instance(
new Http::Mixer::Instance(mixer_config));
callbacks.addStreamDecoderFilter(
Http::StreamDecoderFilterSharedPtr(instance));
callbacks.addAccessLogHandler(
Http::AccessLog::InstanceSharedPtr(instance));
};
}
};

static RegisterHttpFilterConfigFactory<MixerConfig> register_;

} // namespace Configuration
} // namespace server
} // namespace Server
189 changes: 9 additions & 180 deletions src/envoy/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -559,185 +559,14 @@ def envoy_repositories(bind=True):
rapidjson_repositories(bind)
nghttp2_repositories(bind)
ares_repositories(bind)

BUILD = """
load("@protobuf_git//:protobuf.bzl", "cc_proto_library")

exports_files(["source/precompiled/precompiled.h"])

package(default_visibility = ["//visibility:public"])

genrule(
name = "envoy-ratelimit-proto",
srcs = [
"source/common/ratelimit/ratelimit.proto",
],
outs = [
"source/common/generated/ratelimit.proto",
],
cmd = "cp $(SRCS) $@",
)

cc_proto_library(
name = "envoy-ratelimit-pb",
srcs = [
"source/common/generated/ratelimit.proto",
],
default_runtime = "//external:protobuf",
protoc = "//external:protoc",
include = "source",
)

genrule(
name = "envoy-test-proto",
srcs = [
"test/proto/helloworld.proto",
],
outs = [
"test/generated/helloworld.proto",
],
cmd = "cp $(SRCS) $@",
)

cc_proto_library(
name = "envoy-test-pb",
srcs = [
"test/generated/helloworld.proto",
],
default_runtime = "//external:protobuf",
protoc = "//external:protoc",
include = "test",
)

genrule(
name = "envoy-version",
srcs = glob([
".git/**",
]),
tools = [
"tools/gen_git_sha.sh",
],
outs = [
"source/common/version_generated.cc",
],
cmd = "touch $@ && $(location tools/gen_git_sha.sh) $$(dirname $(location tools/gen_git_sha.sh)) $@",
local = 1,
)

cc_library(
name = "envoy-common",
srcs = glob([
"source/**/*.cc",
"source/**/*.h",
"include/**/*.h",
], exclude=["source/exe/main.cc"]) + [
"source/common/version_generated.cc",
],
copts = [
"-I./external/envoy_git/source",
"-include ./external/envoy_git/source/precompiled/precompiled.h",
],
includes = [
"include",
],
linkopts = [
"-lpthread",
"-lanl",
"-lrt",
],
linkstatic=1,
alwayslink=1,
deps = [
":envoy-ratelimit-pb",
"//external:ares",
"//external:libssl",
"//external:nghttp2",
"//external:spdlog",
"//external:tclap",
"//external:lightstep",
"//external:event",
"//external:protobuf",
"//external:http_parser",
"//external:rapidjson",
"//external:event_pthreads",
],
)

cc_library(
name = "envoy-main",
srcs = [
"source/exe/main.cc",
],
copts = [
"-I./external/envoy_git/source",
"-include ./external/envoy_git/source/precompiled/precompiled.h",
],
deps = [
":envoy-common",
],
linkstatic=1,
)

cc_binary(
name = "envoy",
srcs = [
"source/exe/main.cc",
],
copts = [
"-I./external/envoy_git/source",
"-include ./external/envoy_git/source/precompiled/precompiled.h",
],
deps = [
":envoy-common",
],
linkstatic=1,
)

cc_library(
name = "envoy-test-lib",
srcs = glob([
"test/**/*.cc",
"test/**/*.h",
]),
copts = [
"-I./external/envoy_git/source",
"-include ./external/envoy_git/test/precompiled/precompiled_test.h",
],
includes = [
"include",
],
deps = [
":envoy-common",
":envoy-test-pb",
"//external:googletest",
],
alwayslink=1,
)

filegroup(
name = "envoy-testdata",
srcs = glob([
"generated/**/*",
"test/**/*",
]),
)

cc_test(
name = "envoy-test",
data = [
":envoy-testdata",
],
deps = [
":envoy-test-lib",
":envoy-test-pb",
"//external:googletest",
],
linkstatic=1,
)"""

native.new_git_repository(
name = "envoy_git",
# @boringssl is defined in //:repositories.bzl, but bound to libssl for
# grpc. Rebind to what envoy expects here.
native.bind(
name = "ssl",
actual = "@boringssl//:ssl",
)
native.git_repository(
name = "envoy",
remote = "https://github.com/lyft/envoy.git",
commit = "09f078b016da908ba8b861857f2a12a43933ba40", # Mar 21 2017
build_file_content = BUILD,
commit = "bf3f23ad439ee83b91015dc4d0d7cb53b14bf1bc",
)