feat(run): detect SwiftPM executable products as run configurations (#6792)

A Swift package now gets one run configuration per executable product, read from the manifest source without running it: declared .executable products plus executable targets no product builds (and legacy targets with main.swift). Each runs swift run --skip-build <product> after a swift build --product <product> before-launch task, and Debug launches .build/debug/<product> under lldb-dap with the configured arguments.

Closes #6786

Co-authored-by: wildcatDownstairs <[email protected]>
Цей коміт міститься в:
LU XIANGRUIтаwildcatDownstairs authored and GitHub committed 2026-11-29 14:39:13 +08:00
1 джерело f2641b9697
коміт 77e669c189
6 files changed
+143 -3

No files matched your search

+16
Переглянути файл
@@ -557,6 +557,22 @@ describe("run config → launch config", () => {
expect(gdb.extraJson).toBeNull();
});
it("swift run under lldb-dap debugs the built product with the arguments after it", () => {
const run = rc({
kind: "swiftpm",
command: "swift",
args: ["run", "--skip-build", "greet", "--loud"],
cwd: "pkg",
debugAdapter: "lldb-dap",
params: { product: "greet", program: ".build/debug/greet" },
});
expect(launchConfigFor(run, "/p")).toMatchObject({
program: "/p/pkg/.build/debug/greet",
args: ["--loud"],
cwd: "/p/pkg",
});
});
it.each(["native", "cmake-application"])(
"maps %s CMake debug-info paths to the editor's canonical source root",
(kind) => {
+5
Переглянути файл
@@ -398,6 +398,11 @@ function godotLaunch(rc: RunConfig, cwd: string): LaunchConfig {
/** A native program under CodeLLDB, lldb-dap or GDB: program, args, cwd, env. */
function nativeLaunch(rc: RunConfig, cwd: string, adapter: string): LaunchConfig {
const out: LaunchConfig = { ...base(rc, adapter, cwd), program: resolveCommand(rc.command, cwd), args: [...rc.args] };
// `swift run <product> <args…>`: debug the product its before launch build left behind.
if (rc.kind === "swiftpm" && rc.params?.program && rc.params.product) {
out.program = join(cwd, rc.params.program);
out.args = rc.args.slice(rc.args.indexOf(rc.params.product) + 1);
}
// lldb-dap takes the environment as `KEY=VALUE` strings.
if (adapter === "lldb-dap") {
const from = rc.params?.cmakeSourceRoot;