Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#### :bug: Bug fix

- Protect against trying to read non-existant `.compiler.log`. https://github.com/rescript-lang/rescript-vscode/pull/1116
- Detected quoted paths in bsb arguments on Windows. https://github.com/rescript-lang/rescript-vscode/pull/1120

#### :rocket: New Feature

Expand Down
25 changes: 21 additions & 4 deletions server/src/incrementalCompilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { performance } from "perf_hooks";
import * as p from "vscode-languageserver-protocol";
import * as cp from "node:child_process";
import semver from "semver";
import * as os from "os";
import config, { send } from "./config";
import * as c from "./constants";
import { fileCodeActions } from "./codeActions";
Expand Down Expand Up @@ -555,6 +556,9 @@ function verifyTriggerToken(filePath: string, triggerToken: number): boolean {
triggerToken
);
}

const isWindows = os.platform() === "win32";

async function figureOutBscArgs(entry: IncrementallyCompiledFileInfo) {
const project = projectsFiles.get(entry.project.rootPath);
if (project?.rescriptVersion == null) {
Expand Down Expand Up @@ -591,10 +595,23 @@ async function figureOutBscArgs(entry: IncrementallyCompiledFileInfo) {
buildArgs.forEach(([key, value]: Array<string>) => {
if (key === "-I") {
if (isBsb) {
callArgs.push(
"-I",
path.resolve(entry.project.rootPath, c.compilerDirPartialPath, value),
);
/*build.ninja could have quoted paths on Windows
Example:
rule mij
command = "C:\Users\moi\Projects\my-project\node_modules\rescript\win32\bsc.exe" -I src -I "C:\Users\moi\Projects\my-project\node_modules\@rescript\core\lib\ocaml" -open RescriptCore -uncurried -bs-package-name rewindow -bs-package-output esmodule:$in_d:.res.mjs -bs-v $g_finger $i
*/
if (isWindows && value.startsWith('"') && value.endsWith('"')) {
callArgs.push("-I", value.substring(1, value.length - 1));
} else {
callArgs.push(
"-I",
path.resolve(
entry.project.rootPath,
c.compilerDirPartialPath,
value,
),
);
}
} else {
// TODO: once ReScript v12 is out we can remove this check for `.`
if (value === ".") {
Expand Down
Loading