Skip to content

Commit

Permalink
upb: create upb/dart/ for Dart FFI code written in C
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 594483803
  • Loading branch information
ericsalo authored and copybara-github committed Dec 29, 2023
1 parent 6e25bb8 commit 56672cd
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 41 deletions.
41 changes: 41 additions & 0 deletions google3/third_party/upb/dart/BUILD
Original file line number Diff line number Diff line change
@@ -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",
],
)
21 changes: 21 additions & 0 deletions google3/third_party/upb/dart/upb_so.c
Original file line number Diff line number Diff line change
@@ -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
22 changes: 0 additions & 22 deletions upb/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 0 additions & 19 deletions upb/upb_so.c

This file was deleted.

0 comments on commit 56672cd

Please sign in to comment.