Skip to content

Documentation: BuildToolPlugin example uses wrong type for executable #8820

Closed
@ADKaster

Description

@ADKaster

With swift from swiftly main-snapshot-2025-06-03, BuildCommand expects executable to be a URL.

@available(_PackageDescription, introduced: 6.0)
case buildCommand(
displayName: String?,
executable: URL,
arguments: [String],
environment: [String: String] = [:],
inputFiles: [URL] = [],
outputFiles: [URL] = []
)

Swift version 6.2-dev (LLVM b5d039be1fbae13, Swift 4fb4945ab972c85)
Target: x86_64-unknown-linux-gnu
Build config: +assertions

The example in Plugins.md passes a Path instead.

https://github.com/swiftlang/swift-package-manager/blob/ff7ea75b95e503bd3f22fcf8cf09e274561c3c10/Documentation/Plugins.md#implementing-the-build-tool-plugin-script

return .buildCommand(
    displayName: "Generating \(outputName) from \(inputPath.lastComponent)",
=>  executable: try context.tool(named: "SomeTool").path,
    arguments: [ "--verbose", "\(inputPath)", "\(outputPath)" ],
    inputFiles: [ inputPath, ],
    outputFiles: [ outputPath ]
)

Trying this pattern in my own code is a hard error.

Swift version 6.2-dev (LLVM b5d039be1fbae13, Swift 4fb4945ab972c85)
Target: x86_64-unknown-linux-gnu
/home/andrew/ladybird-org/htmlparser-swift/Plugins/GenerateNamedCharacterReferencesPlugin/main.swift:35:89: error: cannot convert value of type 'Path' to expected argument type 'URL'
33 |             .buildCommand(
34 |                 displayName: "Generate Named Character References",
35 |                 executable: try context.tool(named: "GenerateNamedCharacterReferences").path,
   |                                                                                         `- error: cannot convert value of type 'Path' to expected argument type 'URL'
36 |                 arguments: [
37 |                     "--generated-header-path", outputHeader.path,
error: build planning stopped due to build-tool plugin failures

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions