ruby_memprofiler_pprof 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/ruby_memprofiler_pprof/backtrace.c +429 -0
- data/ext/ruby_memprofiler_pprof/collector.c +1055 -0
- data/ext/ruby_memprofiler_pprof/compat.c +182 -0
- data/ext/ruby_memprofiler_pprof/extconf.rb +72 -0
- data/ext/ruby_memprofiler_pprof/pprof.upb.c +170 -0
- data/ext/ruby_memprofiler_pprof/pprof.upb.h +848 -0
- data/ext/ruby_memprofiler_pprof/pprof_out.c +285 -0
- data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.c +11 -0
- data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.h +301 -0
- data/ext/ruby_memprofiler_pprof/strtab.c +391 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/BUILD +719 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/CONTRIBUTING.md +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/DESIGN.md +201 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/LICENSE +26 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/README.md +78 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/WORKSPACE +58 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/BUILD +53 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/amalgamate.py +129 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/build_defs.bzl +160 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/lua.BUILD +127 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/protobuf.patch +54 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/py_proto_library.bzl +137 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/python_downloads.bzl +84 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/system_python.bzl +101 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/upb_proto_library.bzl +388 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/workspace_deps.bzl +89 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD +252 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD.googleapis +54 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/benchmark.cc +333 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/build_defs.bzl +88 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/compare.py +118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor.proto +888 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor_sv.proto +890 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/empty.proto +6 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_protobuf_binary_cc.py +64 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_synthetic_protos.py +118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_upb_binary_c.py +65 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/BUILD.bazel +102 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/README.md +23 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/build_defs.bzl +73 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/make_cmakelists.py +340 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test.py +57 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test_lib.py +186 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/render.py +43 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/style-guide.md +65 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/vs-cpp-protos.md +255 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/wrapping-upb.md +444 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/BUILD +216 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.c +394 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.h +63 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.c +1694 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.h +80 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.c +704 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.h +114 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.c +650 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.h +48 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/BUILD.bazel +193 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/dist.bzl +190 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.c +247 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.h +39 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.c +522 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.h +66 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.c +1909 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.h +101 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/minimal_test.py +183 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/BUILD +70 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/README.md +11 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_database_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_pool_test_wrapper.py +45 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_test_wrapper.py +46 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/generator_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/json_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/keywords_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_factory_test_wrapper.py +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_test_wrapper.py +52 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/proto_builder_test_wrapper.py +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/pyproto_test_wrapper.bzl +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/reflection_test_wrapper.py +45 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/service_reflection_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/symbol_database_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_encoding_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/unknown_fields_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/well_known_types_test_wrapper.py +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/wire_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.c +350 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.h +230 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/py_extension.bzl +55 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/python_api.h +61 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.c +828 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.h +69 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.c +404 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.h +39 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/version_script.lds +6 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/LICENSE +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/README.google +9 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/console.lua +156 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/lunit.lua +725 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/BUILD +19 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/LICENSE +21 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/naive.c +92 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-neon.c +157 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-sse.c +170 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/utf8_range.h +9 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/BUILD.bazel +129 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/README.md +8 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/def.c +939 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/lua_proto_library.bzl +138 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/main.c +83 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/msg.c +1118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test.proto +69 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test_upb.lua +846 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.c +258 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.h +132 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.lua +58 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upbc.cc +134 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.c +192 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.h +174 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb.c +346 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb_failures.txt +1 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.c +1221 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.h +94 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.c +1055 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.h +153 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_internal.h +211 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.c +3262 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.h +414 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.hpp +438 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/empty.proto +1 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.c +604 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.h +71 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/BUILD +13 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/file_descriptor_parsenew_fuzzer.cc +43 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.c +1509 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.h +47 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.c +776 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.h +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.c +1147 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.h +189 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.hpp +112 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.c +363 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.h +263 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_internal.h +59 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_test.cc +425 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_test.cc +230 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.c +428 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.h +114 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_internal.h +836 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.cc +491 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.proto +195 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_def.inc +261 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_undef.inc +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.c +323 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.h +109 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.hpp +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table.c +926 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table_internal.h +385 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test.proto +74 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.cc +186 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.proto +12 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_generated_code.cc +977 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_table.cc +580 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.c +472 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.h +64 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.c +362 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.h +378 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.hpp +115 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb_internal.h +68 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/BUILD +121 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/README.md +7 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.c +300 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.h +66 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare_test.cc +236 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.c +572 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.h +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_public_import_test.proto +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_regular_import_test.proto +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.cc +143 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.proto +119 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_weak_import_test.proto +28 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_wweak_import_test.proto +28 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.c +311 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.h +94 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.cc +202 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.proto +48 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/BUILD +78 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.cc +77 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.h +112 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upb.cc +1997 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upbdefs.cc +193 -0
- data/lib/ruby_memprofiler_pprof/atfork.rb +77 -0
- data/lib/ruby_memprofiler_pprof/block_flusher.rb +61 -0
- data/lib/ruby_memprofiler_pprof/file_flusher.rb +45 -0
- data/lib/ruby_memprofiler_pprof/profile_app.rb +30 -0
- data/lib/ruby_memprofiler_pprof/profile_data.rb +18 -0
- data/lib/ruby_memprofiler_pprof/version.rb +5 -0
- data/lib/ruby_memprofiler_pprof.rb +8 -0
- data/libexec/ruby_memprofiler_pprof_profile +16 -0
- metadata +257 -0
@@ -0,0 +1,388 @@
|
|
1
|
+
# Copyright (c) 2009-2021, Google LLC
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
# * Redistributions of source code must retain the above copyright
|
7
|
+
# notice, this list of conditions and the following disclaimer.
|
8
|
+
# * Redistributions in binary form must reproduce the above copyright
|
9
|
+
# notice, this list of conditions and the following disclaimer in the
|
10
|
+
# documentation and/or other materials provided with the distribution.
|
11
|
+
# * Neither the name of Google LLC nor the
|
12
|
+
# names of its contributors may be used to endorse or promote products
|
13
|
+
# derived from this software without specific prior written permission.
|
14
|
+
#
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
16
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
|
19
|
+
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
|
+
|
26
|
+
"""Public rules for using upb protos:
|
27
|
+
- upb_proto_library()
|
28
|
+
- upb_proto_reflection_library()
|
29
|
+
"""
|
30
|
+
|
31
|
+
load("@bazel_skylib//lib:paths.bzl", "paths")
|
32
|
+
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
|
33
|
+
|
34
|
+
# Generic support code #########################################################
|
35
|
+
|
36
|
+
# begin:github_only
|
37
|
+
_is_google3 = False
|
38
|
+
# end:github_only
|
39
|
+
|
40
|
+
# begin:google_only
|
41
|
+
# _is_google3 = True
|
42
|
+
# end:google_only
|
43
|
+
|
44
|
+
def _get_real_short_path(file):
|
45
|
+
# For some reason, files from other archives have short paths that look like:
|
46
|
+
# ../com_google_protobuf/google/protobuf/descriptor.proto
|
47
|
+
short_path = file.short_path
|
48
|
+
if short_path.startswith("../"):
|
49
|
+
second_slash = short_path.index("/", 3)
|
50
|
+
short_path = short_path[second_slash + 1:]
|
51
|
+
|
52
|
+
# Sometimes it has another few prefixes like:
|
53
|
+
# _virtual_imports/any_proto/google/protobuf/any.proto
|
54
|
+
# benchmarks/_virtual_imports/100_msgs_proto/benchmarks/100_msgs.proto
|
55
|
+
# We want just google/protobuf/any.proto.
|
56
|
+
virtual_imports = "_virtual_imports/"
|
57
|
+
if virtual_imports in short_path:
|
58
|
+
short_path = short_path.split(virtual_imports)[1].split("/", 1)[1]
|
59
|
+
return short_path
|
60
|
+
|
61
|
+
def _get_real_root(file):
|
62
|
+
real_short_path = _get_real_short_path(file)
|
63
|
+
return file.path[:-len(real_short_path) - 1]
|
64
|
+
|
65
|
+
def _generate_output_file(ctx, src, extension):
|
66
|
+
real_short_path = _get_real_short_path(src)
|
67
|
+
real_short_path = paths.relativize(real_short_path, ctx.label.package)
|
68
|
+
output_filename = paths.replace_extension(real_short_path, extension)
|
69
|
+
ret = ctx.actions.declare_file(output_filename)
|
70
|
+
return ret
|
71
|
+
|
72
|
+
def _filter_none(elems):
|
73
|
+
out = []
|
74
|
+
for elem in elems:
|
75
|
+
if elem:
|
76
|
+
out.append(elem)
|
77
|
+
return out
|
78
|
+
|
79
|
+
def _cc_library_func(ctx, name, hdrs, srcs, copts, dep_ccinfos):
|
80
|
+
"""Like cc_library(), but callable from rules.
|
81
|
+
|
82
|
+
Args:
|
83
|
+
ctx: Rule context.
|
84
|
+
name: Unique name used to generate output files.
|
85
|
+
hdrs: Public headers that can be #included from other rules.
|
86
|
+
srcs: C/C++ source files.
|
87
|
+
dep_ccinfos: CcInfo providers of dependencies we should build/link against.
|
88
|
+
|
89
|
+
Returns:
|
90
|
+
CcInfo provider for this compilation.
|
91
|
+
"""
|
92
|
+
|
93
|
+
compilation_contexts = [info.compilation_context for info in dep_ccinfos]
|
94
|
+
linking_contexts = [info.linking_context for info in dep_ccinfos]
|
95
|
+
toolchain = find_cpp_toolchain(ctx)
|
96
|
+
feature_configuration = cc_common.configure_features(
|
97
|
+
ctx = ctx,
|
98
|
+
cc_toolchain = toolchain,
|
99
|
+
requested_features = ctx.features,
|
100
|
+
unsupported_features = ctx.disabled_features,
|
101
|
+
)
|
102
|
+
|
103
|
+
blaze_only_args = {}
|
104
|
+
|
105
|
+
if _is_google3:
|
106
|
+
blaze_only_args["grep_includes"] = ctx.file._grep_includes
|
107
|
+
|
108
|
+
(compilation_context, compilation_outputs) = cc_common.compile(
|
109
|
+
actions = ctx.actions,
|
110
|
+
feature_configuration = feature_configuration,
|
111
|
+
cc_toolchain = toolchain,
|
112
|
+
name = name,
|
113
|
+
srcs = srcs,
|
114
|
+
public_hdrs = hdrs,
|
115
|
+
user_compile_flags = copts,
|
116
|
+
compilation_contexts = compilation_contexts,
|
117
|
+
**blaze_only_args
|
118
|
+
)
|
119
|
+
(linking_context, linking_outputs) = cc_common.create_linking_context_from_compilation_outputs(
|
120
|
+
actions = ctx.actions,
|
121
|
+
name = name,
|
122
|
+
feature_configuration = feature_configuration,
|
123
|
+
cc_toolchain = toolchain,
|
124
|
+
compilation_outputs = compilation_outputs,
|
125
|
+
linking_contexts = linking_contexts,
|
126
|
+
**blaze_only_args
|
127
|
+
)
|
128
|
+
|
129
|
+
return CcInfo(
|
130
|
+
compilation_context = compilation_context,
|
131
|
+
linking_context = linking_context,
|
132
|
+
)
|
133
|
+
|
134
|
+
# Build setting for whether fasttable code generation is enabled ###############
|
135
|
+
|
136
|
+
_FastTableEnabled = provider(
|
137
|
+
fields = {
|
138
|
+
"enabled": "whether fasttable is enabled",
|
139
|
+
},
|
140
|
+
)
|
141
|
+
|
142
|
+
def fasttable_enabled_impl(ctx):
|
143
|
+
raw_setting = ctx.build_setting_value
|
144
|
+
|
145
|
+
if raw_setting:
|
146
|
+
# TODO(haberman): check that the target CPU supports fasttable.
|
147
|
+
pass
|
148
|
+
|
149
|
+
return _FastTableEnabled(enabled = raw_setting)
|
150
|
+
|
151
|
+
upb_fasttable_enabled = rule(
|
152
|
+
implementation = fasttable_enabled_impl,
|
153
|
+
build_setting = config.bool(flag = True),
|
154
|
+
)
|
155
|
+
|
156
|
+
# Dummy rule to expose select() copts to aspects ##############################
|
157
|
+
|
158
|
+
_UpbProtoLibraryCopts = provider(
|
159
|
+
fields = {
|
160
|
+
"copts": "copts for upb_proto_library()",
|
161
|
+
},
|
162
|
+
)
|
163
|
+
|
164
|
+
def upb_proto_library_copts_impl(ctx):
|
165
|
+
return _UpbProtoLibraryCopts(copts = ctx.attr.copts)
|
166
|
+
|
167
|
+
upb_proto_library_copts = rule(
|
168
|
+
implementation = upb_proto_library_copts_impl,
|
169
|
+
attrs = {"copts": attr.string_list(default = [])},
|
170
|
+
)
|
171
|
+
|
172
|
+
# upb_proto_library / upb_proto_reflection_library shared code #################
|
173
|
+
|
174
|
+
GeneratedSrcsInfo = provider(
|
175
|
+
fields = {
|
176
|
+
"srcs": "list of srcs",
|
177
|
+
"hdrs": "list of hdrs",
|
178
|
+
},
|
179
|
+
)
|
180
|
+
|
181
|
+
_UpbWrappedCcInfo = provider(fields = ["cc_info"])
|
182
|
+
_UpbDefsWrappedCcInfo = provider(fields = ["cc_info"])
|
183
|
+
_WrappedGeneratedSrcsInfo = provider(fields = ["srcs"])
|
184
|
+
_WrappedDefsGeneratedSrcsInfo = provider(fields = ["srcs"])
|
185
|
+
|
186
|
+
def _compile_upb_protos(ctx, generator, proto_info, proto_sources):
|
187
|
+
if len(proto_sources) == 0:
|
188
|
+
return GeneratedSrcsInfo(srcs = [], hdrs = [])
|
189
|
+
|
190
|
+
ext = "." + generator
|
191
|
+
tool = getattr(ctx.executable, "_gen_" + generator)
|
192
|
+
srcs = [_generate_output_file(ctx, name, ext + ".c") for name in proto_sources]
|
193
|
+
hdrs = [_generate_output_file(ctx, name, ext + ".h") for name in proto_sources]
|
194
|
+
transitive_sets = proto_info.transitive_descriptor_sets.to_list()
|
195
|
+
fasttable_enabled = (hasattr(ctx.attr, "_fasttable_enabled") and
|
196
|
+
ctx.attr._fasttable_enabled[_FastTableEnabled].enabled)
|
197
|
+
codegen_params = "fasttable:" if fasttable_enabled else ""
|
198
|
+
ctx.actions.run(
|
199
|
+
inputs = depset(
|
200
|
+
direct = [proto_info.direct_descriptor_set],
|
201
|
+
transitive = [proto_info.transitive_descriptor_sets],
|
202
|
+
),
|
203
|
+
tools = [tool],
|
204
|
+
outputs = srcs + hdrs,
|
205
|
+
executable = ctx.executable._protoc,
|
206
|
+
arguments = [
|
207
|
+
"--" + generator + "_out=" + codegen_params + _get_real_root(srcs[0]),
|
208
|
+
"--plugin=protoc-gen-" + generator + "=" + tool.path,
|
209
|
+
"--descriptor_set_in=" + ctx.configuration.host_path_separator.join([f.path for f in transitive_sets]),
|
210
|
+
] +
|
211
|
+
[_get_real_short_path(file) for file in proto_sources],
|
212
|
+
progress_message = "Generating upb protos for :" + ctx.label.name,
|
213
|
+
mnemonic = "GenUpbProtos",
|
214
|
+
)
|
215
|
+
return GeneratedSrcsInfo(srcs = srcs, hdrs = hdrs)
|
216
|
+
|
217
|
+
def _upb_proto_rule_impl(ctx):
|
218
|
+
if len(ctx.attr.deps) != 1:
|
219
|
+
fail("only one deps dependency allowed.")
|
220
|
+
dep = ctx.attr.deps[0]
|
221
|
+
|
222
|
+
if _WrappedDefsGeneratedSrcsInfo in dep:
|
223
|
+
srcs = dep[_WrappedDefsGeneratedSrcsInfo].srcs
|
224
|
+
elif _WrappedGeneratedSrcsInfo in dep:
|
225
|
+
srcs = dep[_WrappedGeneratedSrcsInfo].srcs
|
226
|
+
else:
|
227
|
+
fail("proto_library rule must generate _WrappedGeneratedSrcsInfo or " +
|
228
|
+
"_WrappedDefsGeneratedSrcsInfo (aspect should have handled this).")
|
229
|
+
|
230
|
+
if _UpbDefsWrappedCcInfo in dep:
|
231
|
+
cc_info = dep[_UpbDefsWrappedCcInfo].cc_info
|
232
|
+
elif _UpbWrappedCcInfo in dep:
|
233
|
+
cc_info = dep[_UpbWrappedCcInfo].cc_info
|
234
|
+
else:
|
235
|
+
fail("proto_library rule must generate _UpbWrappedCcInfo or " +
|
236
|
+
"_UpbDefsWrappedCcInfo (aspect should have handled this).")
|
237
|
+
|
238
|
+
lib = cc_info.linking_context.linker_inputs.to_list()[0].libraries[0]
|
239
|
+
files = _filter_none([
|
240
|
+
lib.static_library,
|
241
|
+
lib.pic_static_library,
|
242
|
+
lib.dynamic_library,
|
243
|
+
])
|
244
|
+
return [
|
245
|
+
DefaultInfo(files = depset(files + srcs.hdrs + srcs.srcs)),
|
246
|
+
srcs,
|
247
|
+
cc_info,
|
248
|
+
]
|
249
|
+
|
250
|
+
def _upb_proto_aspect_impl(target, ctx, generator, cc_provider, file_provider):
|
251
|
+
proto_info = target[ProtoInfo]
|
252
|
+
files = _compile_upb_protos(ctx, generator, proto_info, proto_info.direct_sources)
|
253
|
+
deps = ctx.rule.attr.deps + getattr(ctx.attr, "_" + generator)
|
254
|
+
dep_ccinfos = [dep[CcInfo] for dep in deps if CcInfo in dep]
|
255
|
+
dep_ccinfos += [dep[_UpbWrappedCcInfo].cc_info for dep in deps if _UpbWrappedCcInfo in dep]
|
256
|
+
dep_ccinfos += [dep[_UpbDefsWrappedCcInfo].cc_info for dep in deps if _UpbDefsWrappedCcInfo in dep]
|
257
|
+
if generator == "upbdefs":
|
258
|
+
if _UpbWrappedCcInfo not in target:
|
259
|
+
fail("Target should have _UpbWrappedCcInfo provider")
|
260
|
+
dep_ccinfos += [target[_UpbWrappedCcInfo].cc_info]
|
261
|
+
cc_info = _cc_library_func(
|
262
|
+
ctx = ctx,
|
263
|
+
name = ctx.rule.attr.name + "." + generator,
|
264
|
+
hdrs = files.hdrs,
|
265
|
+
srcs = files.srcs,
|
266
|
+
copts = ctx.attr._copts[_UpbProtoLibraryCopts].copts,
|
267
|
+
dep_ccinfos = dep_ccinfos,
|
268
|
+
)
|
269
|
+
return [cc_provider(cc_info = cc_info), file_provider(srcs = files)]
|
270
|
+
|
271
|
+
def _upb_proto_library_aspect_impl(target, ctx):
|
272
|
+
return _upb_proto_aspect_impl(target, ctx, "upb", _UpbWrappedCcInfo, _WrappedGeneratedSrcsInfo)
|
273
|
+
|
274
|
+
def _upb_proto_reflection_library_aspect_impl(target, ctx):
|
275
|
+
return _upb_proto_aspect_impl(target, ctx, "upbdefs", _UpbDefsWrappedCcInfo, _WrappedDefsGeneratedSrcsInfo)
|
276
|
+
|
277
|
+
def _maybe_add(d):
|
278
|
+
if _is_google3:
|
279
|
+
d["_grep_includes"] = attr.label(
|
280
|
+
allow_single_file = True,
|
281
|
+
cfg = "exec",
|
282
|
+
default = "@bazel_tools//tools/cpp:grep-includes",
|
283
|
+
)
|
284
|
+
return d
|
285
|
+
|
286
|
+
# upb_proto_library() ##########################################################
|
287
|
+
|
288
|
+
_upb_proto_library_aspect = aspect(
|
289
|
+
attrs = _maybe_add({
|
290
|
+
"_copts": attr.label(
|
291
|
+
default = "//:upb_proto_library_copts__for_generated_code_only_do_not_use",
|
292
|
+
),
|
293
|
+
"_gen_upb": attr.label(
|
294
|
+
executable = True,
|
295
|
+
cfg = "exec",
|
296
|
+
default = "//upbc:protoc-gen-upb",
|
297
|
+
),
|
298
|
+
"_protoc": attr.label(
|
299
|
+
executable = True,
|
300
|
+
cfg = "exec",
|
301
|
+
default = "@com_google_protobuf//:protoc",
|
302
|
+
),
|
303
|
+
"_cc_toolchain": attr.label(
|
304
|
+
default = "@bazel_tools//tools/cpp:current_cc_toolchain",
|
305
|
+
),
|
306
|
+
"_upb": attr.label_list(default = [
|
307
|
+
"//:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
|
308
|
+
]),
|
309
|
+
"_fasttable_enabled": attr.label(default = "//:fasttable_enabled"),
|
310
|
+
}),
|
311
|
+
implementation = _upb_proto_library_aspect_impl,
|
312
|
+
provides = [
|
313
|
+
_UpbWrappedCcInfo,
|
314
|
+
_WrappedGeneratedSrcsInfo,
|
315
|
+
],
|
316
|
+
attr_aspects = ["deps"],
|
317
|
+
fragments = ["cpp"],
|
318
|
+
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
|
319
|
+
incompatible_use_toolchain_transition = True,
|
320
|
+
)
|
321
|
+
|
322
|
+
upb_proto_library = rule(
|
323
|
+
output_to_genfiles = True,
|
324
|
+
implementation = _upb_proto_rule_impl,
|
325
|
+
attrs = {
|
326
|
+
"deps": attr.label_list(
|
327
|
+
aspects = [_upb_proto_library_aspect],
|
328
|
+
allow_rules = ["proto_library"],
|
329
|
+
providers = [ProtoInfo],
|
330
|
+
),
|
331
|
+
},
|
332
|
+
)
|
333
|
+
|
334
|
+
# upb_proto_reflection_library() ###############################################
|
335
|
+
|
336
|
+
_upb_proto_reflection_library_aspect = aspect(
|
337
|
+
attrs = _maybe_add({
|
338
|
+
"_copts": attr.label(
|
339
|
+
default = "//:upb_proto_library_copts__for_generated_code_only_do_not_use",
|
340
|
+
),
|
341
|
+
"_gen_upbdefs": attr.label(
|
342
|
+
executable = True,
|
343
|
+
cfg = "exec",
|
344
|
+
default = "//upbc:protoc-gen-upbdefs",
|
345
|
+
),
|
346
|
+
"_protoc": attr.label(
|
347
|
+
executable = True,
|
348
|
+
cfg = "exec",
|
349
|
+
default = "@com_google_protobuf//:protoc",
|
350
|
+
),
|
351
|
+
"_cc_toolchain": attr.label(
|
352
|
+
default = "@bazel_tools//tools/cpp:current_cc_toolchain",
|
353
|
+
),
|
354
|
+
"_upbdefs": attr.label_list(
|
355
|
+
default = [
|
356
|
+
"//:generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
|
357
|
+
],
|
358
|
+
),
|
359
|
+
}),
|
360
|
+
implementation = _upb_proto_reflection_library_aspect_impl,
|
361
|
+
provides = [
|
362
|
+
_UpbDefsWrappedCcInfo,
|
363
|
+
_WrappedDefsGeneratedSrcsInfo,
|
364
|
+
],
|
365
|
+
required_aspect_providers = [
|
366
|
+
_UpbWrappedCcInfo,
|
367
|
+
_WrappedGeneratedSrcsInfo,
|
368
|
+
],
|
369
|
+
attr_aspects = ["deps"],
|
370
|
+
fragments = ["cpp"],
|
371
|
+
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
|
372
|
+
incompatible_use_toolchain_transition = True,
|
373
|
+
)
|
374
|
+
|
375
|
+
upb_proto_reflection_library = rule(
|
376
|
+
output_to_genfiles = True,
|
377
|
+
implementation = _upb_proto_rule_impl,
|
378
|
+
attrs = {
|
379
|
+
"deps": attr.label_list(
|
380
|
+
aspects = [
|
381
|
+
_upb_proto_library_aspect,
|
382
|
+
_upb_proto_reflection_library_aspect,
|
383
|
+
],
|
384
|
+
allow_rules = ["proto_library"],
|
385
|
+
providers = [ProtoInfo],
|
386
|
+
),
|
387
|
+
},
|
388
|
+
)
|
@@ -0,0 +1,89 @@
|
|
1
|
+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
2
|
+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
|
3
|
+
load("//bazel:python_downloads.bzl", "python_nuget_package", "python_source_archive")
|
4
|
+
load("//bazel:system_python.bzl", "system_python")
|
5
|
+
|
6
|
+
def _github_archive(repo, commit, **kwargs):
|
7
|
+
repo_name = repo.split("/")[-1]
|
8
|
+
http_archive(
|
9
|
+
urls = [repo + "/archive/" + commit + ".zip"],
|
10
|
+
strip_prefix = repo_name + "-" + commit,
|
11
|
+
**kwargs
|
12
|
+
)
|
13
|
+
|
14
|
+
def upb_deps():
|
15
|
+
maybe(
|
16
|
+
http_archive,
|
17
|
+
name = "com_google_absl",
|
18
|
+
url = "https://github.com/abseil/abseil-cpp/archive/b9b925341f9e90f5e7aa0cf23f036c29c7e454eb.zip",
|
19
|
+
strip_prefix = "abseil-cpp-b9b925341f9e90f5e7aa0cf23f036c29c7e454eb",
|
20
|
+
sha256 = "bb2a0b57c92b6666e8acb00f4cbbfce6ddb87e83625fb851b0e78db581340617",
|
21
|
+
)
|
22
|
+
|
23
|
+
maybe(
|
24
|
+
_github_archive,
|
25
|
+
name = "com_google_protobuf",
|
26
|
+
repo = "https://github.com/protocolbuffers/protobuf",
|
27
|
+
commit = "b180b2809f7e77fdf7dd075d26a7421085bac58f",
|
28
|
+
patches = ["//bazel:protobuf.patch"],
|
29
|
+
)
|
30
|
+
|
31
|
+
rules_python_version = "740825b7f74930c62f44af95c9a4c1bd428d2c53" # Latest @ 2021-06-23
|
32
|
+
|
33
|
+
maybe(
|
34
|
+
http_archive,
|
35
|
+
name = "rules_python",
|
36
|
+
strip_prefix = "rules_python-{}".format(rules_python_version),
|
37
|
+
url = "https://github.com/bazelbuild/rules_python/archive/{}.zip".format(rules_python_version),
|
38
|
+
sha256 = "09a3c4791c61b62c2cbc5b2cbea4ccc32487b38c7a2cc8f87a794d7a659cc742",
|
39
|
+
)
|
40
|
+
|
41
|
+
maybe(
|
42
|
+
http_archive,
|
43
|
+
name = "bazel_skylib",
|
44
|
+
strip_prefix = "bazel-skylib-main",
|
45
|
+
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/main.tar.gz"],
|
46
|
+
)
|
47
|
+
|
48
|
+
system_python(
|
49
|
+
name = "system_python",
|
50
|
+
)
|
51
|
+
|
52
|
+
#Python Downloads
|
53
|
+
|
54
|
+
python_source_archive(
|
55
|
+
name = "python-3.7.0",
|
56
|
+
sha256 = "85bb9feb6863e04fb1700b018d9d42d1caac178559ffa453d7e6a436e259fd0d",
|
57
|
+
)
|
58
|
+
python_nuget_package(
|
59
|
+
name = "nuget_python_i686_3.7.0",
|
60
|
+
sha256 = "a8bb49fa1ca62ad55430fcafaca1b58015e22943e66b1a87d5e7cef2556c6a54",
|
61
|
+
)
|
62
|
+
python_nuget_package(
|
63
|
+
name = "nuget_python_x86-64_3.7.0",
|
64
|
+
sha256 = "66eb796a5bdb1e6787b8f655a1237a6b6964af2115b7627cf4f0032cf068b4b2",
|
65
|
+
)
|
66
|
+
python_nuget_package(
|
67
|
+
name = "nuget_python_i686_3.8.0",
|
68
|
+
sha256 = "87a6481f5eef30b42ac12c93f06f73bd0b8692f26313b76a6615d1641c4e7bca",
|
69
|
+
)
|
70
|
+
python_nuget_package(
|
71
|
+
name = "nuget_python_x86-64_3.8.0",
|
72
|
+
sha256 = "96c61321ce90dd053c8a04f305a5f6cc6d91350b862db34440e4a4f069b708a0",
|
73
|
+
)
|
74
|
+
python_nuget_package(
|
75
|
+
name = "nuget_python_i686_3.9.0",
|
76
|
+
sha256 = "229abecbe49dc08fe5709e0b31e70edfb3b88f23335ebfc2904c44f940fd59b6",
|
77
|
+
)
|
78
|
+
python_nuget_package(
|
79
|
+
name = "nuget_python_x86-64_3.9.0",
|
80
|
+
sha256 = "6af58a733e7dfbfcdd50d55788134393d6ffe7ab8270effbf724bdb786558832",
|
81
|
+
)
|
82
|
+
python_nuget_package(
|
83
|
+
name = "nuget_python_i686_3.10.0",
|
84
|
+
sha256 = "e115e102eb90ce160ab0ef7506b750a8d7ecc385bde0a496f02a54337a8bc333",
|
85
|
+
)
|
86
|
+
python_nuget_package(
|
87
|
+
name = "nuget_python_x86-64_3.10.0",
|
88
|
+
sha256 = "4474c83c25625d93e772e926f95f4cd398a0abbb52793625fa30f39af3d2cc00",
|
89
|
+
)
|