-
Notifications
You must be signed in to change notification settings - Fork 151
Explicitly pass .swiftmodule and .swiftinterface files as action inputs #1583
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
base: master
Are you sure you want to change the base?
Explicitly pass .swiftmodule and .swiftinterface files as action inputs #1583
Conversation
dd23624
to
efa3f31
Compare
9ea7b48
to
89c0878
Compare
@brentleyjones can I have your opinion on this one? |
|
||
return ConfigResultInfo( | ||
inputs = prerequisites.transitive_swiftmodules, | ||
inputs = transitive_inputs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make it so prerequisites.transitive_swiftmodules
has the right things (and probably rename it to transitive_included_modules
... though maybe we don't do that for now to keep cherry-picks easier). Also, we should only add one or the other. We should add swift_module.swiftmodule
if it exists, otherwise swift_module.private_swiftinterface
, otherwise swift_module.swiftinterface
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am running into issues if I pick only one of those files since -swiftmodule
is getting generated even though it is not explicitly passed. I am assuming that .swiftmodule
is produced as a result of building swift_import
target with .swiftinterface
.
Basically we need to keep logic as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming that
.swiftmodule
is produced as a result of buildingswift_import
target with.swiftinterface
Ideally we wouldn't compile .swiftinterface
and just pass it along as an importable module. You should only need to compile a (private) interface into a module if you needed access to package/protected types, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not really familiar with how swift_import
rule is implemented. But essentially I am building https://github.com/wesprint-io/swift-syntax-prebuilt/releases and it only exposes swift_import
targets with no .swiftmodule
files yet they are produced at some point and if I pick either .swiftmodule
or .swiftinterface
the build fails because it won't pick up the .swiftinterface
since .swiftmodule
appears and it gets selected. Only way that I was able to make it work is by including both of them like in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brentleyjones given the following swift_import
target
swift_import(
name = "SwiftBasicFormat",
archives = select({":darwin_arm64": ["arm64/libSwiftBasicFormat.a"]}),
module_name = "SwiftBasicFormat",
swiftdoc = select({":darwin_arm64": "arm64/SwiftBasicFormat.swiftdoc"}),
swiftinterface = select({":darwin_arm64": "arm64/SwiftBasicFormat.swiftinterface"}),
visibility = ["//visibility:public"],
deps = [":SwiftSyntax"],
)
after executing build bazel build :SwiftBasicFormat
I see the following files produced
SwiftSyntax601.swiftmodule-0.params
SwiftBasicFormat.swiftmodule
SwiftBasicFormat.swiftmodule-0.params
SwiftSyntax.swiftmodule
SwiftSyntax.swiftmodule-0.params
SwiftSyntax509.swiftmodule
SwiftSyntax509.swiftmodule-0.params
SwiftSyntax510.swiftmodule
SwiftSyntax510.swiftmodule-0.params
SwiftSyntax600.swiftmodule
SwiftSyntax600.swiftmodule-0.params
SwiftSyntax601.swiftmodule
I also added print staments to track this while build is in progress
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax509.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax509.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax510.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax510.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax600.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax600.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax601.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax601.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax509.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax509.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax510.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax510.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax600.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax600.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax601.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax601.swiftinterface>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2015:22: Adding swiftmodule: <generated file SwiftSyntax.swiftmodule>
DEBUG: /private/var/tmp/_bazel_adincebic/636060455adfb7fc752026ce1a8908d3/external/rules_swift+/swift/toolchains/config/compile_config.bzl:2018:22: Adding swiftinterface: <source file arm64/SwiftSyntax.private.swiftinterface>
Previously when building
swift_import
targets that depend on otherswift_import
targets with.swiftinterface
files failed when using Bazel sandbox with error:The
SWIFT_ACTION_COMPILE_MODULE_INTERFACE
action was missing transitive dependency files as inputs so I made sure that they are explicitly listed.