From d7531190ad92e6f6874dc5fd151d3ba7f420070b Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 6 Mar 2019 10:00:20 +0000 Subject: [PATCH 1/3] build: fix compile database generation Signed-off-by: Lizan Zhou --- .bazelignore | 2 ++ WORKSPACE | 6 ++-- bazel/api_repositories.bzl | 35 +++++++++++++++++++++++ bazel/repositories.bzl | 58 ++++++++------------------------------ 4 files changed, 52 insertions(+), 49 deletions(-) create mode 100644 .bazelignore create mode 100644 bazel/api_repositories.bzl diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 000000000000..04680184abec --- /dev/null +++ b/.bazelignore @@ -0,0 +1,2 @@ +api +examples/grpc-bridge/script diff --git a/WORKSPACE b/WORKSPACE index ecd0a358f163..c339f3535cdd 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,5 +1,8 @@ workspace(name = "envoy") +load("//bazel:api_repositories.bzl", "envoy_api_dependencies") +envoy_api_dependencies() + load("//bazel:repositories.bzl", "GO_VERSION", "envoy_dependencies") load("//bazel:cc_configure.bzl", "cc_configure") @@ -11,9 +14,6 @@ rules_foreign_cc_dependencies() cc_configure() -load("@envoy_api//bazel:repositories.bzl", "api_dependencies") - -api_dependencies() load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies") diff --git a/bazel/api_repositories.bzl b/bazel/api_repositories.bzl new file mode 100644 index 000000000000..016fb16c8a2e --- /dev/null +++ b/bazel/api_repositories.bzl @@ -0,0 +1,35 @@ +def _default_envoy_api_impl(ctx): + ctx.file("WORKSPACE", "") + ctx.file("BUILD.bazel", "") + api_dirs = [ + "bazel", + "docs", + "envoy", + "examples", + "test", + "tools", + ] + for d in api_dirs: + ctx.symlink(ctx.path(ctx.attr.api).dirname.get_child(d), d) + +_default_envoy_api = repository_rule( + implementation = _default_envoy_api_impl, + attrs = { + "api": attr.label(default = "@envoy//api:BUILD"), + }, +) + +def envoy_api_dependencies(): + # Treat the data plane API as an external repo, this simplifies exporting the API to + # https://github.com/envoyproxy/data-plane-api. + if "envoy_api" not in native.existing_rules().keys(): + _default_envoy_api(name = "envoy_api") + + native.bind( + name = "api_httpbody_protos", + actual = "@googleapis//:api_httpbody_protos", + ) + native.bind( + name = "http_api_protos", + actual = "@googleapis//:http_api_protos", + ) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 34328b133528..13504b7de085 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -1,6 +1,6 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load(":genrule_repository.bzl", "genrule_repository") -load("//api/bazel:envoy_http_archive.bzl", "envoy_http_archive") +load("@envoy_api//bazel:envoy_http_archive.bzl", "envoy_http_archive") load(":repository_locations.bzl", "REPOSITORY_LOCATIONS") load(":target_recipes.bzl", "TARGET_RECIPES") load( @@ -9,6 +9,8 @@ load( "setup_vc_env_vars", ) load("@bazel_tools//tools/cpp:lib_cc_configure.bzl", "get_env_var") +load("@envoy_api//bazel:repositories.bzl", "api_dependencies") + # dict of {build recipe name: longform extension name,} PPC_SKIP_TARGETS = {"luajit": "envoy.filters.http.lua"} @@ -39,27 +41,6 @@ _default_envoy_build_config = repository_rule( }, ) -def _default_envoy_api_impl(ctx): - ctx.file("WORKSPACE", "") - ctx.file("BUILD.bazel", "") - api_dirs = [ - "bazel", - "docs", - "envoy", - "examples", - "test", - "tools", - ] - for d in api_dirs: - ctx.symlink(ctx.path(ctx.attr.api).dirname.get_child(d), d) - -_default_envoy_api = repository_rule( - implementation = _default_envoy_api_impl, - attrs = { - "api": attr.label(default = "@envoy//api:BUILD"), - }, -) - # Python dependencies. If these become non-trivial, we might be better off using a virtualenv to # wrap them, but for now we can treat them as first-class Bazel. def _python_deps(): @@ -95,6 +76,14 @@ def _python_deps(): name = "com_github_twitter_common_finagle_thrift", build_file = "@envoy//bazel/external:twitter_common_finagle_thrift.BUILD", ) + _repository_impl( + name = "six_archive", + build_file = "@com_google_protobuf//:six.BUILD", + ) + native.bind( + name = "six", + actual = "@six_archive//:six", + ) # Bazel native C++ dependencies. For the dependencies that doesn't provide autoconf/automake builds. def _cc_deps(): @@ -128,29 +117,6 @@ def _go_deps(skip_targets): _repository_impl("io_bazel_rules_go") _repository_impl("bazel_gazelle") -def _envoy_api_deps(): - # Treat the data plane API as an external repo, this simplifies exporting the API to - # https://github.com/envoyproxy/data-plane-api. - if "envoy_api" not in native.existing_rules().keys(): - _default_envoy_api(name = "envoy_api") - - native.bind( - name = "api_httpbody_protos", - actual = "@googleapis//:api_httpbody_protos", - ) - native.bind( - name = "http_api_protos", - actual = "@googleapis//:http_api_protos", - ) - _repository_impl( - name = "six_archive", - build_file = "@com_google_protobuf//:six.BUILD", - ) - native.bind( - name = "six", - actual = "@six_archive//:six", - ) - def envoy_dependencies(skip_targets = []): # Treat Envoy's overall build config as an external repo, so projects that # build Envoy as a subcomponent can easily override the config. @@ -208,7 +174,7 @@ def envoy_dependencies(skip_targets = []): _python_deps() _cc_deps() _go_deps(skip_targets) - _envoy_api_deps() + api_dependencies() def _boringssl(): _repository_impl("boringssl") From d539cd1ee0280bb2f69452f2fb52f82d5a9dc175 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 6 Mar 2019 10:38:43 +0000 Subject: [PATCH 2/3] fix CI Signed-off-by: Lizan Zhou --- WORKSPACE | 2 +- bazel/repositories.bzl | 1 - ci/WORKSPACE | 4 ++++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index c339f3535cdd..b66cc75c7d2e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,6 +1,7 @@ workspace(name = "envoy") load("//bazel:api_repositories.bzl", "envoy_api_dependencies") + envoy_api_dependencies() load("//bazel:repositories.bzl", "GO_VERSION", "envoy_dependencies") @@ -14,7 +15,6 @@ rules_foreign_cc_dependencies() cc_configure() - load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies") go_rules_dependencies() diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 13504b7de085..58e0e9d5004b 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -11,7 +11,6 @@ load( load("@bazel_tools//tools/cpp:lib_cc_configure.bzl", "get_env_var") load("@envoy_api//bazel:repositories.bzl", "api_dependencies") - # dict of {build recipe name: longform extension name,} PPC_SKIP_TARGETS = {"luajit": "envoy.filters.http.lua"} diff --git a/ci/WORKSPACE b/ci/WORKSPACE index 682ff00973ca..d17395b37438 100644 --- a/ci/WORKSPACE +++ b/ci/WORKSPACE @@ -1,5 +1,9 @@ workspace(name = "ci") +load("//bazel:api_repositories.bzl", "envoy_api_dependencies") + +envoy_api_dependencies() + load("//bazel:repositories.bzl", "GO_VERSION", "envoy_dependencies") load("//bazel:cc_configure.bzl", "cc_configure") From 6695e191f8d9489839b3385fd15d36d15cd1168f Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Thu, 7 Mar 2019 22:29:58 +0000 Subject: [PATCH 3/3] fix ci/WORKSPACE Signed-off-by: Lizan Zhou --- ci/WORKSPACE | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ci/WORKSPACE b/ci/WORKSPACE index d17395b37438..586385e0251c 100644 --- a/ci/WORKSPACE +++ b/ci/WORKSPACE @@ -22,10 +22,6 @@ rules_foreign_cc_dependencies() cc_configure() -load("@envoy_api//bazel:repositories.bzl", "api_dependencies") - -api_dependencies() - load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies") go_rules_dependencies()