Skip to content

Commit d631242

Browse files
committed
enhance dev workflow
- when start task in vscode, it does not need stop anymore
1 parent e874082 commit d631242

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

jscomp/test/string_set.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1 "ext/set.cppo.ml"
1+
22
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
33
*
44
* This program is free software: you can redistribute it and/or modify

scripts/ninja.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,12 +1608,14 @@ function nativeNinja() {
16081608
var templateNative = `
16091609
subninja ${getPreprocessorFileName()}
16101610
rule optc
1611-
command = $ocamlopt -safe-string -I +compiler-libs -opaque ${includes} -g -w +6-40-30-23 -warn-error +a-40-30-23 -absname -c $in
1611+
command = $ocamlopt -safe-string -I +compiler-libs -opaque ${includes} -g -w a-50+6-40-30-23 -warn-error +a -absname -c $in
16121612
description = $out : $in
16131613
rule archive
16141614
command = $ocamlopt -a $in -o $out
1615+
description = arcive -> $out
16151616
rule link
16161617
command = $ocamlopt -g -I +compiler-libs $flags $libs $in -o $out
1618+
description = linking -> $out
16171619
rule mk_bsversion
16181620
command = node $in
16191621
generator = true

scripts/tasks.js

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ var isBuilding = false;
2828
var ninjaFile = require("./ninja.js");
2929
var jscompDir = path.join("..", "jscomp");
3030
function rebuild() {
31-
console.log(">>>> Start compiling");
3231
if (isBuilding) {
3332
buildAppending = true;
3433
} else {
34+
console.log(">>>> Start compiling");
3535
isBuilding = true;
3636
var p = cp.spawn(ninjaFile.vendorNinjaPath, [], {
3737
stdio: ["inherit", "inherit", "pipe"]
@@ -54,7 +54,7 @@ function buildFinished(code, signal) {
5454
console.log(`File "BUILD", line 1, characters 1-1:`);
5555
console.log(`Error: Failed to build`);
5656
}
57-
console.log(">>>> Finish compiling");
57+
console.log(">>>> Finish compiling (options: R|clean|config)");
5858
// TODO: check ninja exit error code
5959
if (code === 0) {
6060
// This is not always correct
@@ -78,3 +78,45 @@ sourceDirs.forEach(x => {
7878
fs.watch(path.join(jscompDir, x), "utf8", onSourceChange);
7979
});
8080
rebuild();
81+
82+
const readline = require("readline");
83+
84+
const rl = readline.createInterface({
85+
input: process.stdin,
86+
output: process.stdout
87+
});
88+
89+
var child_process = require("child_process");
90+
rl.on("line", input => {
91+
switch (input.toLowerCase()) {
92+
case "r":
93+
rebuild();
94+
break;
95+
case "config":
96+
if (isBuilding) {
97+
console.log(`it's building`);
98+
} else {
99+
isBuilding = true;
100+
child_process
101+
.fork(path.join(__dirname, "ninja.js"), ["config"])
102+
.on("close", () => {
103+
isBuilding = false;
104+
rebuild();
105+
});
106+
}
107+
break;
108+
case "clean":
109+
if (isBuilding) {
110+
console.log(`it's building`);
111+
} else {
112+
isBuilding = true;
113+
child_process
114+
.fork(path.join(__dirname, "ninja.js"), ["cleanbuild"])
115+
.on("close", () => {
116+
isBuilding = false;
117+
});
118+
}
119+
120+
break;
121+
}
122+
});

0 commit comments

Comments
 (0)