-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add Bazel support #416
Changes from all commits
8135afc
2d0f96c
a444344
975131e
f3f7cbc
a49b28b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
/generated | ||
cscope.* | ||
BROWSE | ||
bazel-* |
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", | ||
], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
load("//:repositories.bzl", "envoy_dependencies") | ||
|
||
envoy_dependencies() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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_ | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't they pass? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.