commit
fa26b551f0
1159 changed files with 57990 additions and 34759 deletions
@ -1,4 +1 @@ |
||||
# These are fetched as external repositories. |
||||
third_party/abseil-cpp |
||||
third_party/googletest |
||||
_build/ |
||||
|
@ -0,0 +1,25 @@ |
||||
name: Release Branch Tests |
||||
|
||||
on: |
||||
schedule: |
||||
# Run daily at 10 AM UTC (2 AM PDT) |
||||
- cron: 0 10 * * * |
||||
workflow_dispatch: |
||||
|
||||
permissions: {} |
||||
|
||||
jobs: |
||||
releases: |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
branch: [25.x, 28.x, 29.x] |
||||
runs-on: ubuntu-latest |
||||
permissions: |
||||
actions: write |
||||
env: |
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
||||
GH_REPO: ${{ github.repository }} |
||||
name: Run Tests on ${{ matrix.branch }} |
||||
steps: |
||||
- run: gh workflow run test_runner.yml --ref ${{ matrix.branch }} |
@ -1,11 +0,0 @@ |
||||
[submodule "third_party/googletest"] |
||||
path = third_party/googletest |
||||
url = https://github.com/google/googletest.git |
||||
ignore = dirty |
||||
[submodule "third_party/abseil-cpp"] |
||||
path = third_party/abseil-cpp |
||||
url = https://github.com/abseil/abseil-cpp.git |
||||
branch = lts_2023_08_02 |
||||
[submodule "third_party/jsoncpp"] |
||||
path = third_party/jsoncpp |
||||
url = https://github.com/open-source-parsers/jsoncpp.git |
@ -1,48 +0,0 @@ |
||||
Pod::Spec.new do |s| |
||||
s.name = 'Protobuf-C++' |
||||
s.version = '5.29.0' |
||||
s.summary = 'Protocol Buffers v3 runtime library for C++.' |
||||
s.homepage = 'https://github.com/google/protobuf' |
||||
s.license = 'BSD-3-Clause' |
||||
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' } |
||||
|
||||
# Ensure developers won't hit CocoaPods/CocoaPods#11402 with the resource |
||||
# bundle for the privacy manifest. |
||||
s.cocoapods_version = '>= 1.12.0' |
||||
|
||||
s.source = { :git => 'https://github.com/google/protobuf.git', |
||||
:tag => "v#{s.version}" } |
||||
|
||||
s.source_files = 'src/google/protobuf/*.{h,cc,inc}', |
||||
'src/google/protobuf/stubs/*.{h,cc}', |
||||
'src/google/protobuf/io/*.{h,cc}', |
||||
'src/google/protobuf/util/*.{h,cc}' |
||||
|
||||
# Excluding all the tests in the directories above |
||||
s.exclude_files = 'src/google/**/*_test.{h,cc,inc}', |
||||
'src/google/**/*_unittest.{h,cc}', |
||||
'src/google/protobuf/test_util*.{h,cc}', |
||||
'src/google/protobuf/map_lite_test_util.{h,cc}', |
||||
'src/google/protobuf/map_test_util*.{h,cc,inc}', |
||||
'src/google/protobuf/reflection_tester.{h,cc}' |
||||
|
||||
s.resource_bundle = { |
||||
"Protobuf-C++_Privacy" => "PrivacyInfo.xcprivacy" |
||||
} |
||||
|
||||
s.header_mappings_dir = 'src' |
||||
|
||||
s.ios.deployment_target = '12.0' |
||||
s.osx.deployment_target = '10.13' |
||||
s.tvos.deployment_target = '12.0' |
||||
s.watchos.deployment_target = '6.0' |
||||
s.visionos.deployment_target = '1.0' |
||||
|
||||
s.pod_target_xcconfig = { |
||||
# Do not let src/google/protobuf/stubs/time.h override system API |
||||
'USE_HEADERMAP' => 'NO', |
||||
'ALWAYS_SEARCH_USER_PATHS' => 'NO', |
||||
'HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)/src"' |
||||
} |
||||
|
||||
end |
@ -1,3 +1,10 @@ |
||||
"""cc_proto_library rule""" |
||||
|
||||
cc_proto_library = native.cc_proto_library |
||||
load("//bazel/private:bazel_cc_proto_library.bzl", _cc_proto_library = "cc_proto_library") # buildifier: disable=bzl-visibility |
||||
|
||||
def cc_proto_library(**kwattrs): |
||||
# Only use Starlark rules when they are removed from Bazel |
||||
if not hasattr(native, "cc_proto_library"): |
||||
_cc_proto_library(**kwattrs) |
||||
else: |
||||
native.cc_proto_library(**kwattrs) # buildifier: disable=native-cc-proto |
||||
|
@ -1,5 +1,7 @@ |
||||
"""ProtoInfo""" |
||||
|
||||
load("//bazel/private:native.bzl", "NativeProtoInfo") |
||||
load("@proto_bazel_features//:features.bzl", "bazel_features") |
||||
load("//bazel/private:proto_info.bzl", _ProtoInfo = "ProtoInfo") # buildifier: disable=bzl-visibility |
||||
|
||||
ProtoInfo = NativeProtoInfo |
||||
# This resolves to Starlark ProtoInfo in Bazel 8 or with --incompatible_enable_autoload flag |
||||
ProtoInfo = getattr(bazel_features.globals, "ProtoInfo", None) or _ProtoInfo |
||||
|
@ -1,5 +1,26 @@ |
||||
"""ProtoLangToolchainInfo""" |
||||
|
||||
load("//bazel/private:native.bzl", "native_proto_common") |
||||
load("//bazel/private:native.bzl", "native_proto_common") # buildifier: disable=bzl-visibility |
||||
|
||||
ProtoLangToolchainInfo = native_proto_common.ProtoLangToolchainInfo |
||||
# Use Starlark implementation only if native_proto_common.ProtoLangToolchainInfo doesn't exist |
||||
ProtoLangToolchainInfo = getattr(native_proto_common, "ProtoLangToolchainInfo", provider( |
||||
doc = """Specifies how to generate language-specific code from .proto files. |
||||
Used by LANG_proto_library rules.""", |
||||
fields = dict( |
||||
out_replacement_format_flag = """(str) Format string used when passing output to the plugin |
||||
used by proto compiler.""", |
||||
output_files = """("single","multiple","legacy") Format out_replacement_format_flag with |
||||
a path to single file or a directory in case of multiple files.""", |
||||
plugin_format_flag = "(str) Format string used when passing plugin to proto compiler.", |
||||
plugin = "(FilesToRunProvider) Proto compiler plugin.", |
||||
runtime = "(Target) Runtime.", |
||||
provided_proto_sources = "(list[File]) Proto sources provided by the toolchain.", |
||||
proto_compiler = "(FilesToRunProvider) Proto compiler.", |
||||
protoc_opts = "(list[str]) Options to pass to proto compiler.", |
||||
progress_message = "(str) Progress message to set on the proto compiler action.", |
||||
mnemonic = "(str) Mnemonic to set on the proto compiler action.", |
||||
allowlist_different_package = """(Target) Allowlist to create lang_proto_library in a |
||||
different package than proto_library""", |
||||
toolchain_type = """(Label) Toolchain type that was used to obtain this info""", |
||||
), |
||||
)) |
||||
|
@ -1,3 +1,16 @@ |
||||
# Copyright (c) 2009-2024, Google LLC |
||||
# 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 |
||||
"""java_lite_proto_library rule""" |
||||
|
||||
java_lite_proto_library = native.java_lite_proto_library |
||||
load("//bazel/private:java_lite_proto_library.bzl", _java_lite_proto_library = "java_lite_proto_library") # buildifier: disable=bzl-visibility |
||||
|
||||
def java_lite_proto_library(**kwattrs): |
||||
# Only use Starlark rules when they are removed from Bazel |
||||
if not hasattr(native, "java_lite_proto_library"): |
||||
_java_lite_proto_library(**kwattrs) |
||||
else: |
||||
native.java_lite_proto_library(**kwattrs) |
||||
|
@ -1,3 +1,16 @@ |
||||
# Copyright (c) 2009-2024, Google LLC |
||||
# 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 |
||||
"""java_proto_library rule""" |
||||
|
||||
java_proto_library = native.java_proto_library |
||||
load("//bazel/private:bazel_java_proto_library_rule.bzl", _java_proto_library = "java_proto_library") # buildifier: disable=bzl-visibility |
||||
|
||||
def java_proto_library(**kwattrs): |
||||
# Only use Starlark rules when they are removed from Bazel |
||||
if not hasattr(native, "java_proto_library"): |
||||
_java_proto_library(**kwattrs) |
||||
else: |
||||
native.java_proto_library(**kwattrs) |
||||
|
@ -0,0 +1,198 @@ |
||||
# Protocol Buffers - Google's data interchange format |
||||
# Copyright 2024 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 |
||||
# |
||||
"""Bazel's implementation of cc_proto_library""" |
||||
|
||||
load("@rules_cc//cc:find_cc_toolchain.bzl", "use_cc_toolchain") |
||||
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") |
||||
load("//bazel/common:proto_common.bzl", "proto_common") |
||||
load("//bazel/common:proto_info.bzl", "ProtoInfo") |
||||
load("//bazel/private:cc_proto_support.bzl", "cc_proto_compile_and_link") |
||||
load("//bazel/private:toolchain_helpers.bzl", "toolchains") |
||||
|
||||
_CC_PROTO_TOOLCHAIN = Label("//bazel/private:cc_toolchain_type") |
||||
|
||||
_ProtoCcFilesInfo = provider(fields = ["files"], doc = "Provide cc proto files.") |
||||
_ProtoCcHeaderInfo = provider(fields = ["headers"], doc = "Provide cc proto headers.") |
||||
|
||||
def _get_output_files(actions, proto_info, suffixes): |
||||
result = [] |
||||
for suffix in suffixes: |
||||
result.extend(proto_common.declare_generated_files( |
||||
actions = actions, |
||||
proto_info = proto_info, |
||||
extension = suffix, |
||||
)) |
||||
return result |
||||
|
||||
# TODO: Make this code actually work. |
||||
def _get_strip_include_prefix(ctx, proto_info): |
||||
proto_root = proto_info.proto_source_root |
||||
if proto_root == "." or proto_root == ctx.label.workspace_root: |
||||
return "" |
||||
strip_include_prefix = "" |
||||
if proto_root.startswith(ctx.bin_dir.path): |
||||
proto_root = proto_root[len(ctx.bin_dir.path) + 1:] |
||||
elif proto_root.startswith(ctx.genfiles_dir.path): |
||||
proto_root = proto_root[len(ctx.genfiles_dir.path) + 1:] |
||||
|
||||
if proto_root.startswith(ctx.label.workspace_root): |
||||
proto_root = proto_root[len(ctx.label.workspace_root):] |
||||
|
||||
strip_include_prefix = "//" + proto_root |
||||
return strip_include_prefix |
||||
|
||||
def _aspect_impl(target, ctx): |
||||
proto_info = target[ProtoInfo] |
||||
proto_configuration = ctx.fragments.proto |
||||
|
||||
sources = [] |
||||
headers = [] |
||||
textual_hdrs = [] |
||||
|
||||
proto_toolchain = toolchains.find_toolchain(ctx, "_aspect_cc_proto_toolchain", _CC_PROTO_TOOLCHAIN) |
||||
should_generate_code = proto_common.experimental_should_generate_code(proto_info, proto_toolchain, "cc_proto_library", target.label) |
||||
|
||||
if should_generate_code: |
||||
if len(proto_info.direct_sources) != 0: |
||||
# Bazel 7 didn't expose cc_proto_library_source_suffixes used by Kythe |
||||
# gradually falling back to .pb.cc |
||||
if type(proto_configuration.cc_proto_library_source_suffixes) == "builtin_function_or_method": |
||||
source_suffixes = [".pb.cc"] |
||||
header_suffixes = [".pb.h"] |
||||
else: |
||||
source_suffixes = proto_configuration.cc_proto_library_source_suffixes |
||||
header_suffixes = proto_configuration.cc_proto_library_header_suffixes |
||||
sources = _get_output_files(ctx.actions, proto_info, source_suffixes) |
||||
headers = _get_output_files(ctx.actions, proto_info, header_suffixes) |
||||
header_provider = _ProtoCcHeaderInfo(headers = depset(headers)) |
||||
else: |
||||
# If this proto_library doesn't have sources, it provides the combined headers of all its |
||||
# direct dependencies. Thus, if a direct dependency does have sources, the generated files |
||||
# are also provided by this library. If a direct dependency does not have sources, it will |
||||
# do the same thing, so that effectively this library looks through all source-less |
||||
# proto_libraries and provides all generated headers of the proto_libraries with sources |
||||
# that it depends on. |
||||
transitive_headers = [] |
||||
for dep in getattr(ctx.rule.attr, "deps", []): |
||||
if _ProtoCcHeaderInfo in dep: |
||||
textual_hdrs.extend(dep[_ProtoCcHeaderInfo].headers.to_list()) |
||||
transitive_headers.append(dep[_ProtoCcHeaderInfo].headers) |
||||
header_provider = _ProtoCcHeaderInfo(headers = depset(transitive = transitive_headers)) |
||||
|
||||
else: # shouldn't generate code |
||||
header_provider = _ProtoCcHeaderInfo(headers = depset()) |
||||
|
||||
proto_common.compile( |
||||
actions = ctx.actions, |
||||
proto_info = proto_info, |
||||
proto_lang_toolchain_info = proto_toolchain, |
||||
generated_files = sources + headers, |
||||
experimental_output_files = "multiple", |
||||
) |
||||
|
||||
deps = [] |
||||
if proto_toolchain.runtime: |
||||
deps = [proto_toolchain.runtime] |
||||
deps.extend(getattr(ctx.rule.attr, "deps", [])) |
||||
|
||||
cc_info, libraries, temps = cc_proto_compile_and_link( |
||||
ctx = ctx, |
||||
deps = deps, |
||||
sources = sources, |
||||
headers = headers, |
||||
textual_hdrs = textual_hdrs, |
||||
strip_include_prefix = _get_strip_include_prefix(ctx, proto_info), |
||||
) |
||||
|
||||
return [ |
||||
cc_info, |
||||
_ProtoCcFilesInfo(files = depset(sources + headers + libraries)), |
||||
OutputGroupInfo(temp_files_INTERNAL_ = temps), |
||||
header_provider, |
||||
] |
||||
|
||||
cc_proto_aspect = aspect( |
||||
implementation = _aspect_impl, |
||||
attr_aspects = ["deps"], |
||||
fragments = ["cpp", "proto"], |
||||
required_providers = [ProtoInfo], |
||||
provides = [CcInfo], |
||||
attrs = toolchains.if_legacy_toolchain({"_aspect_cc_proto_toolchain": attr.label( |
||||
default = configuration_field(fragment = "proto", name = "proto_toolchain_for_cc"), |
||||
)}), |
||||
toolchains = use_cc_toolchain() + toolchains.use_toolchain(_CC_PROTO_TOOLCHAIN), |
||||
) |
||||
|
||||
def _cc_proto_library_impl(ctx): |
||||
if len(ctx.attr.deps) != 1: |
||||
fail( |
||||
"'deps' attribute must contain exactly one label " + |
||||
"(we didn't name it 'dep' for consistency). " + |
||||
"The main use-case for multiple deps is to create a rule that contains several " + |
||||
"other targets. This makes dependency bloat more likely. It also makes it harder" + |
||||
"to remove unused deps.", |
||||
attr = "deps", |
||||
) |
||||
dep = ctx.attr.deps[0] |
||||
|
||||
proto_toolchain = toolchains.find_toolchain(ctx, "_aspect_cc_proto_toolchain", _CC_PROTO_TOOLCHAIN) |
||||
proto_common.check_collocated(ctx.label, dep[ProtoInfo], proto_toolchain) |
||||
|
||||
return [DefaultInfo(files = dep[_ProtoCcFilesInfo].files), dep[CcInfo], dep[OutputGroupInfo]] |
||||
|
||||
cc_proto_library = rule( |
||||
implementation = _cc_proto_library_impl, |
||||
doc = """ |
||||
<p> |
||||
<code>cc_proto_library</code> generates C++ code from <code>.proto</code> files. |
||||
</p> |
||||
|
||||
<p> |
||||
<code>deps</code> must point to <a href="protocol-buffer.html#proto_library"><code>proto_library |
||||
</code></a> rules. |
||||
</p> |
||||
|
||||
<p> |
||||
Example: |
||||
</p> |
||||
|
||||
<pre> |
||||
<code class="lang-starlark"> |
||||
cc_library( |
||||
name = "lib", |
||||
deps = [":foo_cc_proto"], |
||||
) |
||||
|
||||
cc_proto_library( |
||||
name = "foo_cc_proto", |
||||
deps = [":foo_proto"], |
||||
) |
||||
|
||||
proto_library( |
||||
name = "foo_proto", |
||||
) |
||||
</code> |
||||
</pre> |
||||
""", |
||||
attrs = { |
||||
"deps": attr.label_list( |
||||
aspects = [cc_proto_aspect], |
||||
allow_rules = ["proto_library"], |
||||
allow_files = False, |
||||
doc = """ |
||||
The list of <a href="protocol-buffer.html#proto_library"><code>proto_library</code></a> |
||||
rules to generate C++ code for.""", |
||||
), |
||||
} | toolchains.if_legacy_toolchain({ |
||||
"_aspect_cc_proto_toolchain": attr.label( |
||||
default = configuration_field(fragment = "proto", name = "proto_toolchain_for_cc"), |
||||
), |
||||
}), |
||||
provides = [CcInfo], |
||||
toolchains = toolchains.use_toolchain(_CC_PROTO_TOOLCHAIN), |
||||
) |
@ -0,0 +1,164 @@ |
||||
# Copyright (c) 2009-2024, Google LLC |
||||
# 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 |
||||
"""The implementation of the `java_proto_library` rule and its aspect.""" |
||||
|
||||
load("@rules_java//java/common:java_info.bzl", "JavaInfo") |
||||
load("//bazel/common:proto_common.bzl", "proto_common") |
||||
load("//bazel/common:proto_info.bzl", "ProtoInfo") |
||||
load("//bazel/private:java_proto_support.bzl", "JavaProtoAspectInfo", "java_compile_for_protos", "java_info_merge_for_protos") |
||||
load("//bazel/private:toolchain_helpers.bzl", "toolchains") |
||||
|
||||
_JAVA_PROTO_TOOLCHAIN = Label("//bazel/private:java_toolchain_type") |
||||
|
||||
def _filter_provider(provider, *attrs): |
||||
return [dep[provider] for attr in attrs for dep in attr if provider in dep] |
||||
|
||||
def _bazel_java_proto_aspect_impl(target, ctx): |
||||
"""Generates and compiles Java code for a proto_library. |
||||
|
||||
The function runs protobuf compiler on the `proto_library` target using |
||||
`proto_lang_toolchain` specified by `--proto_toolchain_for_java` flag. |
||||
This generates a source jar. |
||||
|
||||
After that the source jar is compiled, respecting `deps` and `exports` of |
||||
the `proto_library`. |
||||
|
||||
Args: |
||||
target: (Target) The `proto_library` target (any target providing `ProtoInfo`. |
||||
ctx: (RuleContext) The rule context. |
||||
|
||||
Returns: |
||||
([JavaInfo, JavaProtoAspectInfo]) A JavaInfo describing compiled Java |
||||
version of`proto_library` and `JavaProtoAspectInfo` with all source and |
||||
runtime jars. |
||||
""" |
||||
|
||||
proto_toolchain_info = toolchains.find_toolchain(ctx, "_aspect_java_proto_toolchain", _JAVA_PROTO_TOOLCHAIN) |
||||
source_jar = None |
||||
if proto_common.experimental_should_generate_code(target[ProtoInfo], proto_toolchain_info, "java_proto_library", target.label): |
||||
# Generate source jar using proto compiler. |
||||
source_jar = ctx.actions.declare_file(ctx.label.name + "-speed-src.jar") |
||||
proto_common.compile( |
||||
ctx.actions, |
||||
target[ProtoInfo], |
||||
proto_toolchain_info, |
||||
[source_jar], |
||||
experimental_output_files = "single", |
||||
) |
||||
|
||||
# Compile Java sources (or just merge if there aren't any) |
||||
deps = _filter_provider(JavaInfo, ctx.rule.attr.deps) |
||||
exports = _filter_provider(JavaInfo, ctx.rule.attr.exports) |
||||
if source_jar and proto_toolchain_info.runtime: |
||||
deps.append(proto_toolchain_info.runtime[JavaInfo]) |
||||
java_info, jars = java_compile_for_protos( |
||||
ctx, |
||||
"-speed.jar", |
||||
source_jar, |
||||
deps, |
||||
exports, |
||||
) |
||||
|
||||
transitive_jars = [dep[JavaProtoAspectInfo].jars for dep in ctx.rule.attr.deps if JavaProtoAspectInfo in dep] |
||||
return [ |
||||
java_info, |
||||
JavaProtoAspectInfo(jars = depset(jars, transitive = transitive_jars)), |
||||
] |
||||
|
||||
bazel_java_proto_aspect = aspect( |
||||
implementation = _bazel_java_proto_aspect_impl, |
||||
attrs = toolchains.if_legacy_toolchain({ |
||||
"_aspect_java_proto_toolchain": attr.label( |
||||
default = configuration_field(fragment = "proto", name = "proto_toolchain_for_java"), |
||||
), |
||||
}), |
||||
toolchains = ["@bazel_tools//tools/jdk:toolchain_type"] + toolchains.use_toolchain(_JAVA_PROTO_TOOLCHAIN), |
||||
attr_aspects = ["deps", "exports"], |
||||
required_providers = [ProtoInfo], |
||||
provides = [JavaInfo, JavaProtoAspectInfo], |
||||
fragments = ["java"], |
||||
) |
||||
|
||||
def bazel_java_proto_library_rule(ctx): |
||||
"""Merges results of `java_proto_aspect` in `deps`. |
||||
|
||||
Args: |
||||
ctx: (RuleContext) The rule context. |
||||
Returns: |
||||
([JavaInfo, DefaultInfo, OutputGroupInfo]) |
||||
""" |
||||
proto_toolchain = toolchains.find_toolchain(ctx, "_aspect_java_proto_toolchain", _JAVA_PROTO_TOOLCHAIN) |
||||
for dep in ctx.attr.deps: |
||||
proto_common.check_collocated(ctx.label, dep[ProtoInfo], proto_toolchain) |
||||
|
||||
java_info = java_info_merge_for_protos([dep[JavaInfo] for dep in ctx.attr.deps], merge_java_outputs = False) |
||||
|
||||
transitive_src_and_runtime_jars = depset(transitive = [dep[JavaProtoAspectInfo].jars for dep in ctx.attr.deps]) |
||||
transitive_runtime_jars = depset(transitive = [java_info.transitive_runtime_jars]) |
||||
|
||||
return [ |
||||
java_info, |
||||
DefaultInfo( |
||||
files = transitive_src_and_runtime_jars, |
||||
runfiles = ctx.runfiles(transitive_files = transitive_runtime_jars), |
||||
), |
||||
OutputGroupInfo(default = depset()), |
||||
] |
||||
|
||||
java_proto_library = rule( |
||||
implementation = bazel_java_proto_library_rule, |
||||
doc = """ |
||||
<p> |
||||
<code>java_proto_library</code> generates Java code from <code>.proto</code> files. |
||||
</p> |
||||
|
||||
<p> |
||||
<code>deps</code> must point to <a href="protocol-buffer.html#proto_library"><code>proto_library |
||||
</code></a> rules. |
||||
</p> |
||||
|
||||
<p> |
||||
Example: |
||||
</p> |
||||
|
||||
<pre class="code"> |
||||
<code class="lang-starlark"> |
||||
java_library( |
||||
name = "lib", |
||||
runtime_deps = [":foo_java_proto"], |
||||
) |
||||
|
||||
java_proto_library( |
||||
name = "foo_java_proto", |
||||
deps = [":foo_proto"], |
||||
) |
||||
|
||||
proto_library( |
||||
name = "foo_proto", |
||||
) |
||||
</code> |
||||
</pre> |
||||
""", |
||||
attrs = { |
||||
"deps": attr.label_list( |
||||
providers = [ProtoInfo], |
||||
aspects = [bazel_java_proto_aspect], |
||||
doc = """ |
||||
The list of <a href="protocol-buffer.html#proto_library"><code>proto_library</code></a> |
||||
rules to generate Java code for. |
||||
""", |
||||
), |
||||
# buildifier: disable=attr-license (calling attr.license()) |
||||
"licenses": attr.license() if hasattr(attr, "license") else attr.string_list(), |
||||
} | toolchains.if_legacy_toolchain({ |
||||
"_aspect_java_proto_toolchain": attr.label( |
||||
default = configuration_field(fragment = "proto", name = "proto_toolchain_for_java"), |
||||
), |
||||
}), # buildifier: disable=attr-licenses (attribute called licenses) |
||||
provides = [JavaInfo], |
||||
toolchains = toolchains.use_toolchain(_JAVA_PROTO_TOOLCHAIN), |
||||
) |
@ -0,0 +1,6 @@ |
||||
"""Exposes cc_proto_aspect to rules_rust""" |
||||
|
||||
load("//bazel/private:bazel_cc_proto_library.bzl", _cc_proto_aspect = "cc_proto_aspect") # buildifier: disable=bzl-visibility |
||||
load("//bazel/private:native.bzl", _native_cc_proto_aspect = "native_cc_proto_aspect") # buildifier: disable=bzl-visibility |
||||
|
||||
cc_proto_aspect = _cc_proto_aspect if not hasattr(native, "cc_proto_library") else _native_cc_proto_aspect |
@ -0,0 +1,143 @@ |
||||
# Protocol Buffers - Google's data interchange format |
||||
# Copyright 2024 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 |
||||
# |
||||
"""Supporting C++ compilation of generated code""" |
||||
|
||||
load("@proto_bazel_features//:features.bzl", "bazel_features") |
||||
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain") |
||||
load("@rules_cc//cc/common:cc_common.bzl", "cc_common") |
||||
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") |
||||
|
||||
def get_feature_configuration(ctx, has_sources, extra_requested_features = []): |
||||
"""Returns C++ feature configuration for compiling and linking generated C++ files. |
||||
|
||||
Args: |
||||
ctx: (RuleCtx) rule context. |
||||
has_sources: (bool) Has the proto_library sources. |
||||
extra_requested_features: (list[str]) Additionally requested features. |
||||
Returns: |
||||
(FeatureConfiguration) C++ feature configuration |
||||
""" |
||||
cc_toolchain = find_cc_toolchain(ctx) |
||||
requested_features = ctx.features + extra_requested_features |
||||
|
||||
# TODO: Remove LAYERING_CHECK once we have verified that there are direct |
||||
# dependencies for all generated #includes. |
||||
unsupported_features = ctx.disabled_features + ["parse_headers", "layering_check"] |
||||
if has_sources: |
||||
requested_features.append("header_modules") |
||||
else: |
||||
unsupported_features.append("header_modules") |
||||
return cc_common.configure_features( |
||||
ctx = ctx, |
||||
cc_toolchain = cc_toolchain, |
||||
requested_features = requested_features, |
||||
unsupported_features = unsupported_features, |
||||
) |
||||
|
||||
def _get_libraries_from_linking_outputs(linking_outputs, feature_configuration): |
||||
library_to_link = linking_outputs.library_to_link |
||||
if not library_to_link: |
||||
return [] |
||||
outputs = [] |
||||
if library_to_link.static_library: |
||||
outputs.append(library_to_link.static_library) |
||||
if library_to_link.pic_static_library: |
||||
outputs.append(library_to_link.pic_static_library) |
||||
|
||||
# On Windows, dynamic library is not built by default, so don't add them to files_to_build. |
||||
if not cc_common.is_enabled(feature_configuration = feature_configuration, feature_name = "targets_windows"): |
||||
if library_to_link.resolved_symlink_dynamic_library: |
||||
outputs.append(library_to_link.resolved_symlink_dynamic_library) |
||||
elif library_to_link.dynamic_library: |
||||
outputs.append(library_to_link.dynamic_library) |
||||
if library_to_link.resolved_symlink_interface_library: |
||||
outputs.append(library_to_link.resolved_symlink_interface_library) |
||||
elif library_to_link.interface_library: |
||||
outputs.append(library_to_link.interface_library) |
||||
return outputs |
||||
|
||||
def cc_proto_compile_and_link(ctx, deps, sources, headers, disallow_dynamic_library = None, feature_configuration = None, alwayslink = False, **kwargs): |
||||
"""Creates C++ compilation and linking actions for C++ proto sources. |
||||
|
||||
Args: |
||||
ctx: rule context |
||||
deps: (list[CcInfo]) List of libraries to be added as dependencies to compilation and linking |
||||
actions. |
||||
sources:(list[File]) List of C++ sources files. |
||||
headers: list(File] List of C++ headers files. |
||||
disallow_dynamic_library: (bool) Are dynamic libraries disallowed. |
||||
feature_configuration: (FeatureConfiguration) feature configuration to use. |
||||
alwayslink: (bool) Should the library be always linked. |
||||
**kwargs: Additional arguments passed to the compilation. See cc_common.compile. |
||||
|
||||
Returns: |
||||
(CcInfo, list[File], list[File]) |
||||
- CcInfo provider with compilation context and linking context |
||||
- A list of linked libraries related to this proto |
||||
- A list of temporary files generated durind compilation |
||||
""" |
||||
cc_toolchain = find_cc_toolchain(ctx) |
||||
feature_configuration = feature_configuration or get_feature_configuration(ctx, bool(sources)) |
||||
if disallow_dynamic_library == None: |
||||
# TODO: Configure output artifact with action_config |
||||
# once proto compile action is configurable from the crosstool. |
||||
disallow_dynamic_library = not cc_common.is_enabled( |
||||
feature_name = "supports_dynamic_linker", |
||||
feature_configuration = feature_configuration, |
||||
) |
||||
|
||||
(compilation_context, compilation_outputs) = cc_common.compile( |
||||
actions = ctx.actions, |
||||
feature_configuration = feature_configuration, |
||||
cc_toolchain = cc_toolchain, |
||||
srcs = sources, |
||||
public_hdrs = headers, |
||||
compilation_contexts = [dep[CcInfo].compilation_context for dep in deps if CcInfo in dep], |
||||
name = ctx.label.name, |
||||
# Don't instrument the generated C++ files even when --collect_code_coverage is set. |
||||
# If we actually start generating coverage instrumentation for .proto files based on coverage |
||||
# data from the generated C++ files, this will have to be removed. Currently, the work done |
||||
# to instrument those files and execute the instrumentation is all for nothing, and it can |
||||
# be quite a bit of extra computation even when that's not made worse by performance bugs, |
||||
# as in b/64963386. |
||||
# code_coverage_enabled = False (cc_common.compile disables code_coverage by default) |
||||
**kwargs |
||||
) |
||||
|
||||
if sources: |
||||
linking_context, linking_outputs = cc_common.create_linking_context_from_compilation_outputs( |
||||
actions = ctx.actions, |
||||
feature_configuration = feature_configuration, |
||||
cc_toolchain = cc_toolchain, |
||||
compilation_outputs = compilation_outputs, |
||||
linking_contexts = [dep[CcInfo].linking_context for dep in deps if CcInfo in dep], |
||||
name = ctx.label.name, |
||||
disallow_dynamic_library = disallow_dynamic_library, |
||||
alwayslink = alwayslink, |
||||
) |
||||
libraries = _get_libraries_from_linking_outputs(linking_outputs, feature_configuration) |
||||
else: |
||||
linking_context = cc_common.merge_linking_contexts( |
||||
linking_contexts = [dep[CcInfo].linking_context for dep in deps if CcInfo in dep], |
||||
) |
||||
libraries = [] |
||||
|
||||
debug_context = None |
||||
temps = [] |
||||
if bazel_features.cc.protobuf_on_allowlist: |
||||
debug_context = cc_common.merge_debug_context( |
||||
[cc_common.create_debug_context(compilation_outputs)] + |
||||
[dep[CcInfo].debug_context() for dep in deps if CcInfo in dep], |
||||
) |
||||
temps = compilation_outputs.temps() |
||||
|
||||
return CcInfo( |
||||
compilation_context = compilation_context, |
||||
linking_context = linking_context, |
||||
debug_context = debug_context, |
||||
), libraries, temps |
@ -0,0 +1,178 @@ |
||||
# Copyright (c) 2009-2024, Google LLC |
||||
# 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 Starlark implementation of the java_lite_proto_library rule.""" |
||||
|
||||
load("@rules_java//java/common:java_common.bzl", "java_common") |
||||
load("@rules_java//java/common:java_info.bzl", "JavaInfo") |
||||
load("@rules_java//java/common:proguard_spec_info.bzl", "ProguardSpecInfo") |
||||
load("//bazel/common:proto_common.bzl", "proto_common") |
||||
load("//bazel/common:proto_info.bzl", "ProtoInfo") |
||||
load("//bazel/private:java_proto_support.bzl", "JavaProtoAspectInfo", "java_compile_for_protos", "java_info_merge_for_protos") |
||||
load("//bazel/private:toolchain_helpers.bzl", "toolchains") |
||||
|
||||
_PROTO_TOOLCHAIN_ATTR = "_aspect_proto_toolchain_for_javalite" |
||||
|
||||
_JAVA_LITE_PROTO_TOOLCHAIN = Label("//bazel/private:javalite_toolchain_type") |
||||
|
||||
def _aspect_impl(target, ctx): |
||||
"""Generates and compiles Java code for a proto_library dependency graph. |
||||
|
||||
Args: |
||||
target: (Target) The `proto_library` target. |
||||
ctx: (RuleContext) The rule context. |
||||
|
||||
Returns: |
||||
([JavaInfo, JavaProtoAspectInfo]) A JavaInfo describing compiled Java |
||||
version of`proto_library` and `JavaProtoAspectInfo` with all source and |
||||
runtime jars. |
||||
""" |
||||
|
||||
deps = [dep[JavaInfo] for dep in ctx.rule.attr.deps] |
||||
exports = [exp[JavaInfo] for exp in ctx.rule.attr.exports] |
||||
proto_toolchain_info = toolchains.find_toolchain( |
||||
ctx, |
||||
"_aspect_proto_toolchain_for_javalite", |
||||
_JAVA_LITE_PROTO_TOOLCHAIN, |
||||
) |
||||
source_jar = None |
||||
|
||||
if proto_common.experimental_should_generate_code(target[ProtoInfo], proto_toolchain_info, "java_lite_proto_library", target.label): |
||||
source_jar = ctx.actions.declare_file(ctx.label.name + "-lite-src.jar") |
||||
proto_common.compile( |
||||
ctx.actions, |
||||
target[ProtoInfo], |
||||
proto_toolchain_info, |
||||
[source_jar], |
||||
experimental_output_files = "single", |
||||
) |
||||
runtime = proto_toolchain_info.runtime |
||||
if runtime: |
||||
deps.append(runtime[JavaInfo]) |
||||
|
||||
java_info, jars = java_compile_for_protos( |
||||
ctx, |
||||
"-lite.jar", |
||||
source_jar, |
||||
deps, |
||||
exports, |
||||
injecting_rule_kind = "java_lite_proto_library", |
||||
) |
||||
transitive_jars = [dep[JavaProtoAspectInfo].jars for dep in ctx.rule.attr.deps] |
||||
|
||||
return [ |
||||
java_info, |
||||
JavaProtoAspectInfo(jars = depset(jars, transitive = transitive_jars)), |
||||
] |
||||
|
||||
_java_lite_proto_aspect = aspect( |
||||
implementation = _aspect_impl, |
||||
attr_aspects = ["deps", "exports"], |
||||
attrs = toolchains.if_legacy_toolchain({ |
||||
_PROTO_TOOLCHAIN_ATTR: attr.label( |
||||
default = configuration_field(fragment = "proto", name = "proto_toolchain_for_java_lite"), |
||||
), |
||||
}), |
||||
fragments = ["java"], |
||||
required_providers = [ProtoInfo], |
||||
provides = [JavaInfo, JavaProtoAspectInfo], |
||||
toolchains = ["@bazel_tools//tools/jdk:toolchain_type"] + |
||||
toolchains.use_toolchain(_JAVA_LITE_PROTO_TOOLCHAIN), |
||||
) |
||||
|
||||
def _rule_impl(ctx): |
||||
"""Merges results of `java_proto_aspect` in `deps`. |
||||
|
||||
`java_lite_proto_library` is identical to `java_proto_library` in every respect, except it |
||||
builds JavaLite protos. |
||||
Implementation of this rule is built on the implementation of `java_proto_library`. |
||||
|
||||
Args: |
||||
ctx: (RuleContext) The rule context. |
||||
Returns: |
||||
([JavaInfo, DefaultInfo, OutputGroupInfo, ProguardSpecInfo]) |
||||
""" |
||||
|
||||
proto_toolchain_info = toolchains.find_toolchain( |
||||
ctx, |
||||
"_aspect_proto_toolchain_for_javalite", |
||||
_JAVA_LITE_PROTO_TOOLCHAIN, |
||||
) |
||||
for dep in ctx.attr.deps: |
||||
proto_common.check_collocated(ctx.label, dep[ProtoInfo], proto_toolchain_info) |
||||
|
||||
runtime = proto_toolchain_info.runtime |
||||
|
||||
if runtime: |
||||
proguard_provider_specs = runtime[ProguardSpecInfo] |
||||
else: |
||||
proguard_provider_specs = ProguardSpecInfo(depset()) |
||||
|
||||
java_info = java_info_merge_for_protos([dep[JavaInfo] for dep in ctx.attr.deps], merge_java_outputs = False) |
||||
|
||||
transitive_src_and_runtime_jars = depset(transitive = [dep[JavaProtoAspectInfo].jars for dep in ctx.attr.deps]) |
||||
transitive_runtime_jars = depset(transitive = [java_info.transitive_runtime_jars]) |
||||
|
||||
if hasattr(java_common, "add_constraints"): |
||||
java_info = java_common.add_constraints(java_info, constraints = ["android"]) |
||||
|
||||
return [ |
||||
java_info, |
||||
DefaultInfo( |
||||
files = transitive_src_and_runtime_jars, |
||||
runfiles = ctx.runfiles(transitive_files = transitive_runtime_jars), |
||||
), |
||||
OutputGroupInfo(default = depset()), |
||||
proguard_provider_specs, |
||||
] |
||||
|
||||
java_lite_proto_library = rule( |
||||
implementation = _rule_impl, |
||||
doc = """ |
||||
<p> |
||||
<code>java_lite_proto_library</code> generates Java code from <code>.proto</code> files. |
||||
</p> |
||||
|
||||
<p> |
||||
<code>deps</code> must point to <a href="protocol-buffer.html#proto_library"><code>proto_library |
||||
</code></a> rules. |
||||
</p> |
||||
|
||||
<p> |
||||
Example: |
||||
</p> |
||||
|
||||
<pre class="code"> |
||||
<code class="lang-starlark"> |
||||
java_library( |
||||
name = "lib", |
||||
runtime_deps = [":foo"], |
||||
) |
||||
|
||||
java_lite_proto_library( |
||||
name = "foo", |
||||
deps = [":bar"], |
||||
) |
||||
|
||||
proto_library( |
||||
name = "bar", |
||||
) |
||||
</code> |
||||
</pre> |
||||
""", |
||||
attrs = { |
||||
"deps": attr.label_list(providers = [ProtoInfo], aspects = [_java_lite_proto_aspect], doc = """ |
||||
The list of <a href="protocol-buffer.html#proto_library"><code>proto_library</code></a> |
||||
rules to generate Java code for. |
||||
"""), |
||||
} | toolchains.if_legacy_toolchain({ |
||||
_PROTO_TOOLCHAIN_ATTR: attr.label( |
||||
default = configuration_field(fragment = "proto", name = "proto_toolchain_for_java_lite"), |
||||
), |
||||
}), |
||||
provides = [JavaInfo], |
||||
toolchains = toolchains.use_toolchain(_JAVA_LITE_PROTO_TOOLCHAIN), |
||||
) |
@ -0,0 +1,62 @@ |
||||
# 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 |
||||
"""Support for compiling protoc generated Java code.""" |
||||
|
||||
load("@rules_java//java/private:proto_support.bzl", "compile", "merge") # buildifier: disable=bzl-visibility |
||||
|
||||
# The provider is used to collect source and runtime jars in the `proto_library` dependency graph. |
||||
JavaProtoAspectInfo = provider("JavaProtoAspectInfo", fields = ["jars"]) |
||||
|
||||
java_info_merge_for_protos = merge |
||||
|
||||
def java_compile_for_protos(ctx, output_jar_suffix, source_jar = None, deps = [], exports = [], injecting_rule_kind = "java_proto_library"): |
||||
"""Compiles Java source jar returned by proto compiler. |
||||
|
||||
Use this call for java_xxx_proto_library. It uses java_common.compile with |
||||
some checks disabled (via javacopts) and jspecify disabled, so that the |
||||
generated code passes. |
||||
|
||||
It also takes care that input source jar is not repackaged with a different |
||||
name. |
||||
|
||||
When `source_jar` is `None`, the function only merges `deps` and `exports`. |
||||
|
||||
Args: |
||||
ctx: (RuleContext) Used to call `java_common.compile` |
||||
output_jar_suffix: (str) How to name the output jar. For example: `-speed.jar`. |
||||
source_jar: (File) Input source jar (may be `None`). |
||||
deps: (list[JavaInfo]) `deps` of the `proto_library`. |
||||
exports: (list[JavaInfo]) `exports` of the `proto_library`. |
||||
injecting_rule_kind: (str) Rule kind requesting the compilation. |
||||
It's embedded into META-INF of the produced runtime jar, for debugging. |
||||
Returns: |
||||
((JavaInfo, list[File])) JavaInfo of this target and list containing source |
||||
and runtime jar, when they are created. |
||||
""" |
||||
if source_jar != None: |
||||
path, sep, filename = ctx.label.name.rpartition("/") |
||||
output_jar = ctx.actions.declare_file(path + sep + "lib" + filename + output_jar_suffix) |
||||
java_toolchain = ctx.toolchains["@bazel_tools//tools/jdk:toolchain_type"].java |
||||
java_info = compile( |
||||
ctx = ctx, |
||||
output = output_jar, |
||||
java_toolchain = java_toolchain, |
||||
source_jars = [source_jar], |
||||
deps = deps, |
||||
exports = exports, |
||||
output_source_jar = source_jar, |
||||
injecting_rule_kind = injecting_rule_kind, |
||||
javac_opts = java_toolchain._compatible_javacopts.get("proto", depset()), |
||||
enable_jspecify = False, |
||||
include_compilation_info = False, |
||||
) |
||||
jars = [source_jar, output_jar] |
||||
else: |
||||
# If there are no proto sources just pass along the compilation dependencies. |
||||
java_info = merge(deps + exports, merge_java_outputs = False, merge_source_jars = False) |
||||
jars = [] |
||||
return java_info, jars |
@ -1,5 +1,5 @@ |
||||
"""Renames toplevel symbols so they can be exported in Starlark under the same name""" |
||||
|
||||
NativeProtoInfo = ProtoInfo |
||||
|
||||
native_proto_common = proto_common_do_not_use |
||||
|
||||
native_cc_proto_aspect = cc_proto_aspect |
||||
|
@ -0,0 +1,186 @@ |
||||
# Protocol Buffers - Google's data interchange format |
||||
# Copyright 2024 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 |
||||
# |
||||
""" |
||||
Definition of ProtoInfo provider. |
||||
""" |
||||
|
||||
_warning = """ Don't use this field. It's intended for internal use and will be changed or removed |
||||
without warning.""" |
||||
|
||||
def _uniq(iterable): |
||||
unique_elements = {element: None for element in iterable} |
||||
return list(unique_elements.keys()) |
||||
|
||||
def _join(*path): |
||||
return "/".join([p for p in path if p != ""]) |
||||
|
||||
def _empty_to_dot(path): |
||||
return path if path else "." |
||||
|
||||
def _from_root(root, repo, relpath): |
||||
"""Constructs an exec path from root to relpath""" |
||||
if not root: |
||||
# `relpath` is a directory with an input source file, the exec path is one of: |
||||
# - when in main repo: `package/path` |
||||
# - when in a external repository: `external/repo/package/path` |
||||
# - with sibling layout: `../repo/package/path` |
||||
return _join(repo, relpath) |
||||
else: |
||||
# `relpath` is a directory with a generated file or an output directory: |
||||
# - when in main repo: `{root}/package/path` |
||||
# - when in an external repository: `{root}/external/repo/package/path` |
||||
# - with sibling layout: `{root}/package/path` |
||||
return _join(root, "" if repo.startswith("../") else repo, relpath) |
||||
|
||||
def _create_proto_info(*, srcs, deps, descriptor_set, proto_path = "", workspace_root = "", bin_dir = None, allow_exports = None): |
||||
"""Constructs ProtoInfo. |
||||
|
||||
Args: |
||||
srcs: ([File]) List of .proto files (possibly under _virtual path) |
||||
deps: ([ProtoInfo]) List of dependencies |
||||
descriptor_set: (File) Descriptor set for this Proto |
||||
proto_path: (str) Path that should be stripped from files in srcs. When |
||||
stripping is needed, the files should be symlinked into `_virtual_imports/target_name` |
||||
directory. Only such paths are accepted. |
||||
workspace_root: (str) Set to ctx.workspace_root if this is not the main repository. |
||||
bin_dir: (str) Set to ctx.bin_dir if _virtual_imports are used. |
||||
allow_exports: (Target) The packages where this proto_library can be exported. |
||||
|
||||
Returns: |
||||
(ProtoInfo) |
||||
""" |
||||
|
||||
# Validate parameters |
||||
src_prefix = _join(workspace_root.replace("external/", "../"), proto_path) |
||||
for src in srcs: |
||||
if type(src) != "File": |
||||
fail("srcs parameter expects a list of Files") |
||||
if src.owner.workspace_root != workspace_root: |
||||
fail("srcs parameter expects all files to have the same workspace_root: ", workspace_root) |
||||
if not src.short_path.startswith(src_prefix): |
||||
fail("srcs parameter expects all files start with %s" % src_prefix) |
||||
if type(descriptor_set) != "File": |
||||
fail("descriptor_set parameter expected to be a File") |
||||
if proto_path: |
||||
if "_virtual_imports/" not in proto_path: |
||||
fail("proto_path needs to contain '_virtual_imports' directory") |
||||
if proto_path.split("/")[-2] != "_virtual_imports": |
||||
fail("proto_path needs to be formed like '_virtual_imports/target_name'") |
||||
if not bin_dir: |
||||
fail("bin_dir parameter should be set when _virtual_imports are used") |
||||
|
||||
direct_proto_sources = srcs |
||||
transitive_proto_sources = depset( |
||||
direct = direct_proto_sources, |
||||
transitive = [dep._transitive_proto_sources for dep in deps], |
||||
order = "preorder", |
||||
) |
||||
transitive_sources = depset( |
||||
direct = srcs, |
||||
transitive = [dep.transitive_sources for dep in deps], |
||||
order = "preorder", |
||||
) |
||||
|
||||
# There can be up more than 1 direct proto_paths, for example when there's |
||||
# a generated and non-generated .proto file in srcs |
||||
root_paths = _uniq([src.root.path for src in srcs]) |
||||
transitive_proto_path = depset( |
||||
direct = [_empty_to_dot(_from_root(root, workspace_root, proto_path)) for root in root_paths], |
||||
transitive = [dep.transitive_proto_path for dep in deps], |
||||
) |
||||
|
||||
if srcs: |
||||
check_deps_sources = depset(direct = srcs) |
||||
else: |
||||
check_deps_sources = depset(transitive = [dep.check_deps_sources for dep in deps]) |
||||
|
||||
transitive_descriptor_sets = depset( |
||||
direct = [descriptor_set], |
||||
transitive = [dep.transitive_descriptor_sets for dep in deps], |
||||
) |
||||
|
||||
# Layering checks. |
||||
if srcs: |
||||
exported_sources = depset(direct = direct_proto_sources) |
||||
else: |
||||
exported_sources = depset(transitive = [dep._exported_sources for dep in deps]) |
||||
|
||||
if "_virtual_imports/" in proto_path: |
||||
#TODO: remove bin_dir from proto_source_root (when users assuming it's there are migrated) |
||||
proto_source_root = _empty_to_dot(_from_root(bin_dir, workspace_root, proto_path)) |
||||
elif workspace_root.startswith("../"): |
||||
proto_source_root = proto_path |
||||
else: |
||||
proto_source_root = _empty_to_dot(_join(workspace_root, proto_path)) |
||||
|
||||
proto_info = dict( |
||||
direct_sources = srcs, |
||||
transitive_sources = transitive_sources, |
||||
direct_descriptor_set = descriptor_set, |
||||
transitive_descriptor_sets = transitive_descriptor_sets, |
||||
proto_source_root = proto_source_root, |
||||
transitive_proto_path = transitive_proto_path, |
||||
check_deps_sources = check_deps_sources, |
||||
transitive_imports = transitive_sources, |
||||
_direct_proto_sources = direct_proto_sources, |
||||
_transitive_proto_sources = transitive_proto_sources, |
||||
_exported_sources = exported_sources, |
||||
) |
||||
if allow_exports: |
||||
proto_info["allow_exports"] = allow_exports |
||||
return proto_info |
||||
|
||||
ProtoInfo, _ = provider( |
||||
doc = "Encapsulates information provided by a `proto_library.`", |
||||
fields = { |
||||
"direct_sources": "(list[File]) The `.proto` source files from the `srcs` attribute.", |
||||
"transitive_sources": """(depset[File]) The `.proto` source files from this rule and all |
||||
its dependent protocol buffer rules.""", |
||||
"direct_descriptor_set": """(File) The descriptor set of the direct sources. If no srcs, |
||||
contains an empty file.""", |
||||
"transitive_descriptor_sets": """(depset[File]) A set of descriptor set files of all |
||||
dependent `proto_library` rules, and this one's. This is not the same as passing |
||||
--include_imports to proto-compiler. Will be empty if no dependencies.""", |
||||
"proto_source_root": """(str) The directory relative to which the `.proto` files defined in |
||||
the `proto_library` are defined. For example, if this is `a/b` and the rule has the |
||||
file `a/b/c/d.proto` as a source, that source file would be imported as |
||||
`import c/d.proto` |
||||
|
||||
In principle, the `proto_source_root` directory itself should always |
||||
be relative to the output directory (`ctx.bin_dir`). |
||||
|
||||
This is at the moment not true for `proto_libraries` using (additional and/or strip) |
||||
import prefixes. `proto_source_root` is in this case prefixed with the output |
||||
directory. For example, the value is similar to |
||||
`bazel-out/k8-fastbuild/bin/a/_virtual_includes/b` for an input file in |
||||
`a/_virtual_includes/b/c.proto` that should be imported as `c.proto`. |
||||
|
||||
When using the value please account for both cases in a general way. |
||||
That is assume the value is either prefixed with the output directory or not. |
||||
This will make it possible to fix `proto_library` in the future. |
||||
""", |
||||
"transitive_proto_path": """(depset(str) A set of `proto_source_root`s collected from the |
||||
transitive closure of this rule.""", |
||||
"check_deps_sources": """(depset[File]) The `.proto` sources from the 'srcs' attribute. |
||||
If the library is a proxy library that has no sources, it contains the |
||||
`check_deps_sources` from this library's direct deps.""", |
||||
"allow_exports": """(Target) The packages where this proto_library can be exported.""", |
||||
|
||||
# Deprecated fields: |
||||
"transitive_imports": """(depset[File]) Deprecated: use `transitive_sources` instead.""", |
||||
|
||||
# Internal fields: |
||||
"_direct_proto_sources": """(list[File]) The `ProtoSourceInfo`s from the `srcs` |
||||
attribute.""" + _warning, |
||||
"_transitive_proto_sources": """(depset[File]) The `ProtoSourceInfo`s from this |
||||
rule and all its dependent protocol buffer rules.""" + _warning, |
||||
"_exported_sources": """(depset[File]) A set of `ProtoSourceInfo`s that may be |
||||
imported by another `proto_library` depending on this one.""" + _warning, |
||||
}, |
||||
init = _create_proto_info, |
||||
) |
@ -0,0 +1,85 @@ |
||||
load("//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain") |
||||
load("//bazel/toolchains:proto_toolchain.bzl", "proto_toolchain") |
||||
|
||||
# Keep this file as small as possible and free of any unnecessary loads |
||||
# It is loaded by every use of protobuf repository, and loads here can force |
||||
# fetching of additional external repositories |
||||
|
||||
# It's also intentionally using toolchain instead of proto_lang_toolchain, |
||||
# because the former does not resolve dependencies until toolchain resolution |
||||
# needs them |
||||
|
||||
proto_toolchain( |
||||
name = "protoc_sources", |
||||
exec_compatible_with = [], |
||||
proto_compiler = "//:protoc", |
||||
) |
||||
|
||||
toolchain( |
||||
name = "cc_source_toolchain", |
||||
exec_compatible_with = [], |
||||
target_compatible_with = [], |
||||
toolchain = "//:cc_toolchain", |
||||
toolchain_type = "//bazel/private:cc_toolchain_type", |
||||
) |
||||
|
||||
toolchain( |
||||
name = "java_source_toolchain", |
||||
exec_compatible_with = [], |
||||
target_compatible_with = [], |
||||
toolchain = "//java/core:toolchain", |
||||
toolchain_type = "//bazel/private:java_toolchain_type", |
||||
) |
||||
|
||||
toolchain( |
||||
name = "javalite_source_toolchain", |
||||
exec_compatible_with = [], |
||||
target_compatible_with = [], |
||||
toolchain = "//java/lite:toolchain", |
||||
toolchain_type = "//bazel/private:javalite_toolchain_type", |
||||
) |
||||
|
||||
toolchain( |
||||
name = "python_source_toolchain", |
||||
exec_compatible_with = [], |
||||
target_compatible_with = [], |
||||
toolchain = "//python:python_toolchain", |
||||
toolchain_type = "//bazel/private:python_toolchain_type", |
||||
) |
||||
|
||||
# Following toolchain registrations are for builtin Bazel 7 rules |
||||
# which defined them in other repositories. |
||||
toolchain( |
||||
name = "cc_source_toolchain_bazel7", |
||||
exec_compatible_with = [], |
||||
target_compatible_with = [], |
||||
toolchain = "//:cc_toolchain", |
||||
toolchain_type = "@rules_cc//cc/proto:toolchain_type", |
||||
) |
||||
|
||||
toolchain( |
||||
name = "java_source_toolchain_bazel7", |
||||
exec_compatible_with = [], |
||||
target_compatible_with = [], |
||||
toolchain = "//java/core:toolchain", |
||||
toolchain_type = "@rules_java//java/proto:toolchain_type", |
||||
) |
||||
|
||||
toolchain( |
||||
name = "javalite_source_toolchain_bazel7", |
||||
exec_compatible_with = [], |
||||
target_compatible_with = [], |
||||
toolchain = "//java/lite:toolchain", |
||||
toolchain_type = "@rules_java//java/proto:lite_toolchain_type", |
||||
) |
||||
|
||||
filegroup( |
||||
name = "for_bazel_tests", |
||||
testonly = True, |
||||
srcs = [ |
||||
"BUILD.bazel", |
||||
], |
||||
visibility = [ |
||||
"//bazel/private:__pkg__", |
||||
], |
||||
) |
@ -1,17 +0,0 @@ |
||||
# Copyright (c) 2009-2021, Google LLC |
||||
# 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 |
||||
|
||||
"""Temporary alias to repository rule for using Python 3.x headers from the system.""" |
||||
|
||||
load( |
||||
"//python/dist:system_python.bzl", |
||||
_system_python = "system_python", |
||||
) |
||||
|
||||
# TODO: Temporary alias. This is deprecated and to be removed in a future |
||||
# release. Users should now get system_python from protobuf_deps.bzl. |
||||
system_python = _system_python |
@ -0,0 +1,61 @@ |
||||
"""Protobuf-specific kotlin build rules.""" |
||||
|
||||
load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION") |
||||
load("//java/osgi:kotlin_osgi.bzl", "osgi_kt_jvm_library") |
||||
|
||||
BUNDLE_DOC_URL = "https://developers.google.com/protocol-buffers/" |
||||
BUNDLE_LICENSE = "https://opensource.org/licenses/BSD-3-Clause" |
||||
|
||||
def protobuf_versioned_kt_jvm_library( |
||||
automatic_module_name, |
||||
bundle_description, |
||||
bundle_name, |
||||
bundle_symbolic_name, |
||||
bundle_additional_imports = [], |
||||
bundle_additional_exports = [], |
||||
**kwargs): |
||||
"""Extends `kt_jvm_library` to add OSGi headers to the MANIFEST.MF using bndlib |
||||
|
||||
This macro should be usable as a drop-in replacement for kt_jvm_library. |
||||
|
||||
The additional arguments are given the bndlib tool to generate an OSGi-compliant manifest file. |
||||
See [bnd documentation](https://bnd.bndtools.org/chapters/110-introduction.html) |
||||
|
||||
Takes all the args that are standard for a kt_jvm_library target plus the following. |
||||
Args: |
||||
bundle_description: (required) The Bundle-Description header defines a short |
||||
description of this bundle. |
||||
automatic_module_name: (required) The Automatic-Module-Name header that represents |
||||
the name of the module when this bundle is used as an automatic |
||||
module. |
||||
bundle_name: (required) The Bundle-Name header defines a readable name for this |
||||
bundle. This should be a short, human-readable name that can |
||||
contain spaces. |
||||
bundle_symbolic_name: (required) The Bundle-SymbolicName header specifies a |
||||
non-localizable name for this bundle. The bundle symbolic name |
||||
together with a version must identify a unique bundle though it can |
||||
be installed multiple times in a framework. The bundle symbolic |
||||
name should be based on the reverse domain name convention. |
||||
bundle_additional_exports: The Export-Package header contains a |
||||
declaration of exported packages. These are additional export |
||||
package statements to be added before the default wildcard export |
||||
"*;version={$Bundle-Version}". |
||||
bundle_additional_imports: The Import-Package header declares the |
||||
imported packages for this bundle. These are additional import |
||||
package statements to be added before the default wildcard import |
||||
"*". |
||||
**kwargs: Additional key-word arguments that are passed to the internal |
||||
kt_jvm_library target. |
||||
""" |
||||
osgi_kt_jvm_library( |
||||
automatic_module_name = automatic_module_name, |
||||
bundle_doc_url = BUNDLE_DOC_URL, |
||||
bundle_license = BUNDLE_LICENSE, |
||||
bundle_version = PROTOBUF_JAVA_VERSION, |
||||
bundle_description = bundle_description, |
||||
bundle_name = bundle_name, |
||||
bundle_symbolic_name = bundle_symbolic_name, |
||||
bundle_additional_exports = bundle_additional_exports, |
||||
bundle_additional_imports = bundle_additional_imports + ["sun.misc;resolution:=optional"], |
||||
**kwargs |
||||
) |
@ -1,4 +1,6 @@ |
||||
import common.bazelrc |
||||
|
||||
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 |
||||
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 |
||||
build --cxxopt="-Woverloaded-virtual" |
||||
build --copt="-Werror" --copt="-Wno-sign-compare" --copt="-Wno-sign-conversion" --copt="-Wno-error=sign-conversion" --copt="-Wno-deprecated-declarations" |
||||
|
||||
|
@ -1,5 +1,7 @@ |
||||
import common.bazelrc |
||||
|
||||
# Workaround for maximum path length issues |
||||
build --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 |
||||
startup --output_user_root=C:/tmp --windows_enable_symlinks |
||||
common --enable_runfiles |
||||
common --enable_runfiles |
||||
|
||||
|
@ -1,6 +1,8 @@ |
||||
import common.bazelrc |
||||
|
||||
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 |
||||
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 |
||||
build --cxxopt="-Woverloaded-virtual" |
||||
build --copt="-Werror" --copt="-Wno-sign-compare" --copt="-Wno-sign-conversion" --copt="-Wno-error=sign-conversion" --copt="-Wno-deprecated-declarations" |
||||
common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1 |
||||
common --xcode_version_config=@com_google_protobuf//.github:host_xcodes |
||||
common --xcode_version_config=@com_google_protobuf//.github:host_xcodes |
||||
|
||||
|
@ -0,0 +1,25 @@ |
||||
load("@rules_python//python:defs.bzl", "py_binary") |
||||
load("//upb/cmake:build_defs.bzl", "staleness_test") |
||||
|
||||
py_binary( |
||||
name = "dependencies_generator", |
||||
srcs = ["dependencies_generator.py"], |
||||
) |
||||
|
||||
genrule( |
||||
name = "generate_dependencies", |
||||
srcs = ["//:MODULE.bazel"], |
||||
outs = ["generated-in/dependencies.cmake"], |
||||
cmd = "$(location :dependencies_generator) " + |
||||
"$(location //:MODULE.bazel) $@", |
||||
tools = [":dependencies_generator"], |
||||
) |
||||
|
||||
staleness_test( |
||||
name = "test_dependencies_staleness", |
||||
outs = [ |
||||
"dependencies.cmake", |
||||
], |
||||
generated_pattern = "generated-in/%s", |
||||
tags = ["manual"], |
||||
) |
@ -0,0 +1,34 @@ |
||||
# Auto-generated by @//cmake:make_dependencies |
||||
# |
||||
# This file contains lists of external dependencies based on our Bazel |
||||
# config. It should be included from a hand-written CMake file that uses |
||||
# them. |
||||
# |
||||
# Changes to this file will be overwritten based on Bazel definitions. |
||||
|
||||
if(${CMAKE_VERSION} VERSION_GREATER 3.10 OR ${CMAKE_VERSION} VERSION_EQUAL 3.10) |
||||
include_guard() |
||||
endif() |
||||
|
||||
set(abseil-cpp-version "20240722.0") |
||||
set(bazel_skylib-version "1.7.0") |
||||
set(jsoncpp-version "1.9.6") |
||||
set(rules_cc-version "0.0.16") |
||||
set(rules_fuzzing-version "0.5.2") |
||||
set(rules_java-version "8.3.2") |
||||
set(rules_jvm_external-version "6.3") |
||||
set(rules_kotlin-version "1.9.6") |
||||
set(rules_license-version "1.0.0") |
||||
set(rules_pkg-version "1.0.1") |
||||
set(rules_python-version "0.28.0") |
||||
set(rules_rust-version "0.51.0") |
||||
set(platforms-version "0.0.8") |
||||
set(zlib-version "1.3.1") |
||||
set(bazel_features-version "1.17.0") |
||||
set(rules_shell-version "0.2.0") |
||||
set(googletest-version "1.14.0") |
||||
set(rules_buf-version "0.3.0") |
||||
set(rules_testing-version "0.6.0") |
||||
set(rules_proto-version "4.0.0") |
||||
|
||||
|
@ -0,0 +1,143 @@ |
||||
#!/usr/bin/python |
||||
# |
||||
# Protocol Buffers - Google's data interchange format |
||||
# Copyright 2023 Google LLC. All rights reserved. |
||||
# https://developers.google.com/protocol-buffers/ |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google LLC nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
"""A tool to convert MODULE.bazel -> CMakeLists.txt. |
||||
|
||||
This tool is very protobuf-specific at the moment, and should not be seen as a |
||||
generic Bazel -> CMake converter. |
||||
""" |
||||
|
||||
from __future__ import absolute_import |
||||
from __future__ import division |
||||
from __future__ import print_function |
||||
|
||||
import os |
||||
import sys |
||||
import textwrap |
||||
|
||||
|
||||
class ExtensionFunctions(object): |
||||
"""A fake extension that we can use to get the functions we need.""" |
||||
|
||||
def toolchain(self, *args, **kwargs): |
||||
pass |
||||
|
||||
def parse(self, *args, **kwargs): |
||||
pass |
||||
|
||||
def spec(self, *args, **kwargs): |
||||
pass |
||||
|
||||
def from_specs(self, *args, **kwargs): |
||||
pass |
||||
|
||||
def install(self, *args, **kwargs): |
||||
pass |
||||
|
||||
|
||||
class ModuleFileFunctions(object): |
||||
"""A fake MODULE file that we can exec() to get the functions we need.""" |
||||
|
||||
def __init__(self, converter): |
||||
self.converter = converter |
||||
|
||||
def module(self, *args, **kwargs): |
||||
pass |
||||
|
||||
def bazel_dep(self, name, version, **kwargs): |
||||
self.converter.toplevel += textwrap.dedent( |
||||
"""\ |
||||
set(%(name)s-version "%(version)s") |
||||
""" |
||||
% { |
||||
"name": name, |
||||
"version": version, |
||||
} |
||||
) |
||||
|
||||
def register_toolchains(self, *args): |
||||
pass |
||||
|
||||
def use_repo(self, *args, **kwargs): |
||||
pass |
||||
|
||||
def use_extension(self, *args): |
||||
return ExtensionFunctions() |
||||
|
||||
|
||||
class Converter(object): |
||||
|
||||
def __init__(self): |
||||
self.toplevel = "" |
||||
self.if_lua = "" |
||||
|
||||
def convert(self): |
||||
return self.template % { |
||||
"toplevel": converter.toplevel, |
||||
} |
||||
|
||||
template = textwrap.dedent("""\ |
||||
# Auto-generated by @//cmake:make_dependencies |
||||
# |
||||
# This file contains lists of external dependencies based on our Bazel |
||||
# config. It should be included from a hand-written CMake file that uses |
||||
# them. |
||||
# |
||||
# Changes to this file will be overwritten based on Bazel definitions. |
||||
|
||||
if(${CMAKE_VERSION} VERSION_GREATER 3.10 OR ${CMAKE_VERSION} VERSION_EQUAL 3.10) |
||||
include_guard() |
||||
endif() |
||||
|
||||
%(toplevel)s |
||||
|
||||
""") |
||||
|
||||
|
||||
data = {} |
||||
converter = Converter() |
||||
|
||||
|
||||
def GetDict(obj): |
||||
ret = {} |
||||
for k in dir(obj): |
||||
if not k.startswith("_"): |
||||
ret[k] = getattr(obj, k) |
||||
return ret |
||||
|
||||
|
||||
# We take the MODULE path as a command-line argument to ensure that we can find |
||||
# it regardless of how exactly Bazel was invoked. |
||||
exec(open(sys.argv[1]).read(), GetDict(ModuleFileFunctions(converter))) |
||||
|
||||
with open(sys.argv[2], "w") as f: |
||||
f.write(converter.convert()) |
@ -1,48 +1,28 @@ |
||||
option(protobuf_USE_EXTERNAL_GTEST "Use external Google Test (i.e. not the one in third_party/googletest)" OFF) |
||||
|
||||
if (protobuf_USE_EXTERNAL_GTEST) |
||||
find_package(GTest REQUIRED CONFIG) |
||||
else() |
||||
if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/googletest/CMakeLists.txt") |
||||
message(FATAL_ERROR |
||||
"Cannot find third_party/googletest directory that's needed to " |
||||
"build tests. If you use git, make sure you have cloned submodules:\n" |
||||
" git submodule update --init --recursive\n" |
||||
"If instead you want to skip tests, run cmake with:\n" |
||||
" cmake -Dprotobuf_BUILD_TESTS=OFF\n") |
||||
if (NOT TARGET GTest::gmock) |
||||
if (NOT protobuf_FORCE_FETCH_DEPENDENCIES) |
||||
find_package(GTest CONFIG) |
||||
endif() |
||||
|
||||
set(googlemock_source_dir "${protobuf_SOURCE_DIR}/third_party/googletest/googlemock") |
||||
set(googletest_source_dir "${protobuf_SOURCE_DIR}/third_party/googletest/googletest") |
||||
include_directories( |
||||
${googlemock_source_dir} |
||||
${googletest_source_dir} |
||||
${googletest_source_dir}/include |
||||
${googlemock_source_dir}/include |
||||
) |
||||
# Fallback to fetching Googletest from github if it's not found locally. |
||||
if (NOT GTest_FOUND AND NOT protobuf_LOCAL_DEPENDENCIES_ONLY) |
||||
include(${protobuf_SOURCE_DIR}/cmake/dependencies.cmake) |
||||
message(STATUS "Fallback to downloading GTest ${googletest-version} from GitHub") |
||||
|
||||
add_library(gmock ${protobuf_SHARED_OR_STATIC} |
||||
"${googlemock_source_dir}/src/gmock-all.cc" |
||||
"${googletest_source_dir}/src/gtest-all.cc" |
||||
) |
||||
if (protobuf_BUILD_SHARED_LIBS) |
||||
set_target_properties(gmock |
||||
PROPERTIES |
||||
COMPILE_DEFINITIONS |
||||
"GTEST_CREATE_SHARED_LIBRARY=1" |
||||
include(FetchContent) |
||||
FetchContent_Declare( |
||||
googletest |
||||
GIT_REPOSITORY "https://github.com/google/googletest.git" |
||||
GIT_TAG "v${googletest-version}" |
||||
) |
||||
|
||||
endif() |
||||
if (protobuf_INSTALL) |
||||
set(protobuf_INSTALL_TESTS ON) |
||||
# Due to https://github.com/google/googletest/issues/4384, we can't name this |
||||
# GTest for use with find_package until 1.15.0. |
||||
FetchContent_MakeAvailable(googletest) |
||||
endif() |
||||
endif() |
||||
|
||||
target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT}) |
||||
add_library(gmock_main STATIC "${googlemock_source_dir}/src/gmock_main.cc") |
||||
target_link_libraries(gmock_main gmock) |
||||
|
||||
add_library(GTest::gmock ALIAS gmock) |
||||
add_library(GTest::gmock_main ALIAS gmock_main) |
||||
add_library(GTest::gtest ALIAS gmock) |
||||
add_library(GTest::gtest_main ALIAS gmock_main) |
||||
if (NOT TARGET GTest::gmock) |
||||
message(FATAL_ERROR |
||||
"Cannot find googletest dependency that's needed to build tests.\n" |
||||
"If instead you want to skip tests, run cmake with:\n" |
||||
" cmake -Dprotobuf_BUILD_TESTS=OFF\n") |
||||
endif() |
||||
|
@ -0,0 +1,11 @@ |
||||
Required.*.JsonInput.DoubleFieldEmptyString # Should have failed to parse, but didn't. |
||||
Required.*.JsonInput.FloatFieldEmptyString # Should have failed to parse, but didn't. |
||||
Required.*.JsonInput.Int32FieldEmptyString # Should have failed to parse, but didn't. |
||||
Required.*.JsonInput.Int64FieldEmptyString # Should have failed to parse, but didn't. |
||||
Required.*.JsonInput.Uint32FieldEmptyString # Should have failed to parse, but didn't. |
||||
Required.*.JsonInput.Uint64FieldEmptyString # Should have failed to parse, but didn't. |
||||
Required.*.JsonInput.DoubleFieldStringValueNonNumeric # Should have failed to parse, but didn't. |
||||
Required.*.JsonInput.DoubleFieldStringValuePartiallyNumeric # Should have failed to parse, but didn't. |
||||
Required.*.JsonInput.FloatFieldStringValueNonNumeric # Should have failed to parse, but didn't. |
||||
Required.*.JsonInput.FloatFieldStringValuePartiallyNumeric # Should have failed to parse, but didn't. |
||||
Required.*.JsonInput.Int32FieldQuotedExponentialValue.* # Failed to parse input or produce output. |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue