ruby_memprofiler_pprof 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,160 @@
|
|
|
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
|
+
"""Internal rules for building upb."""
|
|
27
|
+
|
|
28
|
+
load(":upb_proto_library.bzl", "GeneratedSrcsInfo")
|
|
29
|
+
|
|
30
|
+
_DEFAULT_CPPOPTS = []
|
|
31
|
+
_DEFAULT_COPTS = []
|
|
32
|
+
|
|
33
|
+
# begin:github_only
|
|
34
|
+
_DEFAULT_CPPOPTS.extend([
|
|
35
|
+
"-Wextra",
|
|
36
|
+
# "-Wshorten-64-to-32", # not in GCC (and my Kokoro images doesn't have Clang)
|
|
37
|
+
"-Werror",
|
|
38
|
+
"-Wno-long-long",
|
|
39
|
+
])
|
|
40
|
+
_DEFAULT_COPTS.extend([
|
|
41
|
+
"-std=c99",
|
|
42
|
+
"-pedantic",
|
|
43
|
+
"-Werror=pedantic",
|
|
44
|
+
"-Wall",
|
|
45
|
+
"-Wstrict-prototypes",
|
|
46
|
+
# GCC (at least) emits spurious warnings for this that cannot be fixed
|
|
47
|
+
# without introducing redundant initialization (with runtime cost):
|
|
48
|
+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
|
|
49
|
+
#"-Wno-maybe-uninitialized",
|
|
50
|
+
])
|
|
51
|
+
# end:github_only
|
|
52
|
+
|
|
53
|
+
UPB_DEFAULT_CPPOPTS = select({
|
|
54
|
+
"//:windows": [],
|
|
55
|
+
"//conditions:default": _DEFAULT_CPPOPTS,
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
UPB_DEFAULT_COPTS = select({
|
|
59
|
+
"//:windows": [],
|
|
60
|
+
"//:fasttable_enabled_setting": ["-std=gnu99", "-DUPB_ENABLE_FASTTABLE"],
|
|
61
|
+
"//conditions:default": _DEFAULT_COPTS,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
runfiles_init = """\
|
|
65
|
+
# --- begin runfiles.bash initialization v2 ---
|
|
66
|
+
# Copy-pasted from the Bazel Bash runfiles library v2.
|
|
67
|
+
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
|
|
68
|
+
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
|
|
69
|
+
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
|
|
70
|
+
source "$0.runfiles/$f" 2>/dev/null || \
|
|
71
|
+
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
|
|
72
|
+
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
|
|
73
|
+
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
|
|
74
|
+
# --- end runfiles.bash initialization v2 ---
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
def _get_real_short_path(file):
|
|
78
|
+
# For some reason, files from other archives have short paths that look like:
|
|
79
|
+
# ../com_google_protobuf/google/protobuf/descriptor.proto
|
|
80
|
+
short_path = file.short_path
|
|
81
|
+
if short_path.startswith("../"):
|
|
82
|
+
second_slash = short_path.index("/", 3)
|
|
83
|
+
short_path = short_path[second_slash + 1:]
|
|
84
|
+
return short_path
|
|
85
|
+
|
|
86
|
+
def _get_real_root(file):
|
|
87
|
+
real_short_path = _get_real_short_path(file)
|
|
88
|
+
return file.path[:-len(real_short_path) - 1]
|
|
89
|
+
|
|
90
|
+
def _get_real_roots(files):
|
|
91
|
+
roots = {}
|
|
92
|
+
for file in files:
|
|
93
|
+
real_root = _get_real_root(file)
|
|
94
|
+
if real_root:
|
|
95
|
+
roots[real_root] = True
|
|
96
|
+
return roots.keys()
|
|
97
|
+
|
|
98
|
+
def make_shell_script(name, contents, out):
|
|
99
|
+
contents = contents.replace("$", "$$")
|
|
100
|
+
native.genrule(
|
|
101
|
+
name = "gen_" + name,
|
|
102
|
+
outs = [out],
|
|
103
|
+
cmd = "(cat <<'HEREDOC'\n%s\nHEREDOC\n) > $@" % contents,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# upb_amalgamation() rule, with file_list aspect.
|
|
107
|
+
|
|
108
|
+
SrcList = provider(
|
|
109
|
+
fields = {
|
|
110
|
+
"srcs": "list of srcs",
|
|
111
|
+
},
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
def _file_list_aspect_impl(target, ctx):
|
|
115
|
+
if GeneratedSrcsInfo in target:
|
|
116
|
+
srcs = target[GeneratedSrcsInfo]
|
|
117
|
+
return [SrcList(srcs = srcs.srcs + srcs.hdrs)]
|
|
118
|
+
|
|
119
|
+
srcs = []
|
|
120
|
+
for src in ctx.rule.attr.srcs:
|
|
121
|
+
srcs += src.files.to_list()
|
|
122
|
+
for hdr in ctx.rule.attr.hdrs:
|
|
123
|
+
srcs += hdr.files.to_list()
|
|
124
|
+
for hdr in ctx.rule.attr.textual_hdrs:
|
|
125
|
+
srcs += hdr.files.to_list()
|
|
126
|
+
return [SrcList(srcs = srcs)]
|
|
127
|
+
|
|
128
|
+
_file_list_aspect = aspect(
|
|
129
|
+
implementation = _file_list_aspect_impl,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
def _upb_amalgamation(ctx):
|
|
133
|
+
inputs = []
|
|
134
|
+
for lib in ctx.attr.libs:
|
|
135
|
+
inputs += lib[SrcList].srcs
|
|
136
|
+
srcs = [src for src in inputs if src.path.endswith("c")]
|
|
137
|
+
ctx.actions.run(
|
|
138
|
+
inputs = inputs,
|
|
139
|
+
outputs = ctx.outputs.outs,
|
|
140
|
+
arguments = [ctx.bin_dir.path + "/", ctx.attr.prefix] + [f.path for f in srcs] + ["-I" + root for root in _get_real_roots(inputs)],
|
|
141
|
+
progress_message = "Making amalgamation",
|
|
142
|
+
executable = ctx.executable._amalgamator,
|
|
143
|
+
)
|
|
144
|
+
return []
|
|
145
|
+
|
|
146
|
+
upb_amalgamation = rule(
|
|
147
|
+
attrs = {
|
|
148
|
+
"_amalgamator": attr.label(
|
|
149
|
+
executable = True,
|
|
150
|
+
cfg = "exec",
|
|
151
|
+
default = "//bazel:amalgamate",
|
|
152
|
+
),
|
|
153
|
+
"prefix": attr.string(
|
|
154
|
+
default = "",
|
|
155
|
+
),
|
|
156
|
+
"libs": attr.label_list(aspects = [_file_list_aspect]),
|
|
157
|
+
"outs": attr.output_list(),
|
|
158
|
+
},
|
|
159
|
+
implementation = _upb_amalgamation,
|
|
160
|
+
)
|
|
@@ -0,0 +1,127 @@
|
|
|
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
|
+
package(
|
|
27
|
+
default_visibility = ["//visibility:public"],
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
cc_library(
|
|
31
|
+
name = "liblua_headers",
|
|
32
|
+
hdrs = [
|
|
33
|
+
"src/lauxlib.h",
|
|
34
|
+
"src/lua.h",
|
|
35
|
+
"src/lua.hpp",
|
|
36
|
+
"src/luaconf.h",
|
|
37
|
+
"src/lualib.h",
|
|
38
|
+
],
|
|
39
|
+
defines = ["LUA_USE_LINUX"],
|
|
40
|
+
includes = ["src"],
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
cc_library(
|
|
44
|
+
name = "liblua",
|
|
45
|
+
srcs = [
|
|
46
|
+
"src/lapi.c",
|
|
47
|
+
"src/lapi.h",
|
|
48
|
+
"src/lauxlib.c",
|
|
49
|
+
"src/lauxlib.h",
|
|
50
|
+
"src/lbaselib.c",
|
|
51
|
+
"src/lbitlib.c",
|
|
52
|
+
"src/lcode.c",
|
|
53
|
+
"src/lcode.h",
|
|
54
|
+
"src/lcorolib.c",
|
|
55
|
+
"src/lctype.c",
|
|
56
|
+
"src/lctype.h",
|
|
57
|
+
"src/ldblib.c",
|
|
58
|
+
"src/ldebug.c",
|
|
59
|
+
"src/ldebug.h",
|
|
60
|
+
"src/ldo.c",
|
|
61
|
+
"src/ldo.h",
|
|
62
|
+
"src/ldump.c",
|
|
63
|
+
"src/lfunc.c",
|
|
64
|
+
"src/lfunc.h",
|
|
65
|
+
"src/lgc.c",
|
|
66
|
+
"src/lgc.h",
|
|
67
|
+
"src/linit.c",
|
|
68
|
+
"src/liolib.c",
|
|
69
|
+
"src/llex.c",
|
|
70
|
+
"src/llex.h",
|
|
71
|
+
"src/llimits.h",
|
|
72
|
+
"src/lmathlib.c",
|
|
73
|
+
"src/lmem.c",
|
|
74
|
+
"src/lmem.h",
|
|
75
|
+
"src/loadlib.c",
|
|
76
|
+
"src/lobject.c",
|
|
77
|
+
"src/lobject.h",
|
|
78
|
+
"src/lopcodes.c",
|
|
79
|
+
"src/lopcodes.h",
|
|
80
|
+
"src/loslib.c",
|
|
81
|
+
"src/lparser.c",
|
|
82
|
+
"src/lparser.h",
|
|
83
|
+
"src/lstate.c",
|
|
84
|
+
"src/lstate.h",
|
|
85
|
+
"src/lstring.c",
|
|
86
|
+
"src/lstring.h",
|
|
87
|
+
"src/lstrlib.c",
|
|
88
|
+
"src/ltable.c",
|
|
89
|
+
"src/ltable.h",
|
|
90
|
+
"src/ltablib.c",
|
|
91
|
+
"src/ltm.c",
|
|
92
|
+
"src/ltm.h",
|
|
93
|
+
"src/lundump.c",
|
|
94
|
+
"src/lundump.h",
|
|
95
|
+
"src/lvm.c",
|
|
96
|
+
"src/lvm.h",
|
|
97
|
+
"src/lzio.c",
|
|
98
|
+
"src/lzio.h",
|
|
99
|
+
],
|
|
100
|
+
hdrs = [
|
|
101
|
+
"src/lauxlib.h",
|
|
102
|
+
"src/lua.h",
|
|
103
|
+
"src/lua.hpp",
|
|
104
|
+
"src/luaconf.h",
|
|
105
|
+
"src/lualib.h",
|
|
106
|
+
],
|
|
107
|
+
defines = ["LUA_USE_LINUX"],
|
|
108
|
+
includes = ["src"],
|
|
109
|
+
linkopts = [
|
|
110
|
+
"-lm",
|
|
111
|
+
"-ldl",
|
|
112
|
+
],
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
cc_binary(
|
|
116
|
+
name = "lua",
|
|
117
|
+
srcs = [
|
|
118
|
+
"src/lua.c",
|
|
119
|
+
],
|
|
120
|
+
linkopts = [
|
|
121
|
+
"-lreadline",
|
|
122
|
+
"-rdynamic",
|
|
123
|
+
],
|
|
124
|
+
deps = [
|
|
125
|
+
":liblua",
|
|
126
|
+
],
|
|
127
|
+
)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
--- BUILD.bazel
|
|
2
|
+
+++ BUILD.bazel
|
|
3
|
+
@@ -896,6 +896,10 @@ py_library(
|
|
4
|
+
[
|
|
5
|
+
"python/google/protobuf/**/*.py",
|
|
6
|
+
],
|
|
7
|
+
+ exclude = [
|
|
8
|
+
+ "python/google/protobuf/internal/*_test.py",
|
|
9
|
+
+ "python/google/protobuf/internal/test_util.py",
|
|
10
|
+
+ ]
|
|
11
|
+
),
|
|
12
|
+
imports = ["python"],
|
|
13
|
+
srcs_version = "PY2AND3",
|
|
14
|
+
|
|
15
|
+
--- python/google/protobuf/internal/test_util.py
|
|
16
|
+
+++ python/google/protobuf/internal/test_util.py
|
|
17
|
+
@@ -39,6 +39,7 @@ __author__ = 'robinson@google.com (Will Robinson)'
|
|
18
|
+
import numbers
|
|
19
|
+
import operator
|
|
20
|
+
import os.path
|
|
21
|
+
+import pathlib
|
|
22
|
+
|
|
23
|
+
from google.protobuf import unittest_import_pb2
|
|
24
|
+
from google.protobuf import unittest_pb2
|
|
25
|
+
@@ -617,17 +618,22 @@ def ExpectAllFieldsSet(test_case, message):
|
|
26
|
+
message.default_import_enum)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
+def _SearchUp(path, filename):
|
|
30
|
+
+ path = pathlib.Path(path).resolve()
|
|
31
|
+
+ for parent in [path] + list(path.parents):
|
|
32
|
+
+ file_path = parent / ('src/google/protobuf/testdata/' + filename)
|
|
33
|
+
+ if file_path.exists():
|
|
34
|
+
+ # Found it. Load the golden file from the testdata directory.
|
|
35
|
+
+ return file_path.open('rb')
|
|
36
|
+
+ return None
|
|
37
|
+
+
|
|
38
|
+
def GoldenFile(filename):
|
|
39
|
+
"""Finds the given golden file and returns a file object representing it."""
|
|
40
|
+
|
|
41
|
+
# Search up the directory tree looking for the C++ protobuf source code.
|
|
42
|
+
- path = '.'
|
|
43
|
+
- while os.path.exists(path):
|
|
44
|
+
- if os.path.exists(os.path.join(path, 'src/google/protobuf')):
|
|
45
|
+
- # Found it. Load the golden file from the testdata directory.
|
|
46
|
+
- full_path = os.path.join(path, 'src/google/protobuf/testdata', filename)
|
|
47
|
+
- return open(full_path, 'rb')
|
|
48
|
+
- path = os.path.join(path, '..')
|
|
49
|
+
+ f = _SearchUp('.', filename) or _SearchUp(__file__, filename)
|
|
50
|
+
+ if f:
|
|
51
|
+
+ return f
|
|
52
|
+
|
|
53
|
+
# Search internally.
|
|
54
|
+
path = '.'
|
|
@@ -0,0 +1,137 @@
|
|
|
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
|
+
"""An implementation of py_proto_library().
|
|
27
|
+
|
|
28
|
+
We have to implement this ourselves because there is currently no reasonable
|
|
29
|
+
py_proto_library() rule available for Bazel.
|
|
30
|
+
|
|
31
|
+
Our py_proto_library() is similar to how a real py_proto_library() should work.
|
|
32
|
+
But it hasn't been deeply tested or reviewed, and upb should not be in the
|
|
33
|
+
business of vending py_proto_library(), so we keep it private to upb.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
load("@bazel_skylib//lib:paths.bzl", "paths")
|
|
37
|
+
|
|
38
|
+
# begin:github_only
|
|
39
|
+
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
|
|
40
|
+
# end:github_only
|
|
41
|
+
|
|
42
|
+
# Generic support code #########################################################
|
|
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
|
+
# py_proto_library() ###########################################################
|
|
73
|
+
|
|
74
|
+
def _py_proto_library_rule_impl(ctx):
|
|
75
|
+
# A real py_proto_library() should enforce this constraint.
|
|
76
|
+
# We don't bother for now, since it saves us some effort not to.
|
|
77
|
+
#
|
|
78
|
+
# if len(ctx.attr.deps) != 1:
|
|
79
|
+
# fail("only one deps dependency allowed.")
|
|
80
|
+
|
|
81
|
+
files = []
|
|
82
|
+
for dep in ctx.attr.deps:
|
|
83
|
+
files += dep[PyInfo].transitive_sources.to_list()
|
|
84
|
+
return [
|
|
85
|
+
DefaultInfo(files = depset(direct = files)),
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
def _py_proto_library_aspect_impl(target, ctx):
|
|
89
|
+
proto_info = target[ProtoInfo]
|
|
90
|
+
proto_sources = proto_info.direct_sources
|
|
91
|
+
srcs = [_generate_output_file(ctx, name, "_pb2.py") for name in proto_sources]
|
|
92
|
+
transitive_sets = proto_info.transitive_descriptor_sets.to_list()
|
|
93
|
+
ctx.actions.run(
|
|
94
|
+
inputs = depset(
|
|
95
|
+
direct = [proto_info.direct_descriptor_set],
|
|
96
|
+
transitive = [proto_info.transitive_descriptor_sets],
|
|
97
|
+
),
|
|
98
|
+
outputs = srcs,
|
|
99
|
+
executable = ctx.executable._protoc,
|
|
100
|
+
arguments = [
|
|
101
|
+
"--python_out=" + _get_real_root(srcs[0]),
|
|
102
|
+
"--descriptor_set_in=" + ctx.configuration.host_path_separator.join([f.path for f in transitive_sets]),
|
|
103
|
+
] +
|
|
104
|
+
[_get_real_short_path(file) for file in proto_sources],
|
|
105
|
+
progress_message = "Generating Python protos for :" + ctx.label.name,
|
|
106
|
+
)
|
|
107
|
+
outs_depset = depset(srcs)
|
|
108
|
+
return [
|
|
109
|
+
PyInfo(transitive_sources = outs_depset),
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
_py_proto_library_aspect = aspect(
|
|
113
|
+
attrs = {
|
|
114
|
+
"_protoc": attr.label(
|
|
115
|
+
executable = True,
|
|
116
|
+
cfg = "exec",
|
|
117
|
+
default = "@com_google_protobuf//:protoc",
|
|
118
|
+
),
|
|
119
|
+
},
|
|
120
|
+
implementation = _py_proto_library_aspect_impl,
|
|
121
|
+
provides = [
|
|
122
|
+
PyInfo,
|
|
123
|
+
],
|
|
124
|
+
attr_aspects = ["deps"],
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
py_proto_library = rule(
|
|
128
|
+
output_to_genfiles = True,
|
|
129
|
+
implementation = _py_proto_library_rule_impl,
|
|
130
|
+
attrs = {
|
|
131
|
+
"deps": attr.label_list(
|
|
132
|
+
aspects = [_py_proto_library_aspect],
|
|
133
|
+
allow_rules = ["proto_library"],
|
|
134
|
+
providers = [ProtoInfo],
|
|
135
|
+
),
|
|
136
|
+
},
|
|
137
|
+
)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""Helper methods to download different python versions"""
|
|
2
|
+
|
|
3
|
+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|
4
|
+
|
|
5
|
+
limited_api_build_file = """
|
|
6
|
+
cc_library(
|
|
7
|
+
name = "python_headers",
|
|
8
|
+
hdrs = glob(["**/Include/**/*.h"]),
|
|
9
|
+
strip_include_prefix = "Python-{}/Include",
|
|
10
|
+
visibility = ["//visibility:public"],
|
|
11
|
+
)
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def python_source_archive(name, sha256):
|
|
15
|
+
"""Helper method to create a python_headers target that will work for linux and macos.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
name: The name of the target, should be in the form python_{VERSION}
|
|
19
|
+
sha256: The sha256 of the python package for the specified version
|
|
20
|
+
"""
|
|
21
|
+
version = name.split("-")[1]
|
|
22
|
+
http_archive(
|
|
23
|
+
name = name,
|
|
24
|
+
urls = [
|
|
25
|
+
"https://www.python.org/ftp/python/{0}/Python-{0}.tgz"
|
|
26
|
+
.format(version),
|
|
27
|
+
],
|
|
28
|
+
sha256 = sha256,
|
|
29
|
+
build_file_content = limited_api_build_file.format(version),
|
|
30
|
+
patch_cmds = [
|
|
31
|
+
"echo '#define SIZEOF_WCHAR_T 4' > Python-{}/Include/pyconfig.h"
|
|
32
|
+
.format(version),
|
|
33
|
+
],
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
nuget_build_file = """
|
|
37
|
+
cc_import(
|
|
38
|
+
name = "python_full_api",
|
|
39
|
+
hdrs = glob(["**/*.h"]),
|
|
40
|
+
shared_library = "python{0}.dll",
|
|
41
|
+
interface_library = "libs/python{0}.lib",
|
|
42
|
+
visibility = ["@upb//python:__pkg__"],
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
cc_import(
|
|
46
|
+
name = "python_limited_api",
|
|
47
|
+
hdrs = glob(["**/*.h"]),
|
|
48
|
+
shared_library = "python{1}.dll",
|
|
49
|
+
interface_library = "libs/python{1}.lib",
|
|
50
|
+
visibility = ["@upb//python:__pkg__"],
|
|
51
|
+
)
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
def python_nuget_package(name, sha256):
|
|
55
|
+
"""Helper method to create full and limited api dependencies for windows using nuget
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
name: The name of the target, should be in the form nuget_python_{CPU}_{VERSION}
|
|
59
|
+
sha256: The sha256 of the nuget package for that version
|
|
60
|
+
"""
|
|
61
|
+
cpu = name.split("_")[2]
|
|
62
|
+
version = name.split("_")[3]
|
|
63
|
+
|
|
64
|
+
full_api_lib_number = version.split(".")[0] + version.split(".")[1]
|
|
65
|
+
limited_api_lib_number = version.split(".")[0]
|
|
66
|
+
|
|
67
|
+
folder_name_dict = {
|
|
68
|
+
"i686": "pythonx86",
|
|
69
|
+
"x86-64": "python",
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
http_archive(
|
|
73
|
+
name = name,
|
|
74
|
+
urls = [
|
|
75
|
+
"https://www.nuget.org/api/v2/package/{}/{}"
|
|
76
|
+
.format(folder_name_dict[cpu], version),
|
|
77
|
+
],
|
|
78
|
+
sha256 = sha256,
|
|
79
|
+
strip_prefix = "tools",
|
|
80
|
+
build_file_content =
|
|
81
|
+
nuget_build_file.format(full_api_lib_number, limited_api_lib_number),
|
|
82
|
+
type = "zip",
|
|
83
|
+
patch_cmds = ["cp -r include/* ."],
|
|
84
|
+
)
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
"""Repository rule for using Python 3.x headers from the system."""
|
|
27
|
+
|
|
28
|
+
_build_file = """
|
|
29
|
+
load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair")
|
|
30
|
+
|
|
31
|
+
cc_library(
|
|
32
|
+
name = "python_headers",
|
|
33
|
+
hdrs = glob(["python/**/*.h"]),
|
|
34
|
+
includes = ["python"],
|
|
35
|
+
visibility = ["//visibility:public"],
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
py_runtime(
|
|
39
|
+
name = "py3_runtime",
|
|
40
|
+
interpreter_path = "{}",
|
|
41
|
+
python_version = "PY3",
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
py_runtime_pair(
|
|
45
|
+
name = "runtime_pair",
|
|
46
|
+
py3_runtime = ":py3_runtime",
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
toolchain(
|
|
50
|
+
name = "python_toolchain",
|
|
51
|
+
toolchain = ":runtime_pair",
|
|
52
|
+
toolchain_type = "@rules_python//python:toolchain_type",
|
|
53
|
+
)
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
def _get_python_version(repository_ctx):
|
|
57
|
+
py_program = "import sys; print(str(sys.version_info.major) + str(sys.version_info.minor))"
|
|
58
|
+
result = repository_ctx.execute(["python3", "-c", py_program])
|
|
59
|
+
return (result.stdout).strip()
|
|
60
|
+
|
|
61
|
+
def _get_config_var(repository_ctx, name):
|
|
62
|
+
py_program = "import sysconfig; print(sysconfig.get_config_var('%s'), end='')"
|
|
63
|
+
result = repository_ctx.execute(["python3", "-c", py_program % (name)])
|
|
64
|
+
if result.return_code != 0:
|
|
65
|
+
return None
|
|
66
|
+
return result.stdout
|
|
67
|
+
|
|
68
|
+
def _python_headers_impl(repository_ctx):
|
|
69
|
+
path = _get_config_var(repository_ctx, "INCLUDEPY")
|
|
70
|
+
if not path:
|
|
71
|
+
# buildifier: disable=print
|
|
72
|
+
print("WARNING: no system python available, builds against system python will fail")
|
|
73
|
+
repository_ctx.file("BUILD.bazel", "")
|
|
74
|
+
repository_ctx.file("version.bzl", "SYSTEM_PYTHON_VERSION = None")
|
|
75
|
+
return
|
|
76
|
+
repository_ctx.symlink(path, "python")
|
|
77
|
+
python3 = repository_ctx.which("python3")
|
|
78
|
+
python_version = _get_python_version(repository_ctx)
|
|
79
|
+
repository_ctx.file("BUILD.bazel", _build_file.format(python3))
|
|
80
|
+
repository_ctx.file("version.bzl", "SYSTEM_PYTHON_VERSION = '{}'".format(python_version))
|
|
81
|
+
|
|
82
|
+
# The system_python() repository rule exposes Python headers from the system.
|
|
83
|
+
#
|
|
84
|
+
# In WORKSPACE:
|
|
85
|
+
# system_python(
|
|
86
|
+
# name = "system_python_repo",
|
|
87
|
+
# )
|
|
88
|
+
#
|
|
89
|
+
# This repository exposes a single rule that you can depend on from BUILD:
|
|
90
|
+
# cc_library(
|
|
91
|
+
# name = "foobar",
|
|
92
|
+
# srcs = ["foobar.cc"],
|
|
93
|
+
# deps = ["@system_python_repo//:python_headers"],
|
|
94
|
+
# )
|
|
95
|
+
#
|
|
96
|
+
# The headers should correspond to the version of python obtained by running
|
|
97
|
+
# the `python3` command on the system.
|
|
98
|
+
system_python = repository_rule(
|
|
99
|
+
implementation = _python_headers_impl,
|
|
100
|
+
local = True,
|
|
101
|
+
)
|