Skip to content

Commit

Permalink
Move proto_library from Bazel repository
Browse files Browse the repository at this point in the history
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
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Jul 18, 2024
1 parent 7c5dd9e commit 3ff2cf0
Show file tree
Hide file tree
Showing 6 changed files with 439 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module(
# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution
# Thus the highest version in their module graph is resolved.
bazel_dep(name = "abseil-cpp", version = "20230802.0.bcr.1", repo_name = "com_google_absl")
bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "bazel_skylib", version = "1.7.0")
bazel_dep(name = "jsoncpp", version = "1.9.5")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_fuzzing", version = "0.5.2")
Expand Down
24 changes: 24 additions & 0 deletions bazel/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# https://developers.google.com/open-source/licenses/bsd

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//bazel/private:native_bool_flag.bzl", "native_bool_flag")

licenses(["notice"])

Expand Down Expand Up @@ -52,3 +53,26 @@ bzl_library(
"//bazel/common:proto_lang_toolchain_info_bzl",
],
)

native_bool_flag(
name = "experimental_proto_descriptor_sets_include_source_info",
flag = "experimental_proto_descriptor_sets_include_source_info",
match_value = "true",
visibility = ["//visibility:public"],
)

native_bool_flag(
name = "strict_proto_deps",
flag = "strict_proto_deps",
match_value = "off",
result = False,
visibility = ["//visibility:public"],
)

native_bool_flag(
name = "strict_public_imports",
flag = "strict_public_imports",
match_value = "off",
result = False,
visibility = ["//visibility:public"],
)
35 changes: 35 additions & 0 deletions bazel/private/native_bool_flag.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd
"""
A helper rule that reads a native boolean flag.
"""

load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")

def _impl(ctx):
return [BuildSettingInfo(value = ctx.attr.value)]

_native_bool_flag_rule = rule(
implementation = _impl,
attrs = {"value": attr.bool()},
)

def native_bool_flag(*, name, flag, match_value = "true", result = True, **kwargs):
_native_bool_flag_rule(
name = name,
value = select({
name + "_setting": result,
"//conditions:default": not result,
}),
**kwargs
)

native.config_setting(
name = name + "_setting",
values = {flag: match_value},
visibility = ["//visibility:private"],
)
Loading

0 comments on commit 3ff2cf0

Please sign in to comment.