Skip to content

Expose the build triple of a BuildTarget in SourceKitLSPAPI #7555

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

Merged
merged 1 commit into from
May 14, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 13, 2024

If we have a package like this

let package = Package(
  name: "MyLibrary",
  targets: [
   .target(name: "Lib"),
   .executableTarget(name: "MyExec", dependencies: ["Lib"]),
   .plugin(
     name: "MyPlugin",
     capability: .command(
       intent: .sourceCodeFormatting(),
       permissions: []
     ),
     dependencies: ["MyExec"]
   )
  ]
)

Then the package graph contains two targets for Lib. We need to be able to differentiate them in SourceKit-LSP. For that, we need to expose the build triple of a BuildTarget.

@@ -23,13 +23,16 @@ import class Build.ClangTargetBuildDescription
import class Build.SwiftTargetBuildDescription
import struct PackageGraph.ResolvedModule
import struct PackageGraph.ModulesGraph
import enum PackageGraph.BuildTriple
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaxDesiatov Do you prefer to expose the BuildTriple type or would you prefer to define an equivalent BuildTriple type in SourceKitLSPAPI and then map between the two?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now IMO it's best to create public typealias BuildTriple = PackageGraph.BuildTriple in SourceKitLSPAPI, which can be replaced with something more advanced later.

@ahoppen ahoppen force-pushed the expose-build-triple branch from 1974b4e to 6b23a47 Compare May 13, 2024 23:34
@ahoppen
Copy link
Member Author

ahoppen commented May 13, 2024

@swift-ci Please test

@ahoppen ahoppen merged commit 4f01a84 into swiftlang:main May 14, 2024
5 checks passed
@ahoppen ahoppen deleted the expose-build-triple branch May 14, 2024 18:06
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
…tlang#7555)

If we have a package like this

```swift
let package = Package(
  name: "MyLibrary",
  targets: [
   .target(name: "Lib"),
   .executableTarget(name: "MyExec", dependencies: ["Lib"]),
   .plugin(
     name: "MyPlugin",
     capability: .command(
       intent: .sourceCodeFormatting(),
       permissions: []
     ),
     dependencies: ["MyExec"]
   )
  ]
)
```

Then the package graph contains two targets for `Lib`. We need to be
able to differentiate them in SourceKit-LSP. For that, we need to expose
the build triple of a `BuildTarget`.
ahoppen added a commit that referenced this pull request May 15, 2024
- **Explanation**: Adds a couple of APIs to the `SourceKitLSPAPI` module
that are needed for background indexing in SourceKit-LSP
- **Scope**: Purely additive API
- **Risk**: Very low, just adds new API
- **Testing**: n/a
- **Issue**: n/a
- **Reviewer**: @MaxDesiatov and @bnbarham on
#7540
#7555 respectively
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
…tlang#7555)

If we have a package like this

```swift
let package = Package(
  name: "MyLibrary",
  targets: [
   .target(name: "Lib"),
   .executableTarget(name: "MyExec", dependencies: ["Lib"]),
   .plugin(
     name: "MyPlugin",
     capability: .command(
       intent: .sourceCodeFormatting(),
       permissions: []
     ),
     dependencies: ["MyExec"]
   )
  ]
)
```

Then the package graph contains two targets for `Lib`. We need to be
able to differentiate them in SourceKit-LSP. For that, we need to expose
the build triple of a `BuildTarget`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants