Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New swift_proto_library rule ignores srcs #1330

Open
rasberik opened this issue Oct 2, 2024 · 2 comments
Open

New swift_proto_library rule ignores srcs #1330

rasberik opened this issue Oct 2, 2024 · 2 comments

Comments

@rasberik
Copy link

rasberik commented Oct 2, 2024

Description

Despite intention of new swift_proto_library to behave like regular swift_library by inheriting its attributes, doesn't allow to add additional srcs.

Example

diff --git a/examples/xplatform/proto_files/BUILD b/examples/xplatform/proto_files/BUILD
index f43ebee..40336a9 100644
--- a/examples/xplatform/proto_files/BUILD
+++ b/examples/xplatform/proto_files/BUILD
@@ -4,6 +4,7 @@ load(
 )
 load("//proto:swift_proto_library.bzl", "swift_proto_library")
 load("//swift:swift_binary.bzl", "swift_binary")
+load("@bazel_skylib//rules:write_file.bzl", "write_file")
 
 proto_library(
     name = "message_1_proto",
@@ -43,6 +44,7 @@ swift_proto_library(
 
 swift_proto_library(
     name = "messages_3_swift_proto",
+    srcs = [":MessagesExport"],
     module_name = "Messages_3",
     protos = [
         ":message_3_proto",
@@ -62,3 +64,11 @@ swift_binary(
         ":messages_3_swift_proto",
     ],
 )
+
+write_file(
+    name = "MessagesExport",
+    out = "MessagesExport.swift",
+    content = [
+        "@_exported import Messages_1_2"
+    ],
+)
@rasberik
Copy link
Author

rasberik commented Oct 10, 2024

@AttilaTheFun @brentleyjones Apologies for direct tags, can I get any thoughts whether this behavior recognized as intended or an issue?
Currently can be resolved by adding wrapper workarounds but would be much nicer to have ability to add additional srcs files.

@AttilaTheFun
Copy link
Contributor

@rasberik Hmm this is an interesting question.

I never thought about the use case of injecting additional source files into the library but I don't think it would be too hard to support.

I think we'd just need to append the srcs attribute to the list of generated srcs passed to swift_common.compile

I'm not a maintainer of rules_swift so I can't approve the PR but @brentleyjones or @luispadron might be able to review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants