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: fix compile database generation #6186

Closed
wants to merge 3 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
2 changes: 2 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
api
Copy link
Member

Choose a reason for hiding this comment

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

Neat; I wonder if there are other places we need this (e.g. docs).

examples/grpc-bridge/script
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
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")

Expand All @@ -11,10 +15,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()
Expand Down
35 changes: 35 additions & 0 deletions bazel/api_repositories.bzl
Original file line number Diff line number Diff line change
@@ -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",
)
57 changes: 11 additions & 46 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -9,6 +9,7 @@ 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"}
Expand Down Expand Up @@ -39,27 +40,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():
Expand Down Expand Up @@ -95,6 +75,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():
Expand Down Expand Up @@ -128,29 +116,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.
Expand Down Expand Up @@ -208,7 +173,7 @@ def envoy_dependencies(skip_targets = []):
_python_deps()
_cc_deps()
_go_deps(skip_targets)
_envoy_api_deps()
api_dependencies()

def _boringssl():
_repository_impl("boringssl")
Expand Down
8 changes: 4 additions & 4 deletions ci/WORKSPACE
Original file line number Diff line number Diff line change
@@ -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")

Expand All @@ -18,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()
Expand Down