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

Add Bazel support #416

Closed
wants to merge 6 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/generated
cscope.*
BROWSE
bazel-*
155 changes: 155 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
load("@protobuf//: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",
],
include = "source",
default_runtime = "@protobuf//:protobuf",
protoc = "@protobuf//:protoc",
)

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",
],
include = "test",
default_runtime = "@protobuf//:protobuf",
protoc = "@protobuf//:protoc",
)

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

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

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

cc_library(
name = "envoy-test-lib",
srcs = glob([
"test/**/*.cc",
"test/**/*.h",
]),
copts = [
"-includetest/precompiled/precompiled_test.h",
],
deps = [
":envoy-common",
":envoy-test-pb",
"@googletest//:googletest",
],
alwayslink = 1,
)

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

cc_test(
name = "envoy-test",
data = [
":envoy-testdata",
],
linkstatic = 1,
deps = [
":envoy-test-lib",
":envoy-test-pb",
"@googletest//:googletest",
],
)
3 changes: 3 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
load("//:repositories.bzl", "envoy_dependencies")

envoy_dependencies()
21 changes: 21 additions & 0 deletions docs/install/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,24 @@ available to turn on debug builds, address sanitizer, etc.).
* :repo:`CMakeLists.txt`
* :repo:`common.cmake`
* :repo:`thirdparty.cmake`

(Experimental) Building with Bazel_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you actually put this under a section heading.

Copy link
Member

@rshriram rshriram Feb 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest moving this content to the readme that @htuch has.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think it's a good idea to move this to the dev docs for now once that change gets merged.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I will move once that change merged.


Follow the instruction_ to install Bazel, then run following command to build Envoy:

.. code-block:: console

bazel build //:envoy

The built binary will be at `bazel-bin/envoy`

To run tests, run following command:

.. code-block:: console

bazel test //:envoy-test

Note not all tests pass with Bazel yet.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't they pass?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bazel test run tests in different paths than do_ci.sh does, results some fixtures cannot be found. I will do a follow up PR after this to fix them.


.. _Bazel: https://bazel.build/
.. _instruction: https://bazel.build/versions/master/docs/install.html
Loading