upb: use google3 ffigen to build the upbdev function wrappers

PiperOrigin-RevId: 527372793
pull/13171/head
Eric Salo 2 years ago committed by Copybara-Service
parent b32938176d
commit 3a0e3f22cd
  1. 33
      upbc/BUILD
  2. 1
      upbc/upbc_so.c
  3. 9
      upbc/upbdev.c
  4. 5
      upbc/upbdev.h

@ -104,7 +104,6 @@ cc_binary(
"//:message_accessors",
"//:mini_table",
"//:port",
"//upbc:upbdev",
],
)
@ -206,6 +205,21 @@ bootstrap_cc_library(
],
)
cc_library(
name = "upbdev_ffi_headers",
srcs = [
"upbdev.h",
],
copts = ["-DUPB_BUILD_API"],
visibility = ["//visibility:public"],
deps = [
":upbdev",
"//:base",
"//:mem",
"//:port",
],
)
cc_library(
name = "upbdev",
srcs = [
@ -217,7 +231,7 @@ cc_library(
"upbdev.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
visibility = ["//visibility:private"],
deps = [
":code_generator_request_upb_proto",
":code_generator_request_upb_proto_reflection",
@ -232,6 +246,21 @@ cc_library(
],
)
cc_binary(
name = "lib/libupbdev.so",
linkshared = 1,
visibility = ["//visibility:private"],
deps = [
":upbdev",
],
)
cc_library(
name = "libupbdev",
srcs = [":lib/libupbdev.so"],
visibility = ["//visibility:public"],
)
bootstrap_cc_binary(
name = "protoc-gen-upb",
srcs = ["protoc-gen-upb.cc"],

@ -36,7 +36,6 @@
#include "upb/message/accessors.h"
#include "upb/message/message.h"
#include "upb/mini_table/decode.h"
#include "upbc/upbdev.h"
// Must be last.
#include "upb/port/def.inc"

@ -92,10 +92,9 @@ upb_StringView upbdev_ProcessInput(const char* buf, size_t size,
const upbc_CodeGeneratorRequest* outer_request =
upbc_MakeCodeGeneratorRequest(inner_request, arena, status);
if (upb_Status_IsOk(status))
out = upbc_JsonEncode(outer_request, arena, status);
if (!upb_Status_IsOk(status)) return out;
return out;
return upbc_JsonEncode(outer_request, arena, status);
}
upb_StringView upbdev_ProcessOutput(const char* buf, size_t size,
@ -126,3 +125,7 @@ void upbdev_ProcessStdout(const char* buf, size_t size, upb_Arena* arena,
}
}
}
upb_Arena* upbdev_Arena_New() { return upb_Arena_New(); }
void upbdev_Status_Clear(upb_Status* status) { upb_Status_Clear(status); }

@ -54,6 +54,11 @@ UPB_API upb_StringView upbdev_ProcessOutput(const char* buf, size_t size,
UPB_API void upbdev_ProcessStdout(const char* buf, size_t size,
upb_Arena* arena, upb_Status* status);
// The following wrappers allow the protoc plugins to call the above functions
// without pulling in the entire pb_runtime library.
UPB_API upb_Arena* upbdev_Arena_New();
UPB_API void upbdev_Status_Clear(upb_Status* status);
#ifdef __cplusplus
} /* extern "C" */
#endif

Loading…
Cancel
Save