Skip to content

Commit 53c99e9

Browse files
Et7f3jaredly
authored andcommitted
RLS on Windows (#318)
* minimal fix for windows * Fix global dependencies of esy for windows. * Fix things that could break on windows.
1 parent 8b519b3 commit 53c99e9

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

src/analyze/BuildSystem.re

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,24 @@ let isRunningInEsyNamedSandbox = () => {
265265
};
266266

267267
let getExecutableInEsyPath = (exeName, ~pwd) => {
268-
if (isRunningInEsyNamedSandbox()) {
268+
let ret = if (isRunningInEsyNamedSandbox()) {
269269
getLine("which " ++ exeName, ~pwd)
270270
} else {
271271
getLine("esy which " ++ exeName, ~pwd)
272+
};
273+
if (Sys.win32) {
274+
switch ret {
275+
| RResult.Ok(ret) =>
276+
let ret = if (isRunningInEsyNamedSandbox()) {
277+
getLine("cygpath -w " ++ ret, ~pwd)
278+
} else {
279+
getLine("esy cygpath -w " ++ ret, ~pwd)
280+
};
281+
ret
282+
| Error(a) => Error(a)
283+
}
284+
} else {
285+
ret
272286
}
273287
};
274288

src/analyze/Packages.re

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ let newJbuilderPackage = (~overrideBuildSystem=?, ~reportDiagnostics, state, roo
362362

363363

364364
/* Log.log("Getting things"); */
365-
let (otherDirectories, otherFiles) = source |> List.filter(s => s != "." && s != "" && s.[0] != '/') |> optMap(name => {
365+
let (globalSource, localSource) = List.filter(s => s != "." && s != "", source)
366+
|> List.partition(Infix.isFullPath);
367+
let (otherDirectories, otherFiles) = localSource |> optMap(name => {
366368
let otherPath = rootPath /+ name;
367369
let res = {
368370
let%try (jbuildPath, jbuildRaw) = JbuildFile.readFromDir(otherPath);
@@ -395,7 +397,7 @@ let newJbuilderPackage = (~overrideBuildSystem=?, ~reportDiagnostics, state, roo
395397
}
396398
}) |> List.split;
397399

398-
let dependencyDirectories = (source |> List.filter(s => s != "" && s != "." && s.[0] == '/')) @ stdlibs;
400+
let dependencyDirectories = globalSource @ stdlibs;
399401

400402
let dependencyModules = dependencyDirectories
401403
|> List.map(path => {

util/Files.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ let split = (str, string) => Str.split(Str.regexp_string(str), string);
44
let absify = path => {
55
if (path == "" || path == ".") {
66
Unix.getcwd()
7-
} else if (path.[0] == '/') {
7+
} else if (Infix.isFullPath(path)) {
88
path
99
} else {
1010
Filename.concat(Unix.getcwd(), path)

util/Infix.re

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ let logIfAbsent = (message, x) => switch x {
3333
| _ => x
3434
};
3535

36+
let isFullPath = b => b.[0] == '/' || Sys.win32 && String.length(b) > 1 && b.[1] == ':';
37+
3638
let maybeConcat = (a, b) => {
37-
if (b != "" && b.[0] == '/') {
39+
if (b != "" && isFullPath(b)) {
3840
b
3941
} else {
4042
fileConcat(a, b)

util/MerlinFile.re

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ let parseMerlin = (base, text) => {
3333
)
3434
};
3535

36-
// let maybeConcat = (base, path) => path.[0] == '/' ? path : Filename.concat(base, path);
36+
// let maybeConcat = (base, path) => Infix.isFullPath(path) ? path : Filename.concat(base, path);
3737

38-
let isRelativePath = Sys.os_type == "Win32"
39-
? path => !Str.string_match(Str.regexp("[A-Z]:"), path, 0)
38+
let isRelativePath = Sys.win32
39+
? path => !Str.string_match(Str.regexp("[A-Za-z]:"), path, 0)
4040
: path => path != "" && path.[0] != '/';
4141

4242
let isBuildFile = name =>

0 commit comments

Comments
 (0)