From 4681fb31af60f1ec7c5a8f84ea9d4e97e0d1244c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20BRAMI?= Date: Sat, 10 Aug 2019 23:08:23 +0200 Subject: [PATCH 1/3] minimal fix for windows --- src/analyze/BuildSystem.re | 16 +++++++++++++++- util/Infix.re | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/analyze/BuildSystem.re b/src/analyze/BuildSystem.re index e11fe52b..628ea5e2 100644 --- a/src/analyze/BuildSystem.re +++ b/src/analyze/BuildSystem.re @@ -264,10 +264,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 } }; diff --git a/util/Infix.re b/util/Infix.re index 14e64d8b..3ad16ef9 100644 --- a/util/Infix.re +++ b/util/Infix.re @@ -36,6 +36,8 @@ let logIfAbsent = (message, x) => switch x { let maybeConcat = (a, b) => { if (b != "" && b.[0] == '/') { b + } else if (Sys.win32 && String.length(b) > 1 && b.[1] == ':') { + b } else { fileConcat(a, b) } From 5005e16496f8951e4717f1040616176f548c4125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20BRAMI?= Date: Mon, 12 Aug 2019 15:31:02 +0200 Subject: [PATCH 2/3] Fix global dependencies of esy for windows. --- src/analyze/Packages.re | 6 ++++-- util/Infix.re | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/analyze/Packages.re b/src/analyze/Packages.re index ae2546ad..aec063a1 100644 --- a/src/analyze/Packages.re +++ b/src/analyze/Packages.re @@ -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); @@ -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 => { diff --git a/util/Infix.re b/util/Infix.re index 3ad16ef9..4f737f02 100644 --- a/util/Infix.re +++ b/util/Infix.re @@ -33,10 +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] == '/') { - b - } else if (Sys.win32 && String.length(b) > 1 && b.[1] == ':') { + if (b != "" && isFullPath(b)) { b } else { fileConcat(a, b) From 155bbaae81f8441fbc40357589189f62adb3755a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20BRAMI?= Date: Mon, 12 Aug 2019 17:28:51 +0200 Subject: [PATCH 3/3] Fix things that could break on windows. --- util/Files.re | 2 +- util/MerlinFile.re | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/util/Files.re b/util/Files.re index 9ed24efd..f712d6f2 100644 --- a/util/Files.re +++ b/util/Files.re @@ -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) diff --git a/util/MerlinFile.re b/util/MerlinFile.re index dd815981..2e8535d6 100644 --- a/util/MerlinFile.re +++ b/util/MerlinFile.re @@ -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 =>