cgrindel / rules_swift_package_manager

Collection of utilities and Bazel rules to aid in the development and maintenance of Swift repositories using Bazel.
Apache License 2.0
72 stars 26 forks source link

C/C++ language standards should be set per-target #1079

Open brentleyjones opened 3 months ago

brentleyjones commented 3 months ago

We shouldn't recommend that users set workspace-wide --copt/--cxxopt flags. Instead we should set the required flags on the {cc,objc}_library targets. If a target has both C and C++ files, we may need to split the target in two in order to apply the correct flag to each one.

cgrindel commented 1 month ago

@brentleyjones Do you have an example where a Swift package combines c and c++ in the same target? If so, I will use it as a test case.

brentleyjones commented 1 month ago

I don't know of one in the wild. I'm not even 100% sure SwiftPM allows it (though I expect it does). I know Bazel does, and it leads to issues with copts, so you generally should split them.

brentleyjones commented 1 month ago

Maybe they can't be both C++ and C at the same time? https://github.com/swiftlang/swift-package-manager/blob/ce099264a187759c2f587393bd209d317a0352b4/Sources/PackageModel/Target.swift#L487

cgrindel commented 1 month ago

I am going to write the support as if it can be one or the other. If we run into a real-world example that says otherwise, I will adjust the logic accordingly.