Skip to content

Commit 62ad3bf

Browse files
committed
Fix Swift rpath lookup
1 parent 9472bf2 commit 62ad3bf

File tree

14 files changed

+85
-32
lines changed

14 files changed

+85
-32
lines changed

.vscode-test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const launchArgs = [
3131
"--disable-crash-reporter",
3232
"--disable-workspace-trust",
3333
"--disable-telemetry",
34+
"--disable-extension",
35+
"vscode.github",
36+
"--disable-extension",
37+
"vscode.github-authentication",
3438
];
3539
if (dataDir) {
3640
launchArgs.push("--user-data-dir", dataDir);

docker/sandbox.sb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
(deny default)
44

55
; Get fonts
6-
(import "system.sb")
6+
; (import "system.sb")
77

88
; Helpers
99
(define (param-regex param-name param-relative-regex)
@@ -50,18 +50,33 @@
5050
(regex #"^/private/var/folders/[^/]+/[^/]+/.+")
5151
(regex #"^/Library/Preferences/.*.plist")
5252
(regex #"^/[^/]+/Library/Python")
53+
(subpath "/Library/Developer/CommandLineTools")
5354
(subpath "/Library/Developer/Toolchains")
5455
(subpath "/Library/Frameworks/UIAutomation.framework")
5556
(subpath "/Library/Python")
57+
(subpath "/System/Library/Perl")
5658
(subpath "/Applications/Xcode.app")
5759
(subpath "/Applications/Xcode-beta.app")
5860
(subpath "/bin")
5961
(subpath "/usr/bin")
6062
(subpath "/usr/local/bin")
61-
(subpath "/usr/lib/swift")
6263
(subpath "/usr/libexec/path_helper")
6364
(subpath "/usr/local/share/git-core")
6465
(subpath "/usr/local/share/hwtrace")
66+
67+
(regex #".*/LLDB.framework/.*")
68+
(regex #".*/Python3.framework/.*")
69+
(regex #".*/branch-main/.*")
70+
(regex #".*/usr/lib/swift/.*")
71+
; (regex #".*/Frameworks/.*")
72+
; (regex #".*/PrivateFrameworks/.*")
73+
74+
; (subpath "/System/Volumes/Preboot")
75+
; (subpath "/System/Volumes")
76+
; (subpath "/usr/lib")
77+
; (subpath "/Users/ec2-user")
78+
; (subpath "/Library/Developer/CommandLineTool")
79+
; (subpath "/")
6580
)
6681

6782
(allow mach-lookup)
@@ -84,8 +99,11 @@
8499
(regex #"^/Users/[^/]+/Library/Caches/com.apple.python.*")
85100
(regex #"^/Users/[^/]+/Library/Developer/Xcode/DerivedData.*")
86101
(regex #"^/Users/[^/]+/Library/Application Support/Code.*")
102+
(regex #"^/Users/[^/]+/Library/Application Support/Microsoft.*")
87103
(regex #"^/private/var/folders/[^/]+/[^/]+/.+")
88104
(regex #"^/Users/[^/]+/.vscode.*")
105+
106+
(regex #".*/branch-main.*")
89107
)
90108

91109
; Execute

docker/test-macos.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ PATH="$ARTIFACTS/$NODE_NAME/bin:$PATH"
5656
mkdir -p "$(dirname "$VSCODE_SETTINGS")"
5757
cat <<EOT > "$VSCODE_SETTINGS"
5858
{
59-
"swift.disableSandbox": true
59+
"swift.path": "/Users/ec2-user/jenkins/workspace/pr-vscode-swift-macos/branch-main/latest_toolchain/usr/bin"
60+
"swift.disableSandbox": true,
61+
"swift.debugger.disable": true,
62+
"swift.debugger.path": "/Users/ec2-user/jenkins/workspace/pr-vscode-swift-macos/branch-main/latest_toolchain/usr/bin/lldb-dap",
63+
"lldb.library": "/Applications/Xcode-beta.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB",
64+
"lldb.launch.expressions": "native",
65+
"lldb.suppressUpdateNotifications": true
6066
}
6167
EOT
6268

@@ -84,4 +90,6 @@ export GIT_CONFIG_VALUE_0="$PWD/hooks"
8490

8591
# Need to set proxy to download VS Code
8692
export npm_config_https_proxy="$HTTPS_PROXY"
93+
94+
# export DEVELOPER_DIR=/Applications/Xcode-beta.app
8795
VSCODE_DATA_DIR="$USER_DATA" CI=1 FAST_TEST_RUN=1 npm run coverage -- --coverage-output "$PWD/coverage"

src/SwiftPackage.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,9 @@ export class SwiftPackage implements PackageContents {
211211
toolchain: SwiftToolchain
212212
): Promise<SwiftPackageState> {
213213
try {
214-
let { stdout } = await execSwift(
215-
toolchain.buildFlags.withAdditionalFlags(["package", "describe", "--type", "json"]),
216-
toolchain,
217-
{
218-
cwd: folder.fsPath,
219-
}
220-
);
214+
let { stdout } = await execSwift(["package", "describe", "--type", "json"], toolchain, {
215+
cwd: folder.fsPath,
216+
});
221217
// remove lines from `swift package describe` until we find a "{"
222218
while (!stdout.startsWith("{")) {
223219
const firstNewLine = stdout.indexOf("\n");

src/configuration.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export interface DebuggerConfiguration {
5151
readonly useDebugAdapterFromToolchain: boolean;
5252
/** Return path to debug adapter */
5353
readonly customDebugAdapterPath: string;
54+
/** Whether or not to disable setting up the debugger */
55+
readonly disable: boolean;
5456
}
5557

5658
/** workspace folder configuration */
@@ -199,6 +201,11 @@ const configuration = {
199201
get customDebugAdapterPath(): string {
200202
return vscode.workspace.getConfiguration("swift.debugger").get<string>("path", "");
201203
},
204+
get disable(): boolean {
205+
return vscode.workspace
206+
.getConfiguration("swift.debugger")
207+
.get<boolean>("disable", false);
208+
},
202209
};
203210
},
204211
/** Files and directories to exclude from the code coverage. */

src/extension.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { showReloadExtensionNotification } from "./ui/ReloadExtension";
3838
import { checkAndWarnAboutWindowsSymlinks } from "./ui/win32";
3939
import { SwiftEnvironmentVariablesManager, SwiftTerminalProfileProvider } from "./terminal";
4040
import { resolveFolderDependencies } from "./commands/dependencies/resolve";
41-
import { SelectedXcodeWatcher } from "./toolchain/SelectedXcodeWatcher";
41+
// import { SelectedXcodeWatcher } from "./toolchain/SelectedXcodeWatcher";
4242

4343
/**
4444
* External API as exposed by the extension. Can be queried by other extensions
@@ -128,8 +128,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<Api> {
128128
const workspaceContext = await WorkspaceContext.create(context, outputChannel, toolchain);
129129
context.subscriptions.push(...commands.register(workspaceContext));
130130
context.subscriptions.push(workspaceContext);
131-
context.subscriptions.push(registerDebugger(workspaceContext));
132-
context.subscriptions.push(new SelectedXcodeWatcher(outputChannel));
131+
if (!configuration.debugger.disable) {
132+
context.subscriptions.push(registerDebugger(workspaceContext));
133+
}
134+
// context.subscriptions.push(new SelectedXcodeWatcher(outputChannel));
133135

134136
// listen for workspace folder changes and active text editor changes
135137
workspaceContext.setupEventListeners();

src/toolchain/toolchain.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,7 @@ export class SwiftToolchain {
813813
private static async getSwiftTargetInfo(): Promise<SwiftTargetInfo> {
814814
try {
815815
try {
816-
const { stdout } = await execSwift(
817-
["-print-target-info", ...BuildFlags.disableSandboxFlags()],
818-
"default"
819-
);
816+
const { stdout } = await execSwift(["-print-target-info"], "default");
820817
const targetInfo = JSON.parse(stdout.trimEnd()) as SwiftTargetInfo;
821818
if (targetInfo.compilerVersion) {
822819
return targetInfo;

src/utilities/utilities.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,18 @@ export async function execFile(
109109
options.env = { ...(options.env ?? process.env), ...runtimeEnv };
110110
}
111111
}
112-
return new Promise<{ stdout: string; stderr: string }>((resolve, reject) =>
113-
cp.execFile(executable, args, options, (error, stdout, stderr) => {
114-
if (error) {
115-
reject(new ExecFileError(error, stdout, stderr));
116-
}
117-
resolve({ stdout, stderr });
118-
})
119-
);
112+
return new Promise<{ stdout: string; stderr: string }>((resolve, reject) => {
113+
try {
114+
cp.execFile(executable, args, options, (error, stdout, stderr) => {
115+
if (error) {
116+
reject(new ExecFileError(error, stdout, stderr));
117+
}
118+
resolve({ stdout, stderr });
119+
});
120+
} catch (e) {
121+
reject(e);
122+
}
123+
});
120124
}
121125

122126
export async function execFileStreamOutput(

test/integration-tests/SwiftSnippet.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ suite("SwiftSnippet Test Suite @slow", function () {
6262
// Set a breakpoint
6363
vscode.debug.addBreakpoints(breakpoints);
6464
},
65+
requiresDebugger: true,
6566
});
6667

6768
suiteTeardown(async () => {

test/integration-tests/commands/build.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ suite("Build Commands @slow", function () {
5656
async teardown() {
5757
await vscode.commands.executeCommand(Workbench.ACTION_CLOSEALLEDITORS);
5858
},
59+
requiresDebugger: true,
5960
});
6061

6162
test("Swift: Run Build", async () => {

0 commit comments

Comments
 (0)