Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ struct BridgeJSBuildPlugin: BuildToolPlugin {
inputFiles.append(configFile)
}

// Include Swift files generated by other plugins applied to this
// target (available in tools-version 6.0+). This lets BridgeJS
// process @JS annotations in files produced by earlier plugins
// without requiring any extra configuration.
let pluginGeneratedSwiftFiles = target.pluginGeneratedSources.filter {
$0.pathExtension == "swift"
}
inputFiles.append(contentsOf: pluginGeneratedSwiftFiles)

let inputTSFile = target.directoryURL.appending(path: "bridge-js.d.ts")
let tsconfigPath = context.package.directoryURL.appending(path: "tsconfig.json")

Expand All @@ -47,15 +56,15 @@ struct BridgeJSBuildPlugin: BuildToolPlugin {
]

if FileManager.default.fileExists(atPath: inputTSFile.path) {
// Add .d.ts file and tsconfig.json as inputs
inputFiles.append(contentsOf: [inputTSFile, tsconfigPath])
arguments.append(contentsOf: [
"--project",
tsconfigPath.path,
])
}

arguments.append(contentsOf: inputSwiftFiles.map(\.path))
let allSwiftFiles = inputSwiftFiles + pluginGeneratedSwiftFiles
arguments.append(contentsOf: allSwiftFiles.map(\.path))

return .buildCommand(
displayName: "Generate BridgeJS code",
Expand Down
1 change: 1 addition & 0 deletions Plugins/BridgeJS/Sources/BridgeJSTool/BridgeJSTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ import BridgeJSUtilities
var inputFiles = withSpan("Collecting Swift files") {
return inputSwiftFiles(targetDirectory: targetDirectory, positionalArguments: positionalArguments)
}

// BridgeJS.Macros.swift contains imported declarations (@JSFunction, @JSClass, etc.) that need
// to be processed by SwiftToSkeleton to populate the imported skeleton. The command plugin
// filters out Generated/ files, so we explicitly add it here after generation.
Expand Down