Skip to content

Commit

Permalink
build: use rules_cc and use buildifier -lint to enforce it (envoyprox…
Browse files Browse the repository at this point in the history
…y#11399)

Commit Message:
Partially address envoyproxy#9488. Resurrected envoyproxy#10597.

Additional Description:
Risk Level: Low
Testing: CI
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Lizan Zhou <[email protected]>
  • Loading branch information
lizan authored Jun 3, 2020
1 parent 35702fe commit 67649af
Show file tree
Hide file tree
Showing 506 changed files with 1,260 additions and 1,173 deletions.
4 changes: 2 additions & 2 deletions api/bazel/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
licenses(["notice"]) # Apache 2

load("@io_bazel_rules_go//proto:compiler.bzl", "go_proto_compiler")

licenses(["notice"]) # Apache 2

go_proto_compiler(
name = "pgv_plugin_go",
options = ["lang=go"],
Expand Down
5 changes: 3 additions & 2 deletions api/bazel/api_build_system.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
load("@com_envoyproxy_protoc_gen_validate//bazel:pgv_proto_library.bzl", "pgv_cc_proto_library")
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("@com_google_protobuf//:protobuf.bzl", _py_proto_library = "py_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_grpc_library", "go_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_test")
load("@rules_proto//proto:defs.bzl", "proto_library")
load(
Expand Down Expand Up @@ -138,7 +139,7 @@ def api_cc_py_proto_library(
_api_cc_grpc_library(name = cc_grpc_name, proto = relative_name, deps = cc_proto_deps)

def api_cc_test(name, **kwargs):
native.cc_test(
cc_test(
name = name,
**kwargs
)
Expand Down
1 change: 0 additions & 1 deletion api/bazel/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load(":envoy_http_archive.bzl", "envoy_http_archive")
load(":repository_locations.bzl", "REPOSITORY_LOCATIONS")

Expand Down
4 changes: 2 additions & 2 deletions api/envoy/service/auth/v2alpha/BUILD
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")

licenses(["notice"]) # Apache 2

# DO NOT EDIT. This file is generated by tools/proto_sync.py.

load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")

api_proto_package(
has_services = True,
deps = ["//envoy/service/auth/v2:pkg"],
Expand Down
4 changes: 2 additions & 2 deletions api/test/build/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
licenses(["notice"]) # Apache 2

load("@envoy_api//bazel:api_build_system.bzl", "api_cc_test", "api_go_test")

licenses(["notice"]) # Apache 2

api_cc_test(
name = "build_test",
srcs = ["build_test.cc"],
Expand Down
4 changes: 2 additions & 2 deletions api/test/validate/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
licenses(["notice"]) # Apache 2

load("@envoy_api//bazel:api_build_system.bzl", "api_cc_test")

licenses(["notice"]) # Apache 2

api_cc_test(
name = "pgv_test",
srcs = ["pgv_test.cc"],
Expand Down
2 changes: 2 additions & 0 deletions api/tools/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_test")

licenses(["notice"]) # Apache 2

py_binary(
Expand Down
4 changes: 2 additions & 2 deletions api/versioning/BUILD
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# DO NOT EDIT. This file is generated by tools/proto_format/active_protos_gen.py.

licenses(["notice"]) # Apache 2

load("@rules_proto//proto:defs.bzl", "proto_library")

licenses(["notice"]) # Apache 2

# This tracks active development versions of protos.
proto_library(
name = "active_protos",
Expand Down
6 changes: 2 additions & 4 deletions bazel/BUILD
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library")
load("//bazel:envoy_build_system.bzl", "envoy_package")
load("//bazel:envoy_internal.bzl", "envoy_select_force_libcpp")

licenses(["notice"]) # Apache 2

load("//bazel:envoy_build_system.bzl", "envoy_package")

envoy_package()

load("//bazel:envoy_internal.bzl", "envoy_select_force_libcpp")

exports_files([
"gen_sh_test_runner.sh",
"sh_test_wrapper.sh",
Expand Down
4 changes: 3 additions & 1 deletion bazel/envoy_binary.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")

# DO NOT LOAD THIS FILE. Load envoy_build_system.bzl instead.
# Envoy binary targets
load(
Expand Down Expand Up @@ -27,7 +29,7 @@ def envoy_cc_binary(
linkopts = linkopts + _envoy_stamped_linkopts()
deps = deps + _envoy_stamped_deps()
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps] + envoy_stdlib_deps()
native.cc_binary(
cc_binary(
name = name,
srcs = srcs,
data = data,
Expand Down
10 changes: 5 additions & 5 deletions bazel/envoy_library.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

# DO NOT LOAD THIS FILE. Load envoy_build_system.bzl instead.
# Envoy library targets
load(
Expand All @@ -6,7 +8,6 @@ load(
"envoy_external_dep_path",
"envoy_linkstatic",
)
load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library")
load("@envoy_api//bazel:api_build_system.bzl", "api_cc_py_proto_library")

# As above, but wrapped in list form for adding to dep lists. This smell seems needed as
Expand All @@ -23,7 +24,7 @@ def tcmalloc_external_deps(repository):
# all envoy targets pass through an envoy-declared skylark function where they can be modified
# before being passed to a native bazel function.
def envoy_basic_cc_library(name, deps = [], external_deps = [], **kargs):
native.cc_library(
cc_library(
name = name,
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps],
**kargs
Expand Down Expand Up @@ -101,8 +102,7 @@ def envoy_cc_library(
"@envoy//bazel:compdb_build": ["@envoy//bazel/external:empty.cc"],
"//conditions:default": [],
})

native.cc_library(
cc_library(
name = name,
srcs = srcs,
hdrs = hdrs,
Expand Down Expand Up @@ -131,7 +131,7 @@ def envoy_cc_library(

# Intended for usage by external consumers. This allows them to disambiguate
# include paths via `external/envoy...`
native.cc_library(
cc_library(
name = name + "_with_external_headers",
hdrs = hdrs,
copts = envoy_copts(repository) + copts,
Expand Down
18 changes: 9 additions & 9 deletions bazel/envoy_test.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
load("@rules_python//python:defs.bzl", "py_binary")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")

# DO NOT LOAD THIS FILE. Load envoy_build_system.bzl instead.
# Envoy test targets. This includes both test library and test binary targets.
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
Expand Down Expand Up @@ -29,8 +32,7 @@ def _envoy_cc_test_infrastructure_library(
**kargs):
# Add implicit tcmalloc external dependency(if available) in order to enable CPU and heap profiling in tests.
deps += tcmalloc_external_deps(repository)

native.cc_library(
cc_library(
name = name,
srcs = srcs,
hdrs = hdrs,
Expand Down Expand Up @@ -105,7 +107,7 @@ def envoy_cc_fuzz_test(
tags = tags,
**kwargs
)
native.cc_test(
cc_test(
name = name,
copts = fuzz_copts + envoy_copts("@envoy", test = True),
linkopts = _envoy_test_linkopts(),
Expand All @@ -129,7 +131,7 @@ def envoy_cc_fuzz_test(
# https://github.com/google/oss-fuzz/blob/master/projects/envoy/build.sh. It won't yield
# anything useful on its own, as it expects to be run in an environment where the linker options
# provide a path to FuzzingEngine.
native.cc_binary(
cc_binary(
name = name + "_driverless",
copts = fuzz_copts + envoy_copts("@envoy", test = True),
linkopts = ["-lFuzzingEngine"] + _envoy_test_linkopts(),
Expand All @@ -138,8 +140,7 @@ def envoy_cc_fuzz_test(
deps = [":" + test_lib_name],
tags = ["manual"] + tags,
)

native.cc_test(
cc_test(
name = name + "_with_libfuzzer",
copts = fuzz_copts + envoy_copts("@envoy", test = True),
linkopts = ["-fsanitize=fuzzer"] + _envoy_test_linkopts(),
Expand Down Expand Up @@ -171,8 +172,7 @@ def envoy_cc_test(
size = "medium",
flaky = False):
coverage_tags = tags + ([] if coverage else ["nocoverage"])

native.cc_test(
cc_test(
name = name,
srcs = srcs,
data = data,
Expand Down Expand Up @@ -277,7 +277,7 @@ def envoy_py_test_binary(
external_deps = [],
deps = [],
**kargs):
native.py_binary(
py_binary(
name = name,
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps],
**kargs
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

# Use a wrapper cc_library with an empty source source file to force
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/apache_thrift.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_python//python:defs.bzl", "py_library")

licenses(["notice"]) # Apache 2

# The apache-thrift distribution does not keep the thrift files in a directory with the
Expand Down
5 changes: 3 additions & 2 deletions bazel/external/boringssl_fips.BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
licenses(["notice"]) # Apache 2

load("@rules_cc//cc:defs.bzl", "cc_library")
load(":genrule_cmd.bzl", "genrule_cmd")

licenses(["notice"]) # Apache 2

cc_library(
name = "crypto",
srcs = [
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/compiler_rt.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/fmtlib.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/http-parser.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/jinja.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_python//python:defs.bzl", "py_library")

licenses(["notice"]) # Apache 2

py_library(
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/libcircllhist.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/libprotobuf_mutator.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/markupsafe.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_python//python:defs.bzl", "py_library")

licenses(["notice"]) # Apache 2

py_library(
Expand Down
20 changes: 10 additions & 10 deletions bazel/external/quiche.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load(":genrule_cmd.bzl", "genrule_cmd")
load(
"@envoy//bazel:envoy_build_system.bzl",
"envoy_cc_library",
"envoy_cc_test",
"envoy_cc_test_library",
)

licenses(["notice"]) # Apache 2

# QUICHE is Google's implementation of QUIC and related protocols. It is the
Expand Down Expand Up @@ -25,16 +35,6 @@ licenses(["notice"]) # Apache 2
# QUICHE platform APIs in //source/extensions/quic_listeners/quiche/platform/,
# should remain largely the same.

load("@rules_proto//proto:defs.bzl", "proto_library")
load(":genrule_cmd.bzl", "genrule_cmd")
load(
"@envoy//bazel:envoy_build_system.bzl",
"envoy_cc_library",
"envoy_cc_test",
"envoy_cc_test_library",
"envoy_proto_library",
)

src_files = glob([
"**/*.h",
"**/*.c",
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/rapidjson.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/spdlog.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/sqlparser.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/tclap.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/twitter_common_finagle_thrift.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_python//python:defs.bzl", "py_library")

licenses(["notice"]) # Apache 2

py_library(
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/twitter_common_lang.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_python//python:defs.bzl", "py_library")

licenses(["notice"]) # Apache 2

py_library(
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/twitter_common_rpc.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_python//python:defs.bzl", "py_library")

licenses(["notice"]) # Apache 2

py_library(
Expand Down
5 changes: 3 additions & 2 deletions bazel/external/wee8.BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
licenses(["notice"]) # Apache 2

load("@rules_cc//cc:defs.bzl", "cc_library")
load(":genrule_cmd.bzl", "genrule_cmd")

licenses(["notice"]) # Apache 2

cc_library(
name = "wee8",
srcs = [
Expand Down
2 changes: 2 additions & 0 deletions bazel/external/xxhash.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
5 changes: 3 additions & 2 deletions bazel/foreign_cc/BUILD
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
licenses(["notice"]) # Apache 2

load("@rules_cc//cc:defs.bzl", "cc_library")
load("//bazel:envoy_build_system.bzl", "envoy_cmake_external", "envoy_package")
load("@rules_foreign_cc//tools/build_defs:configure.bzl", "configure_make")

licenses(["notice"]) # Apache 2

envoy_package()

# autotools packages are unusable on Windows as-is
Expand Down
Loading

0 comments on commit 67649af

Please sign in to comment.