Generate proto bindings during build for macOS.

PiperOrigin-RevId: 852489495
This commit is contained in:
Francis Tsui
2026-01-05 15:59:43 -08:00
committed by Copybara-Service
parent 877fcf8cd8
commit 6cc697cc56
3 changed files with 162 additions and 35 deletions
+43
View File
@@ -0,0 +1,43 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: 'Setup protobuf for swift build'
description: 'Composite action to setup protobuf for swift build'
runs:
using: "composite"
steps:
- name: sync protobuf repo
uses: actions/checkout@v6
with:
repository: protocolbuffers/protobuf
ref: v33.2
path: google-protobuf
- name: install protoc
run: |
brew install protobuf
protoc --version
shell: bash
- name: generate nearby proto bindings
run: |
mkdir protoc_out
protoc --cpp_out=protoc_out connections/implementation/proto/offline_wire_formats.proto internal/proto/analytics/connections_log.proto internal/proto/credential.proto internal/proto/local_credential.proto internal/proto/metadata.proto proto/errorcode/error_code_enums.proto proto/mediums/ble_frames.proto proto/mediums/multiplex_frames.proto proto/mediums/nfc_frames.proto proto/mediums/web_rtc_signaling_frames.proto proto/connections_enums.proto proto/sharing_enums.proto sharing/proto/analytics/nearby_sharing_log.proto
ls -lR protoc_out
shell: bash
- name: generate ukey2 proto bindings
run: |
cd third_party/ukey2
mkdir protoc_out
protoc --cpp_out=protoc_out --proto_path=ukey2 ukey2/src/main/proto/device_to_device_messages.proto ukey2/src/main/proto/securegcm.proto ukey2/src/main/proto/securemessage.proto ukey2/src/main/proto/ukey.proto
ls -lR protoc_out
shell: bash
+10 -6
View File
@@ -24,9 +24,12 @@ jobs:
name: Build Swift
runs-on: macOS-latest
steps:
- uses: actions/checkout@v3
- name: sync repo
uses: actions/checkout@v6
with:
submodules: true
- name: setup protobuf
uses: ./.github/actions/swift-protobuf
- name: Build
run: swift build
@@ -34,9 +37,11 @@ jobs:
name: Test Swift
runs-on: macOS-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
with:
submodules: true
- name: setup protobuf
uses: ./.github/actions/swift-protobuf
- name: Test
run: swift test
@@ -44,21 +49,20 @@ jobs:
name: Build Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Build Connections
run: CC=clang-16 CXX=clang-16++ bazel build --proto_compiler=@com_github_protobuf_prebuilt//:protoc --copt='-DGITHUB_BUILD' //connections:core
- name: Build Presence
run: CC=clang-16 CXX=clang-16++ bazel build --proto_compiler=@com_github_protobuf_prebuilt//:protoc --copt='-DGITHUB_BUILD' //presence
- name: Build Sharing
run: CC=clang-16 CXX=clang-16++ bazel build --proto_compiler=@com_github_protobuf_prebuilt//:protoc --verbose_failures --copt='-DGITHUB_BUILD' //sharing/proto/... //sharing/analytics
run: CC=clang-16 CXX=clang-16++ bazel build --proto_compiler=@com_github_protobuf_prebuilt//:protoc --verbose_failures --copt='-DGITHUB_BUILD' //sharing/proto/...
build-rust-linux:
name: Build Rust on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Build FPP
run: cargo build --manifest-path presence/fpp/fpp/Cargo.toml
+109 -29
View File
@@ -88,13 +88,13 @@ let package = Package(
sources: [
"ukey2/src/securemessage/src/securemessage",
"ukey2/src/main/cpp/src/securegcm",
"compiled_proto",
"protoc_out",
],
publicHeadersPath: "include",
cSettings: [
.headerSearchPath("ukey2/"),
.headerSearchPath("compiled_proto/"),
.headerSearchPath("compiled_proto/src/main/"),
.headerSearchPath("protoc_out/"),
.headerSearchPath("protoc_out/src/main/"),
]
),
.target(
@@ -103,10 +103,30 @@ let package = Package(
sources: ["EmptySwiftPackageManagerFile.cpp"],
publicHeadersPath: "json/include"
),
.target(
name: "protobuf-utf8",
dependencies: [
.product(name: "abseil", package: "abseil-cpp-SwiftPM"),
],
path: "google-protobuf/third_party/utf8_range",
sources: [
"utf8_validity.h",
"utf8_range.h",
"utf8_range.c",
],
publicHeadersPath: ".",
cSettings: [
.headerSearchPath("./"),
],
),
.target(
name: "protobuf",
path: "third_party/protobuf/src",
dependencies: [
"protobuf-utf8",
],
path: "google-protobuf/src",
exclude: [
"google/protobuf/bridge",
"google/protobuf/compiler",
"google/protobuf/testdata",
"google/protobuf/testing",
@@ -120,16 +140,12 @@ let package = Package(
"google/protobuf/arenastring_unittest.cc",
"google/protobuf/descriptor.proto",
"google/protobuf/reflection_ops_unittest.cc",
"google/protobuf/stubs/stringprintf_unittest.cc",
"google/protobuf/empty.proto",
"google/protobuf/map_lite_unittest.proto",
"google/protobuf/test_util_lite.cc",
"google/protobuf/any_test.cc",
"google/protobuf/stubs/structurally_valid_unittest.cc",
"google/protobuf/unittest_proto3_arena_lite.proto",
"google/protobuf/stubs/strutil_unittest.cc",
"google/protobuf/unittest_preserve_unknown_enum.proto",
"google/protobuf/arena_test_util.cc",
"google/protobuf/any_test.proto",
"google/protobuf/timestamp.proto",
"google/protobuf/io/tokenizer_unittest.cc",
@@ -142,26 +158,18 @@ let package = Package(
"google/protobuf/map_unittest.proto",
"google/protobuf/unittest_no_field_presence.proto",
"google/protobuf/unittest_proto3_arena.proto",
"google/protobuf/stubs/stringpiece_unittest.cc",
"google/protobuf/stubs/time_test.cc",
"google/protobuf/unittest_optimize_for.proto",
"google/protobuf/map_test_util.inc",
"google/protobuf/stubs/statusor_test.cc",
"google/protobuf/wire_format_unittest.inc",
"google/protobuf/repeated_field_reflection_unittest.cc",
"google/protobuf/stubs/template_util_unittest.cc",
"google/protobuf/unittest_import_public.proto",
"google/protobuf/io/printer_unittest.cc",
"google/protobuf/test_messages_proto3.proto",
"google/protobuf/io/zero_copy_stream_unittest.cc",
"google/protobuf/text_format_unittest.cc",
"google/protobuf/stubs/int128_unittest.cc",
"google/protobuf/unittest_lazy_dependencies_enum.proto",
"google/protobuf/test_messages_proto2.proto",
"google/protobuf/unittest_arena.proto",
"google/protobuf/unittest_lite.proto",
"google/protobuf/type.proto",
"google/protobuf/test_util.inc",
"google/protobuf/extension_set_unittest.cc",
"google/protobuf/preserve_unknown_enum_test.cc",
"google/protobuf/unittest_lazy_dependencies.proto",
@@ -169,11 +177,9 @@ let package = Package(
"google/protobuf/unittest_embed_optimize_for.proto",
"google/protobuf/lite_unittest.cc",
"google/protobuf/unknown_field_set_unittest.cc",
"google/protobuf/stubs/bytestream_unittest.cc",
"google/protobuf/wire_format_unittest.cc",
"google/protobuf/unittest_proto3_lite.proto",
"google/protobuf/api.proto",
"google/protobuf/stubs/status_test.cc",
"google/protobuf/generated_message_reflection_unittest.cc",
"google/protobuf/unittest_custom_options.proto",
"google/protobuf/map_field_test.cc",
@@ -189,7 +195,6 @@ let package = Package(
"google/protobuf/io/coded_stream_unittest.cc",
"google/protobuf/unittest_drop_unknown_fields.proto",
"google/protobuf/source_context.proto",
"google/protobuf/generated_message_tctable_impl.inc",
"google/protobuf/map_proto2_unittest.proto",
"google/protobuf/proto3_lite_unittest.cc",
"google/protobuf/descriptor_unittest.cc",
@@ -199,11 +204,9 @@ let package = Package(
"google/protobuf/stubs/common_unittest.cc",
"google/protobuf/arena_unittest.cc",
"google/protobuf/unittest_enormous_descriptor.proto",
"google/protobuf/map_lite_test_util.cc",
"google/protobuf/unittest_proto3.proto",
"google/protobuf/struct.proto",
"google/protobuf/unittest_preserve_unknown_enum2.proto",
"google/protobuf/io/gzip_stream_unittest.sh",
"google/protobuf/unittest_empty.proto",
"google/protobuf/port_def.inc",
"google/protobuf/dynamic_message_unittest.cc",
@@ -215,11 +218,89 @@ let package = Package(
"google/protobuf/well_known_types_unittest.cc",
"google/protobuf/map_test.inc",
"google/protobuf/reflection_tester.cc",
"google/protobuf/varint_shuffle_test.cc",
"google/protobuf/unredacted_debug_format_for_test_test.cc",
"google/protobuf/wire_format_unittest.h",
"google/protobuf/wire_format_unittest.cc",
"google/protobuf/string_view_test.cc",
"google/protobuf/string_block_test.cc",
"google/protobuf/arena_align_test.cc",
"google/protobuf/arenaz_sampler_test.cc",
"google/protobuf/debug_counter_test.cc",
"google/protobuf/descriptor_visitor_test.cc",
"google/protobuf/edition_message_unittest.cc",
"google/protobuf/feature_resolver_test.cc",
"google/protobuf/generated_enum_util_test.cc",
"google/protobuf/generated_message_tctable_lite_test.cc",
"google/protobuf/has_bits_test.cc",
"google/protobuf/internal_feature_helper_test.cc",
"google/protobuf/internal_message_util_unittest.cc",
"google/protobuf/map_probe_benchmark.cc",
"google/protobuf/map_test_util.h",
"google/protobuf/message_unittest_legacy_apis.inc",
"google/protobuf/micro_string_test.cc",
"google/protobuf/no_field_presence_map_test.cc",
"google/protobuf/port_test.cc",
"google/protobuf/raw_ptr_test.cc",
"google/protobuf/redaction_metric_test.cc",
"google/protobuf/reflection_mode_test.cc",
"google/protobuf/reflection_tester.h",
"google/protobuf/reflection_visit_fields_test.cc",
"google/protobuf/repeated_field_reflection_unittest.inc",
"google/protobuf/repeated_ptr_field_unittest.cc",
"google/protobuf/retention_test.cc",
"google/protobuf/string_piece_field_support_unittest.cc",
"google/protobuf/test_textproto.h",
"google/protobuf/test_util.h",
"google/protobuf/test_util2.h",
"google/protobuf/test_util_lite.h",
"google/protobuf/os_macros_undef.inc",
"google/protobuf/os_macros_restore.inc",
"google/protobuf/lazily_build_dependencies_test.cc",
"google/protobuf/edition_unittest.proto",
"google/protobuf/internal_options.proto",
"google/protobuf/late_loaded_option.proto",
"google/protobuf/late_loaded_option_user.proto",
"google/protobuf/map_proto3_unittest.proto",
"google/protobuf/only_one_enum_test.proto",
"google/protobuf/sample_messages_edition.proto",
"google/protobuf/cpp_features.proto",
"google/protobuf/unittest_custom_features.proto",
"google/protobuf/unittest_custom_options_unlinked.proto",
"google/protobuf/unittest_delimited.proto",
"google/protobuf/unittest_delimited_import.proto",
"google/protobuf/unittest_extension_set.proto",
"google/protobuf/unittest_features.proto",
"google/protobuf/unittest_import_option.proto",
"google/protobuf/unittest_invalid_features.proto",
"google/protobuf/unittest_legacy_features.proto",
"google/protobuf/unittest_lite_edition_2024.proto",
"google/protobuf/unittest_proto3_bad_macros.proto",
"google/protobuf/unittest_proto3_extensions.proto",
"google/protobuf/unittest_redaction.proto",
"google/protobuf/unittest_retention.proto",
"google/protobuf/unittest_string_type.proto",
"google/protobuf/unittest_string_view.proto",
"google/protobuf/BUILD.bazel",
"google/protobuf/bridge/BUILD.bazel",
"google/protobuf/io/BUILD.bazel",
"google/protobuf/json/BUILD.bazel",
"google/protobuf/stubs/BUILD.bazel",
"google/protobuf/json/BUILD.bazel",
"google/protobuf/json/json_test.cc",
"google/protobuf/json/internal/lexer_test.cc",
"google/protobuf/json/internal/zero_copy_buffered_stream_test.cc",
"google/protobuf/io/printer_death_test.cc",
"google/protobuf/io/test_zero_copy_stream.h",
"google/protobuf/io/test_zero_copy_stream_test.cc",
"google/protobuf/io/zero_copy_sink_test.cc",
],
sources: [
"google/protobuf",
],
sources: ["google/protobuf"],
publicHeadersPath: ".",
cSettings: [
.headerSearchPath("./")
.headerSearchPath("./"),
]
),
.target(
@@ -347,7 +428,6 @@ let package = Package(
"connections/implementation/pcp_manager_test.cc",
"connections/implementation/ble_advertisement_test.cc",
"connections/implementation/base_endpoint_channel_test.cc",
"connections/implementation/reconnect_manager_test.cc",
"connections/v3/connections_device_test.cc",
"connections/v3/connections_device_provider_test.cc",
"connections/implementation/connections_authentication_transport_test.cc",
@@ -470,7 +550,7 @@ let package = Package(
"internal/platform/medium_environment.cc",
],
sources: [
"compiled_proto",
"protoc_out",
"connections",
"internal",
"proto",
@@ -478,9 +558,9 @@ let package = Package(
publicHeadersPath: "connections",
cSettings: [
.headerSearchPath("./"),
.headerSearchPath("compiled_proto/"),
.headerSearchPath("protoc_out/"),
.headerSearchPath("third_party/ukey2/ukey2/"),
.headerSearchPath("third_party/ukey2/compiled_proto/"),
.headerSearchPath("third_party/ukey2/protoc_out/"),
.define("NO_WEBRTC"),
]
),
@@ -497,7 +577,7 @@ let package = Package(
publicHeadersPath: "connections/c",
cSettings: [
.headerSearchPath("./"),
.headerSearchPath("compiled_proto/"),
.headerSearchPath("protoc_out/"),
.define("NO_WEBRTC"),
]
),
@@ -510,7 +590,7 @@ let package = Package(
publicHeadersPath: "connections/swift/NearbyCoreAdapter/Sources/Public",
cSettings: [
.headerSearchPath("./"),
.headerSearchPath("compiled_proto/"),
.headerSearchPath("protoc_out/"),
.define("NO_WEBRTC"),
]
),