diff --git a/math/py-or-tools/files/patch-protobuf b/math/py-or-tools/files/patch-protobuf new file mode 100644 index 000000000000..f8fa931455b5 --- /dev/null +++ b/math/py-or-tools/files/patch-protobuf @@ -0,0 +1,49 @@ +Obtained from: https://github.com/google/or-tools/commit/4cbd27dae94609e1c9413e4c4614c250758f9d9e + https://github.com/google/or-tools/commit/516a777f55e66caf70c27ad7e81f7d8850d36079 + +--- ortools/base/file.cc.orig 2023-11-13 09:51:25 UTC ++++ ortools/base/file.cc +@@ -224,7 +224,8 @@ class NoOpErrorCollector : public google::protobuf::io + namespace { + class NoOpErrorCollector : public google::protobuf::io::ErrorCollector { + public: +- void AddError(int line, int column, const std::string& message) override {} ++ void RecordError(int /*line*/, int /*column*/, ++ absl::string_view /*message*/) override {} + }; + } // namespace + +--- ortools/util/file_util.cc.orig 2023-11-13 09:51:25 UTC ++++ ortools/util/file_util.cc +@@ -137,7 +137,7 @@ bool WriteProtoToFile(absl::string_view filename, + case ProtoWriteFormat::kJson: { + google::protobuf::util::JsonPrintOptions options; + options.add_whitespace = true; +- options.always_print_primitive_fields = true; ++ options.always_print_fields_with_no_presence = true; + options.preserve_proto_field_names = true; + if (!google::protobuf::util::MessageToJsonString(proto, &output_string, + options) +--- ortools/util/parse_proto.cc.orig 2023-11-13 09:51:25 UTC ++++ ortools/util/parse_proto.cc +@@ -36,11 +36,16 @@ class TextFormatErrorCollector : public google::protob + TextFormatErrorCollector() = default; + ~TextFormatErrorCollector() override = default; + +- void AddError(int line, int column, const std::string& message) override { +- collected_errors_.push_back({false, line, column, message}); ++ void RecordError(const int line, const int column, ++ absl::string_view message) override { ++ collected_errors_.push_back( ++ {/*warning=*/false, line, column, std::string(message)}); + } +- void AddWarning(int line, int column, const std::string& message) override { +- collected_errors_.push_back({true, line, column, message}); ++ ++ void RecordWarning(const int line, const int column, ++ absl::string_view message) override { ++ collected_errors_.push_back( ++ {/*warning=*/true, line, column, std::string(message)}); + } + + // Returns a string listing each collected error. When an error is associated