From be45a8529424bcc3f22376483287eacfaa32ee60 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Wed, 30 Sep 2026 03:11:43 +0000 Subject: [PATCH 1/2] Fix compiler switches: use /EXE on Windows, --executable elsewhere PureBasic has no --exe or --run switch. Pass the platform-correct output switch and launch the built executable after a successful compile instead of passing --run. Also auto-detect pbcompilerc.exe (C backend). Fixes #1 Co-Authored-By: Claude Opus 5.5 --- src/compilerService.ts | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/compilerService.ts b/src/compilerService.ts index fbaf085..1cdf28a 100644 --- a/src/compilerService.ts +++ b/src/compilerService.ts @@ -32,8 +32,11 @@ export class CompilerService { const extraArgs = cfg.get('compilerArgs', []); const outputFile = this.getOutputPath(filePath); - const args: string[] = [filePath, '--exe', outputFile, ...extraArgs]; - if (run) { args.push('--run'); } + // The Windows compilers (pbcompiler.exe / pbcompilerc.exe) use "/EXE", + // while Linux/macOS use "--executable". Neither has a "run" switch, so the + // executable is launched separately after a successful compile. + const exeSwitch = process.platform === 'win32' ? '/EXE' : '--executable'; + const args: string[] = [filePath, exeSwitch, outputFile, ...extraArgs]; this.outputChannel.clear(); this.outputChannel.show(true); @@ -91,6 +94,7 @@ export class CompilerService { if (code === 0) { this.outputChannel.appendLine(`\n✅ Compilation successful → ${outputFile}`); vscode.window.setStatusBarMessage('PureBasic: Compiled successfully ✅', 5000); + if (run) { this.runExecutable(outputFile); } } else { this.outputChannel.appendLine(`\n❌ Compilation failed (exit code ${code})`); vscode.window.setStatusBarMessage('PureBasic: Compilation failed ❌', 5000); @@ -108,6 +112,24 @@ export class CompilerService { ); } + private runExecutable(exePath: string): void { + this.outputChannel.appendLine(`\n▶ Running: ${path.basename(exePath)}\n`); + + const proc = cp.spawn(exePath, [], { cwd: path.dirname(exePath) }); + + proc.stdout?.on('data', (data: Buffer) => this.outputChannel.append(data.toString())); + proc.stderr?.on('data', (data: Buffer) => this.outputChannel.append(data.toString())); + + proc.on('close', (code) => { + this.outputChannel.appendLine(`\n■ Program exited (exit code ${code})`); + }); + + proc.on('error', (err) => { + this.outputChannel.appendLine(`\n❌ Failed to run program: ${err.message}`); + vscode.window.showErrorMessage(`PureBasic: failed to run program: ${err.message}`); + }); + } + private parseCompilerOutput( text: string, diags: Map, @@ -171,6 +193,8 @@ export class CompilerService { candidates.push( 'C:\\Program Files\\PureBasic\\Compilers\\pbcompiler.exe', 'C:\\Program Files (x86)\\PureBasic\\Compilers\\pbcompiler.exe', + 'C:\\Program Files\\PureBasic\\Compilers\\pbcompilerc.exe', + 'C:\\Program Files (x86)\\PureBasic\\Compilers\\pbcompilerc.exe', ); } else if (process.platform === 'darwin') { candidates.push( From 80b4843d3032e22f7bb9f96997066c80312ec844 Mon Sep 17 00:00:00 2001 From: agorangetek Date: Wed, 30 Sep 2026 10:11:45 +0300 Subject: [PATCH 2/2] Use -o rather than the undocumented --executable on Linux/macOS PureBasic's own reference documents the output switch as "-o, --output, /OUTPUT " and the Windows example uses /EXE, but "--executable" appears nowhere: not in `pbcompiler -h` and not in the manual. It is accepted by 6.41 and does honour the path, so this is not a live bug -- it is an undocumented alias with nothing promising it on other versions. -o is the same switch in its documented short form, so the non-Windows branch now uses it. The /EXE choice for Windows is unchanged and matches the manual's Windows example. --- src/compilerService.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/compilerService.ts b/src/compilerService.ts index 1cdf28a..35bc7c2 100644 --- a/src/compilerService.ts +++ b/src/compilerService.ts @@ -33,9 +33,11 @@ export class CompilerService { const extraArgs = cfg.get('compilerArgs', []); const outputFile = this.getOutputPath(filePath); // The Windows compilers (pbcompiler.exe / pbcompilerc.exe) use "/EXE", - // while Linux/macOS use "--executable". Neither has a "run" switch, so the - // executable is launched separately after a successful compile. - const exeSwitch = process.platform === 'win32' ? '/EXE' : '--executable'; + // while Linux/macOS take "-o" (documented as "--output"). "--executable" is + // an undocumented alias that happens to work on 6.41, so it is not used + // here. Neither has a "run" switch, so the executable is launched + // separately after a successful compile. + const exeSwitch = process.platform === 'win32' ? '/EXE' : '-o'; const args: string[] = [filePath, exeSwitch, outputFile, ...extraArgs]; this.outputChannel.clear();