Skip to content

Commit

Permalink
RLS on Windows (#318)
Browse files Browse the repository at this point in the history
* minimal fix for windows

* Fix global dependencies of esy for windows.

* Fix things that could break on windows.
  • Loading branch information
Et7f3 authored and jaredly committed Sep 10, 2019
1 parent 8b519b3 commit 53c99e9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
16 changes: 15 additions & 1 deletion src/analyze/BuildSystem.re
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,24 @@ let isRunningInEsyNamedSandbox = () => {
};

let getExecutableInEsyPath = (exeName, ~pwd) => {
if (isRunningInEsyNamedSandbox()) {
let ret = if (isRunningInEsyNamedSandbox()) {
getLine("which " ++ exeName, ~pwd)
} else {
getLine("esy which " ++ exeName, ~pwd)
};
if (Sys.win32) {
switch ret {
| RResult.Ok(ret) =>
let ret = if (isRunningInEsyNamedSandbox()) {
getLine("cygpath -w " ++ ret, ~pwd)
} else {
getLine("esy cygpath -w " ++ ret, ~pwd)
};
ret
| Error(a) => Error(a)
}
} else {
ret
}
};

Expand Down
6 changes: 4 additions & 2 deletions src/analyze/Packages.re
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ let newJbuilderPackage = (~overrideBuildSystem=?, ~reportDiagnostics, state, roo


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

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

let dependencyModules = dependencyDirectories
|> List.map(path => {
Expand Down
2 changes: 1 addition & 1 deletion util/Files.re
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let split = (str, string) => Str.split(Str.regexp_string(str), string);
let absify = path => {
if (path == "" || path == ".") {
Unix.getcwd()
} else if (path.[0] == '/') {
} else if (Infix.isFullPath(path)) {
path
} else {
Filename.concat(Unix.getcwd(), path)
Expand Down
4 changes: 3 additions & 1 deletion util/Infix.re
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ let logIfAbsent = (message, x) => switch x {
| _ => x
};

let isFullPath = b => b.[0] == '/' || Sys.win32 && String.length(b) > 1 && b.[1] == ':';

let maybeConcat = (a, b) => {
if (b != "" && b.[0] == '/') {
if (b != "" && isFullPath(b)) {
b
} else {
fileConcat(a, b)
Expand Down
6 changes: 3 additions & 3 deletions util/MerlinFile.re
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ let parseMerlin = (base, text) => {
)
};

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

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

let isBuildFile = name =>
Expand Down

0 comments on commit 53c99e9

Please sign in to comment.