Skip to content

Add API to query executable paths for runnable targets #482

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Richlee96112
Copy link

This change adds a public API to retrieve the absolute path of the built binary for a specified executable target, addressing issue #286. This functionality is intended to support tools like swift run, which need to locate and launch built targets.

The new asynchronous API, generateRunnableInfo, is implemented in SWBBuildServiceSession and returns a SWBRunnableInfo struct containing the resolved executable path. Targets are resolved using targetID, providing reliable and consistent identification across the build system.

Comprehensive error handling is included to cover cases where the target is missing or not executable. Unit tests validate both successful and failure scenarios to ensure correctness.

  • Sources/Protocol/SWBRunnableInfo.swift – Defines a struct that encapsulates the path to a built executable
  • Sources/BuildService/Session.swift – Implements a new API that takes a targetID and returns the resolved path of the corresponding executable
  • Tests/SWBBuildServiceTests/BuildServiceTests.swift – Adds unit tests for both success and error scenarios

Note: This PR addresses only the functionality requested in issue #286. Any existing Swift 6 compatibility issues in the project are unrelated to these changes and should be tracked and resolved separately.

While running tests, the following Swift 6 compatibility errors were encountered:
error: cannot find type 'sendingValue' in scope
error: cannot infer contextual base in reference to member 'init'
error: contextual closure type '() -> sending ()' expects 0 arguments...
These errors stem from existing code in the SWBUtil module that is not yet compatible with Swift 6’s new ownership model (e.g., ~Copyable, sending).

@Richlee96112 Richlee96112 changed the title Add API to query executable paths for runnable targets (issue #286) Add API to query executable paths for runnable targets May 2, 2025
@owenv
Copy link
Collaborator

owenv commented May 2, 2025

Thanks for the contribution! It doesn't look like this change compiles currently, so I'm converting it to a draft for now. Please feel free to re-request review once it's building successfully.

@owenv owenv marked this pull request as draft May 2, 2025 22:14
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.

2 participants