Skip to content

Commit ff6ad5b

Browse files
authored
Merge pull request #23 from bstoll/bazel8
Add bzlmod/Bazel8 support.
2 parents 4a64bd9 + 6d1202f commit ff6ad5b

10 files changed

Lines changed: 1051 additions & 168 deletions

File tree

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.4.0
1+
8.1.1

.github/workflows/ci-cpp-build.yml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,25 @@ on:
44
push:
55
branches: [ main ]
66
pull_request:
7-
branches: [ main ]
87
schedule:
98
- cron: "0 0 * * *"
109
workflow_dispatch:
1110

1211
jobs:
1312
build:
1413
runs-on: ubuntu-latest
15-
env:
16-
BAZEL: bazelisk-linux-amd64
1714
steps:
18-
- uses: actions/checkout@v2
19-
- name: Compute hour of the day.
20-
id: hour
21-
run: echo "::set-output name=number::$(date +%H)"
22-
- name: Mount bazel cache
23-
uses: actions/cache@v2
24-
with:
25-
# See https://docs.bazel.build/versions/master/output_directories.html
26-
path: "~/.cache/bazel"
27-
# Create a new cache entry whenever Bazel files change.
28-
# See https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows
29-
key: bazel-${{ runner.os }}-build-${{ hashFiles('**/*.bzl', '**/*.bazel') }}
30-
restore-keys: |
31-
bazel-${{ runner.os }}-build-
32-
- name: Install bazelisk
33-
run: |
34-
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.17.0/$BAZEL"
35-
chmod +x $BAZEL
36-
sudo mv $BAZEL /usr/local/bin/bazel
37-
- name: Build
38-
run: bazel build //...
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
16+
with:
17+
submodules: recursive
18+
- name: Mount bazel cache
19+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
20+
with:
21+
path: "~/.cache/bazel"
22+
key: bazel-${{ runner.os }}-build-${{ hashFiles('**/*.bzl', '**/*.bazel') }}
23+
restore-keys: |
24+
bazel-${{ runner.os }}-build-
25+
- name: Build
26+
run: bazel build //...
27+
- name: Test
28+
run: bazel test //...

MODULE.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module(
2+
name = "openconfig_gnpsi",
3+
version = "0.0.0",
4+
)
5+
6+
bazel_dep(name = "grpc", version = "1.69.0", repo_name = "com_github_grpc_grpc")
7+
bazel_dep(name = "protobuf", version = "29.3", repo_name = "com_google_protobuf")
8+
bazel_dep(name = "abseil-cpp", version = "20240722.0.bcr.2", repo_name = "com_google_absl")
9+
bazel_dep(name = "glog", version = "0.7.1", repo_name = "com_github_google_glog")
10+
bazel_dep(name = "googletest", version = "1.15.2", repo_name = "com_google_googletest")

MODULE.bazel.lock

Lines changed: 894 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WORKSPACE

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
workspace(name = "com_github_openconfig_gnpsi")
16+
17+
load("//:gnpsi_deps.bzl", "gnpsi_deps")
18+
19+
gnpsi_deps()
20+
21+
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
22+
23+
switched_rules_by_language(
24+
name = "com_google_googleapis_imports",
25+
cc = True,
26+
go = True,
27+
grpc = True,
28+
)
29+
30+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
31+
32+
bazel_features_deps()
33+
34+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
35+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
36+
37+
go_rules_dependencies()
38+
39+
go_register_toolchains(version = "1.23.4")
40+
41+
gazelle_dependencies()
42+
43+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
44+
45+
protobuf_deps()
46+
47+
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
48+
49+
grpc_deps()
50+
51+
load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies")
52+
load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies")
53+
54+
# Required by grpc
55+
load("@rules_python//python:repositories.bzl", "py_repositories")
56+
57+
py_repositories()
58+
59+
apple_rules_dependencies(ignore_version_differences = False)
60+
61+
apple_support_dependencies()

WORKSPACE.bazel

Lines changed: 0 additions & 67 deletions
This file was deleted.

bazel/patches/grpc-001-fix_file_watcher_race_condition.patch

Lines changed: 0 additions & 12 deletions
This file was deleted.

compile_protos.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

gnpsi_deps.bzl

Lines changed: 69 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,67 +18,96 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1818

1919
def gnpsi_deps():
2020
"""Declare the third-party dependencies necessary to build gnpsi"""
21+
if not native.existing_rule("bazel_features"):
22+
http_archive(
23+
name = "bazel_features",
24+
sha256 = "af3d4fb1cf4f25942cb4a933b1ad93a0ea9fe9ee70c2af7f369fb72a67c266e5",
25+
strip_prefix = "bazel_features-1.21.0",
26+
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.21.0/bazel_features-v1.21.0.tar.gz",
27+
)
28+
if not native.existing_rule("bazel_gazelle"):
29+
http_archive(
30+
name = "bazel_gazelle",
31+
sha256 = "aefbf2fc7c7616c9ed73aa3d51c77100724d5b3ce66cfa16406e8c13e87c8b52",
32+
urls = [
33+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.41.0/bazel-gazelle-v0.41.0.tar.gz",
34+
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.41.0/bazel-gazelle-v0.41.0.tar.gz",
35+
],
36+
)
37+
# Needed to make glog happy.
38+
if not native.existing_rule("com_github_gflags_gflags"):
39+
http_archive(
40+
name = "com_github_gflags_gflags",
41+
url = "https://github.com/gflags/gflags/archive/v2.2.2.tar.gz",
42+
strip_prefix = "gflags-2.2.2",
43+
sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf",
44+
)
45+
if not native.existing_rule("com_github_google_glog"):
46+
http_archive(
47+
name = "com_github_google_glog",
48+
url = "https://github.com/google/glog/archive/v0.7.1.tar.gz",
49+
strip_prefix = "glog-0.7.1",
50+
sha256 = "00e4a87e87b7e7612f519a41e491f16623b12423620006f59f5688bfd8d13b08",
51+
)
2152
if not native.existing_rule("com_github_grpc_grpc"):
2253
http_archive(
2354
name = "com_github_grpc_grpc",
24-
url = "https://github.com/grpc/grpc/archive/v1.61.0.zip",
25-
strip_prefix = "grpc-1.61.0",
26-
sha256 = "ba6c53c3924a1d01c663352010e0f73736bad3d99d72108e0f2b1a6466f9be20",
27-
patch_args = ["-p1"],
28-
patches = [
29-
"@com_github_openconfig_gnpsi//:bazel/patches/grpc-001-fix_file_watcher_race_condition.patch",
30-
],
55+
url = "https://github.com/grpc/grpc/archive/refs/tags/v1.69.0.tar.gz",
56+
strip_prefix = "grpc-1.69.0",
57+
sha256 = "cd256d91781911d46a57506978b3979bfee45d5086a1b6668a3ae19c5e77f8dc",
3158
)
3259
if not native.existing_rule("com_google_absl"):
3360
http_archive(
3461
name = "com_google_absl",
35-
url = "https://github.com/abseil/abseil-cpp/archive/20230802.0.tar.gz",
36-
strip_prefix = "abseil-cpp-20230802.0",
37-
sha256 = "59d2976af9d6ecf001a81a35749a6e551a335b949d34918cfade07737b9d93c5",
62+
url = "https://github.com/abseil/abseil-cpp/archive/20240722.0.tar.gz",
63+
strip_prefix = "abseil-cpp-20240722.0",
64+
sha256 = "f50e5ac311a81382da7fa75b97310e4b9006474f9560ac46f54a9967f07d4ae3",
65+
)
66+
if not native.existing_rule("com_google_googleapis"):
67+
http_archive(
68+
name = "com_google_googleapis",
69+
sha256 = "0513f0f40af63bd05dc789cacc334ab6cec27cc89db596557cb2dfe8919463e4",
70+
strip_prefix = "googleapis-fe8ba054ad4f7eca946c2d14a63c3f07c0b586a0",
71+
urls = ["https://github.com/googleapis/googleapis/archive/fe8ba054ad4f7eca946c2d14a63c3f07c0b586a0.tar.gz"],
3872
)
3973
if not native.existing_rule("com_google_googletest"):
4074
http_archive(
4175
name = "com_google_googletest",
42-
urls = ["https://github.com/google/googletest/archive/release-1.11.0.tar.gz"],
43-
strip_prefix = "googletest-release-1.11.0",
44-
sha256 = "b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5",
76+
urls = ["https://github.com/google/googletest/archive/v1.15.2.tar.gz"],
77+
strip_prefix = "googletest-1.15.2",
78+
sha256 = "7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926",
4579
)
4680
if not native.existing_rule("com_google_protobuf"):
4781
http_archive(
4882
name = "com_google_protobuf",
49-
url = "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v25.2.zip",
50-
strip_prefix = "protobuf-25.2",
51-
sha256 = "ddd0f5271f31b549efc74eb39061e142132653d5d043071fcec265bd571e73c4",
83+
url = "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v29.3.zip",
84+
strip_prefix = "protobuf-29.3",
85+
sha256 = "85803e01f347141e16a2f770213a496f808fff9f0138c7c0e0c9dfa708b0da92",
86+
repo_mapping = {
87+
"@proto_bazel_features": "@bazel_features",
88+
},
5289
)
53-
if not native.existing_rule("com_google_googleapis"):
90+
if not native.existing_rule("bazel_skylib"):
5491
http_archive(
55-
name = "com_google_googleapis",
56-
url = "https://github.com/googleapis/googleapis/archive/f405c718d60484124808adb7fb5963974d654bb4.zip",
57-
strip_prefix = "googleapis-f405c718d60484124808adb7fb5963974d654bb4",
58-
sha256 = "406b64643eede84ce3e0821a1d01f66eaf6254e79cb9c4f53be9054551935e79",
92+
name = "bazel_skylib",
93+
urls = [
94+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
95+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
96+
],
97+
sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",
5998
)
60-
if not native.existing_rule("com_github_google_glog"):
99+
if not native.existing_rule("io_bazel_rules_go"):
61100
http_archive(
62-
name = "com_github_google_glog",
63-
url = "https://github.com/google/glog/archive/v0.6.0.tar.gz",
64-
strip_prefix = "glog-0.6.0",
65-
sha256 = "8a83bf982f37bb70825df71a9709fa90ea9f4447fb3c099e1d720a439d88bad6",
66-
)
67-
68-
# Needed to make glog happy.
69-
if not native.existing_rule("com_github_gflags_gflags"):
70-
http_archive(
71-
name = "com_github_gflags_gflags",
72-
url = "https://github.com/gflags/gflags/archive/v2.2.2.tar.gz",
73-
strip_prefix = "gflags-2.2.2",
74-
sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf",
101+
name = "io_bazel_rules_go",
102+
sha256 = "0936c9bc3c4321ee372cb8f66dd972d368cb940ed01a9ba9fd7debcf0093f09b",
103+
urls = [
104+
"https://github.com/bazelbuild/rules_go/releases/download/v0.51.0/rules_go-v0.51.0.zip",
105+
],
75106
)
76107
if not native.existing_rule("rules_proto"):
77108
http_archive(
78109
name = "rules_proto",
79-
urls = [
80-
"https://github.com/bazelbuild/rules_proto/archive/5.3.0-21.7.tar.gz",
81-
],
82-
strip_prefix = "rules_proto-5.3.0-21.7",
83-
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
110+
sha256 = "0e5c64a2599a6e26c6a03d6162242d231ecc0de219534c38cb4402171def21e8",
111+
strip_prefix = "rules_proto-7.0.2",
112+
url = "https://github.com/bazelbuild/rules_proto/releases/download/7.0.2/rules_proto-7.0.2.tar.gz",
84113
)

proto/gnpsi/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#
1515

1616
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
17+
load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
18+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
1719

1820
# gnpsi defines a gRPC-based network packet sampling interface implemented on
1921
# vendor network elements. It provides mechanisms for streaming packet

0 commit comments

Comments
 (0)