Skip to content

Commit 99af4c2

Browse files
committed
fixing bsc.exe location and -bs-no-builtin-ppx flag
1 parent aa526cb commit 99af4c2

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

src/analyze/BuildSystem.re

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ let namespacedName = (buildSystem, namespace, name) => switch buildSystem {
8585

8686
open Infix;
8787

88+
let nodePlatform =
89+
switch (Sys.os_type) {
90+
| "Unix" => switch (input_line (Unix.open_process_in ("uname -s"))) {
91+
| "Darwin" => "darwin"
92+
| "Linux" => "linux"
93+
| "FreeBSD" => "freebsd"
94+
| s => invalid_arg (s ++ ": unsupported os_type")
95+
}
96+
| "Win32" => "win32"
97+
| s => invalid_arg (s ++ ": unsupported os_type")
98+
};
99+
100+
88101
let getBsPlatformDir = rootPath => {
89102
let result =
90103
ModuleResolution.resolveNodeModulePath(
@@ -319,7 +332,10 @@ let getCompiler = (rootPath, buildSystem) => {
319332
| BsbNative(_, Js)
320333
| Bsb(_) =>
321334
let%try_wrap bsPlatformDir = getBsPlatformDir(rootPath);
322-
bsPlatformDir /+ "lib" /+ "bsc.exe"
335+
switch(Files.ifExists(bsPlatformDir /+ "lib" /+ "bsc.exe")){
336+
| Some (x) => x
337+
| None => bsPlatformDir /+ nodePlatform /+ "bsc.exe"
338+
}
323339
| BsbNative(_, Native) =>
324340
let%try_wrap bsPlatformDir = getBsPlatformDir(rootPath);
325341
bsPlatformDir /+ "vendor" /+ "ocaml" /+ "ocamlopt.opt"

src/analyze/Packages.re

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,12 @@ let newBsPackage = (~overrideBuildSystem=?, ~reportDiagnostics, state, rootPath)
5151
let%try bsPlatform = BuildSystem.getBsPlatformDir(rootPath);
5252

5353

54-
let nodePlatform =
55-
switch (Sys.os_type) {
56-
| "Unix" => switch (input_line (Unix.open_process_in ("uname -s"))) {
57-
| "Darwin" => "darwin"
58-
| "Linux" => "linux"
59-
| "FreeBSD" => "freebsd"
60-
| s => invalid_arg (s ++ ": unsupported os_type")
61-
}
62-
| "Win32" => "win32"
63-
| s => invalid_arg (s ++ ": unsupported os_type")
64-
};
54+
6555

6656
let bsb = switch (Files.ifExists(bsPlatform /+ "lib" /+ "bsb.exe")){
6757
| Some (x) => x
6858
| None =>
69-
switch (Files.ifExists(bsPlatform /+ nodePlatform /+ "bsb.exe")){
59+
switch (Files.ifExists(bsPlatform /+ BuildSystem.nodePlatform /+ "bsb.exe")){
7060
| Some (x) => x
7161
| None => failwith ("can not locate bsb.exe in " ++ bsPlatform)
7262
}
@@ -189,7 +179,7 @@ let newBsPackage = (~overrideBuildSystem=?, ~reportDiagnostics, state, rootPath)
189179
};
190180

191181
let flags = switch buildSystem {
192-
| Bsb(_) | BsbNative(_, Js) => {
182+
| Bsb(version) | BsbNative(version, Js) => {
193183

194184
let jsPackageMode = {
195185
let specs = config |> Json.get("package-specs");
@@ -212,7 +202,7 @@ let newBsPackage = (~overrideBuildSystem=?, ~reportDiagnostics, state, rootPath)
212202
| _ => flags;
213203
};
214204
/* flags */
215-
["-bs-no-builtin-ppx-ml", ...flags];
205+
[ version > "7.1" ? "-bs-no-builtin-ppx" : "-bs-no-builtin-ppx-ml", ...flags];
216206
}
217207
| _ => flags
218208
};

0 commit comments

Comments
 (0)