Removed upb dependencies on absl/log.

absl/log is not yet released in any ABSL LTS.

PiperOrigin-RevId: 501965150
pull/13171/head
Joshua Haberman 2 years ago committed by Copybara-Service
parent aaf9e43e4f
commit 4f02fc4790
  1. 3
      protos_generator/BUILD
  2. 12
      protos_generator/gen_utils.cc
  3. 5
      protos_generator/output.h
  4. 4
      upbc/BUILD
  5. 17
      upbc/plugin.h
  6. 8
      upbc/protoc-gen-upb.cc

@ -69,11 +69,10 @@ cc_library(
"//upbc:file_layout",
"//upbc:keywords",
"//upbc:names",
"//upbc:plugin",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings",
"@com_google_protobuf//:protobuf",
"@com_google_protobuf//src/google/protobuf/compiler:code_generator",

@ -31,11 +31,11 @@
#include "absl/strings/str_cat.h"
// begin:google_only
// #include "absl/log/check.h"
// #include "absl/strings/str_replace.h"
// end:google_only
#include "absl/strings/str_split.h"
#include "upbc/keywords.h"
#include "upbc/plugin.h"
namespace protos_generator {
@ -44,9 +44,13 @@ namespace protobuf = ::google::protobuf;
// begin:github_only
#ifndef DCHECK
#ifndef NDEBUG
#define DCHECK(condition) if(!(condition)) LOG(FATAL);
#define DCHECK(condition) \
if (!(condition)) { \
upbc::LogFatal("Failed DCHECK: ", #condition, "File: ", __FILE__, \
", Line: ", __LINE__); \
}
#else
#define DCHECK(condition) if(!(true || condition)) LOG(FATAL);
#define DCHECK(condition) if(!(true || condition)) ;
#endif
#endif
// end:github_only
@ -162,7 +166,7 @@ std::string CppTypeInternal(const protobuf::FieldDescriptor* field,
case protobuf::FieldDescriptor::CPPTYPE_STRING:
return "absl::string_view";
default:
LOG(FATAL) << "Unexpected type: " << field->cpp_type();
upbc::LogFatal("Unexpected type: ", field->cpp_type());
}
}

@ -30,12 +30,11 @@
#include <vector>
#include "absl/base/log_severity.h"
#include "absl/log/log.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/substitute.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/io/zero_copy_stream.h"
#include "upbc/plugin.h"
namespace protos_generator {
@ -58,7 +57,7 @@ class Output {
void Outdent() { Outdent(kIndentationSize); }
void Outdent(size_t size) {
if (indent_ < size) {
LOG(FATAL) << "mismatched Output indent/unindent calls";
upbc::LogFatal("mismatched Output indent/unindent calls");
}
indent_ -= size;
}

@ -178,8 +178,6 @@ bootstrap_cc_library(
deps = [
"//:port",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings",
],
)
@ -252,8 +250,6 @@ bootstrap_cc_binary(
"//:wire_types",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings",
],
)

@ -45,7 +45,6 @@
// end:github_only
#include "absl/container/flat_hash_set.h"
#include "absl/log/log.h"
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include "upb/reflection/def.hpp"
@ -72,6 +71,12 @@ inline std::vector<std::pair<std::string, std::string>> ParseGeneratorParameter(
return ret;
}
template <class... Arg>
void LogFatal(const Arg&... arg) {
fprintf(stderr, "FATAL ERROR: %s\n", absl::StrCat(arg...).c_str());
exit(1);
}
class Plugin {
public:
Plugin() { ReadRequest(); }
@ -113,8 +118,8 @@ class Plugin {
if (!file) {
absl::string_view name =
ToStringView(UPB_DESC(FileDescriptorProto_name)(file_proto));
LOG(FATAL) << "Couldn't add file " << name
<< " to DefPool: " << status.error_message();
LogFatal("Couldn't add file ", name,
" to DefPool: ", status.error_message());
}
if (generate) func(file);
});
@ -169,7 +174,7 @@ class Plugin {
request_ = UPB_DESC(compiler_CodeGeneratorRequest_parse)(
data.data(), data.size(), arena_.ptr());
if (!request_) {
LOG(FATAL) << "Failed to parse CodeGeneratorRequest";
LogFatal("Failed to parse CodeGeneratorRequest");
}
response_ = UPB_DESC(compiler_CodeGeneratorResponse_new)(arena_.ptr());
UPB_DESC(compiler_CodeGeneratorResponse_set_supported_features)
@ -182,11 +187,11 @@ class Plugin {
char* serialized = UPB_DESC(compiler_CodeGeneratorResponse_serialize)(
response_, arena_.ptr(), &size);
if (!serialized) {
LOG(FATAL) << "Failed to serialize CodeGeneratorResponse";
LogFatal("Failed to serialize CodeGeneratorResponse");
}
if (fwrite(serialized, 1, size, stdout) != size) {
LOG(FATAL) << "Failed to write response to stdout";
LogFatal("Failed to write response to stdout");
}
}
};

@ -43,8 +43,6 @@
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/escaping.h"
#include "absl/strings/string_view.h"
#include "absl/strings/substitute.h"
@ -1262,7 +1260,7 @@ std::string FieldInitializer(upb::FieldDefPtr field,
const upb_MiniTableField* field32,
const Options& options) {
if (options.bootstrap) {
CHECK(!field.is_extension());
if (field.is_extension()) LogFatal("Should not be an extension");
return absl::Substitute(
"*upb_MiniTable_FindFieldByNumber($0, $1)",
MessageMiniTableRef(field.containing_type(), options), field.number());
@ -1679,8 +1677,8 @@ int main(int argc, char** argv) {
if (!file) {
absl::string_view name =
upbc::ToStringView(UPB_DESC(FileDescriptorProto_name)(file_proto));
LOG(FATAL) << "Couldn't add file " << name
<< " to DefPool: " << status.error_message();
upbc::LogFatal("Couldn't add file ", name,
" to DefPool: ", status.error_message());
}
if (generate) GenerateFile(pools, file, options, &plugin);
});

Loading…
Cancel
Save