BridgeJS: Include pluginGeneratedSources in build plugin input files#638
Conversation
6f3ab1c to
9589496
Compare
|
Hmm, I'm not confident that it works properly with incremental builds. Given that |
|
Thanks for calling this out, jumped to conclusion a bit too quickly seeing it work in test runs 😅 Do you think this approach be viable?
My understanding is this would create an explicit "producer -> consumer" edge in the build graph, so BridgeJS should wait for plugin A output on clean build and also invalidates reliably on incremental changes? On the other hand I understand this is quite specific usecase, if there is no much value in it in overall I can keep it within our fork 🙏🏻 |
|
@kateinoigakukun after some exploration, I think there might be better approach that drops SPM already has /// The file URLs of any sources generated by other plugins applied
/// to the given target before the plugin being executed.
///
/// Note: Plugins are applied in order of declaration in the package
/// manifest.
@available(_PackageDescription, introduced: 6.0)
var pluginGeneratedSources: [URL] { get }In our setup, plugin A is declared before BridgeJS in the So update to BridgeJS side would be roughly: // After collecting inputSwiftFiles from target.sourceFiles:
let pluginGenerated = target.pluginGeneratedSources.filter {
$0.pathExtension == "swift"
}
inputFiles.append(contentsOf: pluginGenerated)And pass them as arguments to This handles incremental builds properly since the files are tracked as |
|
@krodak Thanks for exploring more! |
Overview
BridgeJS wasn't seeing Swift files generated by other build plugins on the same target. If plugin A generates
@JS-annotated.swiftfiles, BridgeJS (running as plugin B) wouldn't process them because it only looked attarget.sourceFiles.Since tools-version 6.0, SPM provides
target.pluginGeneratedSources- a list of output files declared by previously-run plugins on the same target. Plugin ordering follows declaration order in theplugins:array, so this is deterministic.This change makes BridgeJS include
pluginGeneratedSourcesin both itsinputFiles(for SPM dependency tracking) and the file list passed to BridgeJSTool for skeleton scanning.