Skip to content

Commit e3eba93

Browse files
committed
examples: Add http-filter-cc using bzlmod
Signed-off-by: Ryan Northey <[email protected]>
1 parent 2d56886 commit e3eba93

29 files changed

+1133
-0
lines changed

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.github
2+
http-filter-cc
23
node_modules
34
wasm-cc
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Verify/Filters
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_call:
8+
9+
10+
jobs:
11+
http-filter-cc:
12+
permissions:
13+
packages: read
14+
contents: read
15+
runs-on: ubuntu-24.04
16+
steps:
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
- run: |
19+
docker pull envoyproxy/envoy:dev
20+
DEV_CONTAINER_ID=$(docker inspect --format='{{.Id}}' envoyproxy/envoy:dev)
21+
echo "DEV_CONTAINER_ID=${DEV_CONTAINER_ID}" >> $GITHUB_ENV
22+
- run: |
23+
echo "build --config=rbe" > repo.bazelrc
24+
echo "build --config=ci" >> repo.bazelrc
25+
./verify.sh
26+
working-directory: http-filter-cc
27+
env:
28+
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/verify.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ jobs:
1919
uses: ./.github/workflows/_verify_examples.yml
2020
wasm:
2121
uses: ./.github/workflows/_verify_wasm.yml
22+
filters:
23+
uses: ./.github/workflows/_verify_filters.yml
24+
permissions:
25+
packages: read
26+
contents: read

http-filter-cc/.bazelrc

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#############################################################################
2+
# startup
3+
#############################################################################
4+
5+
startup --host_jvm_args=-Xmx3g
6+
7+
8+
#############################################################################
9+
# global
10+
#############################################################################
11+
12+
build --color=yes
13+
fetch --color=yes
14+
run --color=yes
15+
16+
common --enable_bzlmod
17+
common --noenable_workspace
18+
common --@envoy//bazel:enable_bzlmod=True
19+
common --registry=https://bcr.bazel.build/
20+
common --registry=https://raw.githubusercontent.com/envoyproxy/toolshed/942638ee2c00a3b1d732c4625aa8ce5da81a1f5b/bazel-registry
21+
common --registry=https://raw.githubusercontent.com/phlax/bazel-central-registry/b739c7fa56b971d695af9600b88099236dcfef76
22+
23+
# build --workspace_status_command="bash get_workspace_status"
24+
build --incompatible_strict_action_env
25+
# Global C++ standard and common warning suppressions
26+
build --cxxopt=-std=c++20 --host_cxxopt=-std=c++20
27+
build --copt=-Wno-deprecated-declarations
28+
build --define envoy_mobile_listener=enabled
29+
build --experimental_repository_downloader_retries=2
30+
build --experimental_cc_static_library
31+
build --enable_platform_specific_config
32+
build --incompatible_merge_fixed_and_default_shell_env
33+
build --jobs=HOST_CPUS*.8
34+
build --verbose_failures
35+
36+
common --@rules_python//python/config_settings:bootstrap_impl=script
37+
build --incompatible_default_to_explicit_init_py
38+
39+
# proxy-wasm-cpp-host
40+
common --@proxy-wasm-cpp-host//bazel:crypto_lib=@envoy//bazel:crypto
41+
42+
build --@googleurl//build_config:system_icu=0
43+
44+
#############################################################################
45+
# ci
46+
#############################################################################
47+
48+
common:ci --noshow_progress
49+
common:ci --noshow_loading_progress
50+
common:ci --test_output=errors
51+
52+
build:remote-ci --config=ci
53+
build:remote-ci --remote_download_minimal
54+
55+
56+
#############################################################################
57+
# compiler
58+
#############################################################################
59+
60+
# Common flags for Clang (shared between all clang variants)
61+
common:clang-common --linkopt=-fuse-ld=lld
62+
common:clang-common --@toolchains_llvm//toolchain/config:compiler-rt=false
63+
common:clang-common --@toolchains_llvm//toolchain/config:libunwind=false
64+
65+
# Clang with libc++ (default)
66+
common:clang --config=clang-common
67+
common:clang --config=libc++
68+
common:clang --host_platform=@clang_platform
69+
common:clang --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
70+
71+
# Clang installed to non-standard location (ie not /opt/llvm/)
72+
common:clang-local --config=clang-common
73+
common:clang-local --config=libc++
74+
75+
# libc++ - default for clang
76+
common:libc++ --action_env=CXXFLAGS=-stdlib=libc++
77+
common:libc++ --action_env=LDFLAGS="-stdlib=libc++ -fuse-ld=lld"
78+
common:libc++ --action_env=BAZEL_CXXOPTS=-stdlib=libc++
79+
common:libc++ --action_env=BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a
80+
common:libc++ --action_env=BAZEL_LINKOPTS=-lm:-pthread
81+
common:libc++ --define force_libcpp=enabled
82+
common:libc++ --@envoy//bazel:libc++=true
83+
84+
85+
#############################################################################
86+
# remote
87+
#############################################################################
88+
89+
build:remote --spawn_strategy=remote,sandboxed,local
90+
build:remote --strategy=Javac=remote,sandboxed,local
91+
build:remote --strategy=Closure=remote,sandboxed,local
92+
build:remote --strategy=Genrule=remote,sandboxed,local
93+
build:remote --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
94+
95+
## RBE (Engflow Envoy)
96+
97+
# this is not included in the `--config=rbe` target - set it to publish to engflow ui
98+
common:bes --bes_backend=grpcs://mordenite.cluster.engflow.com/
99+
common:bes --bes_results_url=https://mordenite.cluster.engflow.com/invocation/
100+
common:bes --bes_timeout=3600s
101+
common:bes --bes_upload_mode=fully_async
102+
common:bes --nolegacy_important_outputs
103+
104+
common:engflow-common --google_default_credentials=false
105+
common:engflow-common --credential_helper=*.engflow.com=%workspace%/engflow-bazel-credential-helper.sh
106+
common:engflow-common --grpc_keepalive_time=60s
107+
common:engflow-common --grpc_keepalive_timeout=30s
108+
common:engflow-common --remote_cache_compression
109+
110+
# this provides access to RBE+cache
111+
common:rbe --config=remote-cache
112+
common:rbe --config=remote-exec
113+
114+
# this provides access to just cache
115+
common:remote-cache --config=engflow-common
116+
common:remote-cache --remote_cache=grpcs://mordenite.cluster.engflow.com
117+
common:remote-cache --remote_timeout=3600s
118+
119+
common:remote-exec --remote_executor=grpcs://mordenite.cluster.engflow.com
120+
common:remote-exec --jobs=200
121+
common:remote-exec --define=engflow_rbe=true
122+
123+
try-import %workspace%/repo.bazelrc

http-filter-cc/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.6.2

http-filter-cc/BUILD

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_binary", "envoy_cc_library")
2+
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")
3+
load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")
4+
5+
licenses(["notice"]) # Apache 2
6+
7+
package(default_visibility = ["//visibility:public"])
8+
9+
api_proto_package()
10+
11+
envoy_cc_library(
12+
name = "http_filter_lib",
13+
srcs = ["http_filter.cc"],
14+
hdrs = ["http_filter.h"],
15+
repository = "@envoy",
16+
deps = [
17+
":pkg_cc_proto",
18+
"@envoy//source/extensions/filters/http/common:pass_through_filter_lib",
19+
],
20+
)
21+
22+
envoy_cc_library(
23+
name = "http_filter_config",
24+
srcs = ["http_filter_config.cc"],
25+
repository = "@envoy",
26+
deps = [
27+
":http_filter_lib",
28+
"@envoy//envoy/server:filter_config_interface",
29+
],
30+
)
31+
32+
envoy_cc_binary(
33+
name = "envoy",
34+
repository = "@envoy",
35+
deps = [
36+
":http_filter_config",
37+
"@envoy//source/exe:envoy_main_entry_lib",
38+
],
39+
)
40+
41+
filegroup(
42+
name = "files",
43+
srcs = glob(
44+
["**/*"],
45+
exclude = [
46+
"**/*~",
47+
"**/.*",
48+
".*/**/*",
49+
"BUILD",
50+
"README.md",
51+
"WORKSPACE",
52+
],
53+
),
54+
)
55+
56+
pkg_tar(
57+
name = "includes",
58+
srcs = [":files"],
59+
package_dir = "_include/http-filter-cc",
60+
visibility = ["//visibility:public"],
61+
)

http-filter-cc/BUILD.bazel

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_binary")
2+
load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")
3+
4+
licenses(["notice"]) # Apache 2
5+
6+
package(default_visibility = ["//visibility:public"])
7+
8+
# Custom Envoy binary with the sample filter statically linked
9+
envoy_cc_binary(
10+
name = "envoy",
11+
repository = "@envoy",
12+
deps = [
13+
"//factory:factory_lib",
14+
"@envoy//source/exe:envoy_main_entry_lib",
15+
],
16+
)
17+
18+
filegroup(
19+
name = "files",
20+
srcs = glob(
21+
["**/*"],
22+
exclude = [
23+
"**/*~",
24+
"**/.*",
25+
".*/**/*",
26+
"BUILD.bazel",
27+
"README.md",
28+
],
29+
),
30+
)
31+
32+
pkg_tar(
33+
name = "includes",
34+
srcs = [":files"],
35+
package_dir = "_include/http-filter-cc",
36+
visibility = ["//visibility:public"],
37+
)

http-filter-cc/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM envoyproxy/envoy-build:ci-cdfbb76bc18c115270127132c6f7c67000cd2e74@sha256:48a8b1bc24ed771560126642dcbba33c50c6b837722ba9c75270b858ef7ab3a6 AS builder
2+
WORKDIR /build
3+
COPY --chmod=755 . /build
4+
ARG GITHUB_TOKEN
5+
ENV GITHUB_TOKEN="${GITHUB_TOKEN:-}"
6+
RUN bazel --version \
7+
&& bazel build --config=clang //:envoy
8+
9+
10+
FROM envoyproxy/envoy:dev
11+
COPY --from=builder /build/bazel-bin/envoy /usr/local/bin/envoy
12+
COPY envoy.yaml /etc/envoy/envoy.yaml
13+
CMD ["/usr/local/bin/envoy", "-c", "/etc/envoy/envoy.yaml"]

http-filter-cc/MODULE.bazel

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
module(
2+
name = "envoy_example_http_filter_cc",
3+
version = "0.1.0-dev",
4+
)
5+
6+
bazel_dep(name = "bazel_skylib", version = "1.8.2")
7+
bazel_dep(name = "envoy", version = "1.36.4-dev")
8+
bazel_dep(name = "envoy_api", version = "1.36.4-dev")
9+
bazel_dep(name = "googleapis", version = "0.0.0-20251003-2193a2bf")
10+
bazel_dep(name = "googleurl", version = "0.0.0-221103-dd4080f.envoy")
11+
bazel_dep(name = "platforms", version = "1.0.0")
12+
bazel_dep(name = "protobuf", version = "33.4.envoy", repo_name = "com_google_protobuf")
13+
bazel_dep(name = "protoc-gen-validate", version = "1.3.0.envoy", repo_name = "com_envoyproxy_protoc_gen_validate")
14+
bazel_dep(name = "proxy-wasm-cpp-host", version = "0.0.0-260115-beb8a4e.envoy")
15+
bazel_dep(name = "re2", version = "2024-07-02.bcr.1")
16+
bazel_dep(name = "rules_go", version = "0.59.0", repo_name = "io_bazel_rules_go")
17+
bazel_dep(name = "rules_pkg", version = "1.1.0")
18+
bazel_dep(name = "rules_python", version = "1.7.0")
19+
bazel_dep(name = "toolchains_llvm", version = "1.6.0.envoy", dev_dependency = True)
20+
bazel_dep(name = "zipkin-api", version = "1.0.0.envoy")
21+
22+
git_override(
23+
module_name = "envoy",
24+
commit = "e1d1bcc84e310bc35d46bb2d78297159fc4f3e9f",
25+
remote = "https://github.com/envoyproxy/envoy",
26+
)
27+
28+
git_override(
29+
module_name = "envoy_api",
30+
commit = "e1d1bcc84e310bc35d46bb2d78297159fc4f3e9f",
31+
remote = "https://github.com/envoyproxy/envoy",
32+
strip_prefix = "api",
33+
)
34+
35+
# needed to resolve conflict grpc <> flatbuffers
36+
single_version_override(
37+
module_name = "rules_swift",
38+
version = "2.4.0",
39+
)
40+
41+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
42+
python.toolchain(
43+
is_default = True,
44+
python_version = "3.12",
45+
)
46+
use_repo(
47+
python,
48+
"python_3_12",
49+
python = "python_versions",
50+
)
51+
52+
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
53+
go_sdk.download(
54+
name = "go_sdk",
55+
version = "1.24.6",
56+
)
57+
use_repo(
58+
go_sdk,
59+
"go_toolchains",
60+
"io_bazel_rules_nogo",
61+
)
62+
register_toolchains("@go_toolchains//:all")
63+
64+
envoy_toolchains_ext = use_extension("@envoy//bazel:extensions.bzl", "envoy_toolchains_extension")
65+
use_repo(envoy_toolchains_ext, "clang_platform")

http-filter-cc/api/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")
2+
3+
licenses(["notice"]) # Apache 2
4+
5+
api_proto_package()

0 commit comments

Comments
 (0)