Skip to content

Commit 6dd6a03

Browse files
committed
1 parent ca3940a commit 6dd6a03

File tree

9 files changed

+109
-58
lines changed

9 files changed

+109
-58
lines changed

Diff for: jscomp/Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ BSB_SRCS= bsb_config \
289289
bsb_build_util \
290290
bsb_helper_linker\
291291
bsb_helper_extract\
292-
bsb_dir \
293292
bsb_rule\
294293
bsb_ninja \
295294
bsb_build_ui \

Diff for: jscomp/others/.depend

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bs_result.cmj :
1919
node_child_process.cmj : node.cmj
2020
js_boolean.cmj : js_boolean.cmi
2121
js_math.cmj :
22-
js_dict.cmj : js_dict.cmi
22+
js_dict.cmj : js_array.cmj js_dict.cmi
2323
js_date.cmj :
2424
js_global.cmj :
2525
js_cast.cmj : js_cast.cmi

Diff for: jscomp/others/node_process.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type t =
3636
> Js.t
3737

3838
external process : t = "" [@@bs.module]
39-
39+
external argv : string array = "" [@@bs.module "process"]
4040
external exit : int -> unit = "" [@@bs.module "process"]
4141
external cwd : unit -> string = "" [@@bs.module "process"]
4242
(** The process.uptime() method returns the number of seconds

Diff for: jscomp/others/node_process.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type t =
3434
> Js.t
3535

3636
external process : t = "" [@@bs.module]
37-
37+
external argv : string array = "" [@@bs.module "process"]
3838
external exit : int -> unit = "" [@@bs.module "process"]
3939
external cwd : unit -> string = "" [@@bs.module "process"]
4040
(** The process.uptime() method returns the number of seconds

Diff for: jscomp/xwatcher/xwatcher_current.js

+39-20
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as Bs_vector from "../../lib/es6/bs_vector.js";
88
import * as Js_primitive from "../../lib/es6/js_primitive.js";
99
import * as Node_process from "../../lib/es6/node_process.js";
1010
import * as Xwatcher_util from "./xwatcher_util.js";
11+
import * as Child_process from "child_process";
1112

1213
Bs_option.getExn(Js_primitive.undefined_to_opt(typeof (__dirname) === "undefined" ? undefined : (__dirname)));
1314

@@ -25,8 +26,10 @@ var lock = Xwatcher_util.makeLock(/* () */0);
2526

2627
var events = Xwatcher_util.makeEventObj(/* () */0);
2728

29+
var command = "./watch-build.sh";
30+
2831
function exec() {
29-
return Xwatcher_util.buildWithShell("./watch-build.sh", events, lock, function () {
32+
return Xwatcher_util.buildWithShell(command, events, lock, function () {
3033
return /* () */0;
3134
});
3235
}
@@ -43,25 +46,41 @@ function watch(dir) {
4346

4447
Node_process.putEnvVar("BS_VSCODE", "1");
4548

46-
Bs_vector.iter(function (x) {
47-
watch(Path.join(jscomp, x));
48-
return /* () */0;
49-
}, /* array */[
50-
"core",
51-
"syntax",
52-
"ext",
53-
"depends",
54-
"others",
55-
"ounit",
56-
"ounit_tests",
57-
"test",
58-
"runtime",
59-
"xwatcher",
60-
"bsb",
61-
"common"
62-
]);
63-
64-
exec(/* () */0);
49+
var match = Process.argv.slice(2);
50+
51+
var exit = 0;
52+
53+
if (match.length !== 1) {
54+
exit = 1;
55+
} else {
56+
var match$1 = match[0];
57+
if (match$1 === "-build") {
58+
Child_process.spawn(command, ( [ ]), ( { "stdio" : "inherit", "shell" : true }));
59+
} else {
60+
exit = 1;
61+
}
62+
}
63+
64+
if (exit === 1) {
65+
Bs_vector.iter(function (x) {
66+
watch(Path.join(jscomp, x));
67+
return /* () */0;
68+
}, /* array */[
69+
"core",
70+
"syntax",
71+
"ext",
72+
"depends",
73+
"others",
74+
"ounit",
75+
"ounit_tests",
76+
"test",
77+
"runtime",
78+
"xwatcher",
79+
"bsb",
80+
"common"
81+
]);
82+
exec(/* () */0);
83+
}
6584

6685
export {
6786

Diff for: jscomp/xwatcher/xwatcher_current.ml

+20-14
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,27 @@ let watch dir =
3535
|| Js.String.endsWith ".cppo" fileName then
3636
exec ()
3737
)
38-
let () =
3938

39+
let () =
4040
Node.Process.putEnvVar "BS_VSCODE" "1";
41-
Bs.Vector.iter (fun [@bs] x ->
42-
ignore @@ watch (Node.Path.join [|jscomp; x|])
43-
)
44-
[| "core"; "syntax"; "ext"; "depends";
45-
"others";
46-
"ounit"; "ounit_tests"; "test";
47-
"runtime";
48-
"xwatcher";
49-
"bsb";
50-
"common"
51-
|];
52-
53-
exec ()
41+
match Js.Array.sliceFrom 2 Node.Process.argv with
42+
| [|"-build"|] ->
43+
Xwatcher_util.spawnInheritIgnore command
44+
| _ ->
45+
begin
46+
Bs.Vector.iter (fun [@bs] x ->
47+
ignore @@ watch (Node.Path.join [|jscomp; x|])
48+
)
49+
[| "core"; "syntax"; "ext"; "depends";
50+
"others";
51+
"ounit"; "ounit_tests"; "test";
52+
"runtime";
53+
"xwatcher";
54+
"bsb";
55+
"common"
56+
|];
57+
58+
exec ()
59+
end
5460

5561

Diff for: jscomp/xwatcher/xwatcher_util.ml

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ external spawnInherit : string ->
4747

4848
external onExit : (_ [@bs.as "exit"]) -> (unit -> unit [@bs.uncurry]) -> unit = "on" [@@bs.send.pipe: t]
4949

50+
51+
external spawnInheritIgnore : string ->
52+
(_ [@bs.as {json| [ ]|json}]) ->
53+
(_ [@bs.as {json| { "stdio" : "inherit", "shell" : true }|json}]) -> unit = "spawn" [@@bs.module "child_process"]
54+
5055
(* let (acquireBuild, releaseBuild) = *)
5156
(* let isBuilding = ref false in *)
5257
(* (fun [@bs]() -> if !isBuilding then false else begin isBuilding := true ; true end), *)

Diff for: jscomp/xwatcher/xwatcher_util.mli

+4
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ val findFile : prev:string -> cwd:string -> string -> string
2323
val getWatchFiles : string -> Js.String.t Js.Array.t
2424
type watcher = { dir : string ; watcher : Node.Fs.Watch.t }
2525
val makeWatcher : string -> (string -> string -> unit [@bs]) -> watcher
26+
27+
external spawnInheritIgnore : string ->
28+
(_ [@bs.as {json| [ ]|json}]) ->
29+
(_ [@bs.as {json| { "stdio" : "inherit", "shell" : true }|json}]) -> unit = "spawn" [@@bs.module "child_process"]

Diff for: scripts/watcher.js

+38-20
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,10 @@ var lock = makeLock(/* () */0);
220220

221221
var events = makeEventObj(/* () */0);
222222

223+
var command = "./watch-build.sh";
224+
223225
function exec() {
224-
return buildWithShell("./watch-build.sh", events, lock, function () {
226+
return buildWithShell(command, events, lock, function () {
225227
return /* () */0;
226228
});
227229
}
@@ -238,25 +240,41 @@ function watch$1(dir) {
238240

239241
putEnvVar("BS_VSCODE", "1");
240242

241-
iter$$1(function (x) {
242-
watch$1(Path.join(jscomp, x));
243-
return /* () */0;
244-
}, /* array */[
245-
"core",
246-
"syntax",
247-
"ext",
248-
"depends",
249-
"others",
250-
"ounit",
251-
"ounit_tests",
252-
"test",
253-
"runtime",
254-
"xwatcher",
255-
"bsb",
256-
"common"
257-
]);
258-
259-
exec(/* () */0);
243+
var match = Process.argv.slice(2);
244+
245+
var exit = 0;
246+
247+
if (match.length !== 1) {
248+
exit = 1;
249+
} else {
250+
var match$1 = match[0];
251+
if (match$1 === "-build") {
252+
Child_process.spawn(command, ( [ ]), ( { "stdio" : "inherit", "shell" : true }));
253+
} else {
254+
exit = 1;
255+
}
256+
}
257+
258+
if (exit === 1) {
259+
iter$$1(function (x) {
260+
watch$1(Path.join(jscomp, x));
261+
return /* () */0;
262+
}, /* array */[
263+
"core",
264+
"syntax",
265+
"ext",
266+
"depends",
267+
"others",
268+
"ounit",
269+
"ounit_tests",
270+
"test",
271+
"runtime",
272+
"xwatcher",
273+
"bsb",
274+
"common"
275+
]);
276+
exec(/* () */0);
277+
}
260278

261279

262280
/* Not a pure module */

0 commit comments

Comments
 (0)