From 56672cdb911a61c41197e9c14907bbb14fb742e9 Mon Sep 17 00:00:00 2001 From: Eric Salo Date: Fri, 29 Dec 2023 12:07:23 -0800 Subject: [PATCH] upb: create upb/dart/ for Dart FFI code written in C PiperOrigin-RevId: 594483803 --- google3/third_party/upb/dart/BUILD | 41 +++++++++++++++++++++++++++ google3/third_party/upb/dart/upb_so.c | 21 ++++++++++++++ upb/BUILD | 22 -------------- upb/upb_so.c | 19 ------------- 4 files changed, 62 insertions(+), 41 deletions(-) create mode 100644 google3/third_party/upb/dart/BUILD create mode 100644 google3/third_party/upb/dart/upb_so.c delete mode 100644 upb/upb_so.c diff --git a/google3/third_party/upb/dart/BUILD b/google3/third_party/upb/dart/BUILD new file mode 100644 index 0000000000000..1182ad3756e5e --- /dev/null +++ b/google3/third_party/upb/dart/BUILD @@ -0,0 +1,41 @@ +# Copyright (c) 2009-2021, Google LLC +# All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +load("//bazel:build_defs.bzl", "UPB_DEFAULT_COPTS") + +# begin:google_only +# package(default_applicable_licenses = ["//upb:license"]) +# end:google_only + +# This library contains the upb functions called by the Dart FFI runtime. +cc_library( + name = "libupb", + srcs = [":libupb.so"], + linkstatic = 1, + visibility = ["//third_party/dart/pb_runtime:__pkg__"], +) + +# Weirdly, the Dart ffigen tool needs a cc_binary() target, not a cc_library(). +cc_binary( + name = "libupb.so", + srcs = ["upb_so.c"], + copts = UPB_DEFAULT_COPTS, + linkshared = 1, + linkstatic = 1, + visibility = ["//third_party/dart/pb_runtime:__pkg__"], + deps = [ + "//upb:mem", + "//upb:message", + "//upb:message_accessors", + "//upb:message_compare", + "//upb:message_split64", + "//upb:mini_descriptor", + "//upb:mini_table", + "//upb:port", + "//upb:wire", + ], +) diff --git a/google3/third_party/upb/dart/upb_so.c b/google3/third_party/upb/dart/upb_so.c new file mode 100644 index 0000000000000..4d7fb8dfdad9d --- /dev/null +++ b/google3/third_party/upb/dart/upb_so.c @@ -0,0 +1,21 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +// These headers form a spanning tree for the upb defs needed by the Dart FFI. + +#define UPB_BUILD_API + +// IWYU pragma: begin_exports +#include "third_party/upb/upb/message/accessors_split64.h" +#include "third_party/upb/upb/message/array_split64.h" +#include "third_party/upb/upb/message/compare.h" +#include "third_party/upb/upb/message/map.h" +#include "third_party/upb/upb/message/message.h" +#include "third_party/upb/upb/mini_descriptor/decode.h" +#include "third_party/upb/upb/wire/decode.h" +#include "third_party/upb/upb/wire/encode.h" +// IWYU pragma: end_exports diff --git a/upb/BUILD b/upb/BUILD index 13047648e5bcb..c9c8033254c6c 100644 --- a/upb/BUILD +++ b/upb/BUILD @@ -312,28 +312,6 @@ alias( visibility = ["//visibility:public"], ) -# Internal C/C++ libraries ##################################################### - -cc_binary( - name = "libupb.so", - srcs = ["upb_so.c"], - copts = UPB_DEFAULT_COPTS + ["-DUPB_BUILD_API"], - linkshared = 1, - linkstatic = 1, - visibility = ["//visibility:public"], - deps = [ - ":mem", - ":message", - ":message_accessors", - ":message_compare", - ":message_split64", - ":mini_descriptor", - ":mini_table", - ":port", - ":wire", - ], -) - # Amalgamation ################################################################# # begin:github_only diff --git a/upb/upb_so.c b/upb/upb_so.c deleted file mode 100644 index a8769ab79d7d4..0000000000000 --- a/upb/upb_so.c +++ /dev/null @@ -1,19 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2023 Google LLC. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd - -// These headers form a spanning tree for the upb defs needed by FFI layers. - -// IWYU pragma: begin_exports -#include "upb/message/accessors_split64.h" -#include "upb/message/array_split64.h" -#include "upb/message/compare.h" -#include "upb/message/map.h" -#include "upb/message/message.h" -#include "upb/mini_descriptor/decode.h" -#include "upb/wire/decode.h" -#include "upb/wire/encode.h" -// IWYU pragma: end_exports