Skip to content

Commit 3ff2cf0

Browse files
Move proto_library from Bazel repository
Use paths.is_normalized and paths.is_absolute from bazel skylib. Upgrade skylib to latest version that has the implementation. Use copybara for the differences in STRIC_DEPS_FLAG_TEMPLATE. Implement native_bool_flag to read native flags and use them in proto_library. Those are implemented in such a way, that they can be replaced in place with starlark bool_flag targets. Implement version check for PackageSpecificationInfo. It's only available after Bazel 6.4.0. Tests will be submitted in separate PRs. PiperOrigin-RevId: 653532601
1 parent 7c5dd9e commit 3ff2cf0

File tree

6 files changed

+439
-6
lines changed

6 files changed

+439
-6
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module(
1313
# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution
1414
# Thus the highest version in their module graph is resolved.
1515
bazel_dep(name = "abseil-cpp", version = "20230802.0.bcr.1", repo_name = "com_google_absl")
16-
bazel_dep(name = "bazel_skylib", version = "1.4.1")
16+
bazel_dep(name = "bazel_skylib", version = "1.7.0")
1717
bazel_dep(name = "jsoncpp", version = "1.9.5")
1818
bazel_dep(name = "rules_cc", version = "0.0.9")
1919
bazel_dep(name = "rules_fuzzing", version = "0.5.2")

bazel/private/BUILD.bazel

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# https://developers.google.com/open-source/licenses/bsd
77

88
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
9+
load("//bazel/private:native_bool_flag.bzl", "native_bool_flag")
910

1011
licenses(["notice"])
1112

@@ -52,3 +53,26 @@ bzl_library(
5253
"//bazel/common:proto_lang_toolchain_info_bzl",
5354
],
5455
)
56+
57+
native_bool_flag(
58+
name = "experimental_proto_descriptor_sets_include_source_info",
59+
flag = "experimental_proto_descriptor_sets_include_source_info",
60+
match_value = "true",
61+
visibility = ["//visibility:public"],
62+
)
63+
64+
native_bool_flag(
65+
name = "strict_proto_deps",
66+
flag = "strict_proto_deps",
67+
match_value = "off",
68+
result = False,
69+
visibility = ["//visibility:public"],
70+
)
71+
72+
native_bool_flag(
73+
name = "strict_public_imports",
74+
flag = "strict_public_imports",
75+
match_value = "off",
76+
result = False,
77+
visibility = ["//visibility:public"],
78+
)

bazel/private/native_bool_flag.bzl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Protocol Buffers - Google's data interchange format
2+
# Copyright 2008 Google Inc. All rights reserved.
3+
#
4+
# Use of this source code is governed by a BSD-style
5+
# license that can be found in the LICENSE file or at
6+
# https://developers.google.com/open-source/licenses/bsd
7+
"""
8+
A helper rule that reads a native boolean flag.
9+
"""
10+
11+
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
12+
13+
def _impl(ctx):
14+
return [BuildSettingInfo(value = ctx.attr.value)]
15+
16+
_native_bool_flag_rule = rule(
17+
implementation = _impl,
18+
attrs = {"value": attr.bool()},
19+
)
20+
21+
def native_bool_flag(*, name, flag, match_value = "true", result = True, **kwargs):
22+
_native_bool_flag_rule(
23+
name = name,
24+
value = select({
25+
name + "_setting": result,
26+
"//conditions:default": not result,
27+
}),
28+
**kwargs
29+
)
30+
31+
native.config_setting(
32+
name = name + "_setting",
33+
values = {flag: match_value},
34+
visibility = ["//visibility:private"],
35+
)

0 commit comments

Comments
 (0)