Skip to content

Commit

Permalink
size: override pgv validations with NOP functions
Browse files Browse the repository at this point in the history
This change updates pgv to a version that supports a "cc nop" language. With
that we can make the validation functions a NOP that hopefuly gets inlined.

This is the PGV change for reference: bufbuild/protoc-gen-validate#533

Size delta: -3.7 Mi

Signed-off-by: Martin Conte Mac Donell <reflejo@gmail.com>
  • Loading branch information
Reflejo committed Feb 18, 2022
1 parent dfc042a commit 8d7b2d4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ build --features=-per_object_debug_info
# Suppress deprecated declaration warnings due to extensive transitive noise from protobuf.
build --copt -Wno-deprecated-declarations

# Override PGV validation with NOP functions
build --@com_envoyproxy_protoc_gen_validate//bazel:template-flavor=nop

# Enable source map for debugging in IDEs
build:dbg --copt="-fdebug-compilation-dir" --copt="/proc/self/cwd"

Expand Down
11 changes: 11 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
workspace(name = "envoy_mobile")

# TODO[fz]: Remove once envoy updates PGV
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "bazel_gazelle",
sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
],
)

load("@envoy_mobile//bazel:envoy_mobile_repositories.bzl", "envoy_mobile_repositories")
envoy_mobile_repositories()

Expand Down
20 changes: 20 additions & 0 deletions bazel/envoy_mobile_repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@bazel_gazelle//:deps.bzl", "go_repository")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file", "http_jar")

def envoy_mobile_repositories():
Expand All @@ -8,12 +10,30 @@ def envoy_mobile_repositories():
urls = ["https://github.com/google/bazel-common/archive/413b433b91f26dbe39cdbc20f742ad6555dd1e27.zip"],
)

# Uses PGV that includes the CC NOP template to disable validation.
# TODO(fz): Remove this once PGV is updated on envoy
override_pgv()

upstream_envoy_overrides()
swift_repos()
kotlin_repos()
android_repos()
python_repos()

def override_pgv():
go_repository(
name = "com_github_lyft_protoc_gen_star",
importpath = "github.com/lyft/protoc-gen-star",
sum = "h1:xOpFu4vwmIoUeUrRuAtdCrZZymT/6AkW/bsUWA506Fo=",
version = "v0.6.0",
)

git_repository(
name = "com_envoyproxy_protoc_gen_validate",
commit = "79071f0f8b04188b297a0517a6e55b2d3641ab5a",
remote = "https://github.com/envoyproxy/protoc-gen-validate"
)

def upstream_envoy_overrides():
# Workaround due to a Detekt version compatibility with protobuf: https://github.com/envoyproxy/envoy-mobile/issues/1869
http_archive(
Expand Down

0 comments on commit 8d7b2d4

Please sign in to comment.