bazelbuild / rules_swift

Bazel rules to build Swift on Apple and Linux platforms
Apache License 2.0
303 stars 133 forks source link

[Feature Request] Mixed language(C and Swift) swift_library support #1182

Open Kyle-Ye opened 3 months ago

Kyle-Ye commented 3 months ago

Swift has a SE to make SwiftPM support it. But it is currently "Returned for Revision".

https://github.com/apple/swift-evolution/blob/main/proposals/0403-swiftpm-mixed-language-targets.md

I was wondering whether we have such feature supported on Bazel currently.

brentleyjones commented 3 months ago

You can currently use the experimental_mixed_language_library in rules_apple to support this.

If the SE is ever implemented, or maybe before then, I believe we will move that rule into rules_swift and graduate it to non-experimental.

Kyle-Ye commented 3 months ago

Haven't used experimental_mixed_language_library before. But I'd like to use it in Linux and other platforms too. Does it support such use case?

The repo's name "rules_apple" is hinting me that it will only work for Apple's Darwin platform.

Kyle-Ye commented 3 months ago

https://github.com/bazelbuild/rules_apple/blob/700f661876678b98596c4e3106396a9029571469/doc/rules-apple.md#experimental_mixed_language_library

Checking the doc, the rule is about ObjectiveC + Swift. But the SE and my issue is about C and Swift not ObjectiveC specific.

brentleyjones commented 3 months ago

The version that gets added to rules_swift would need to support C. For now you can probably write your own macro that uses cc_library instead of objc_library.