Just wanted to let you guys know that I finally got an early prototype of a rescript web IDE running! The ninja part is probably far from optimal, because that’s the first c++ code I have ever written/dug into, same thing with ocaml… So I basically removed this code part: ninja/build.cc at 3a477ee7cac769d25f0a8993612a7ea59411e48c · rescript-lang/ninja · GitHub and replaced it with this:
while (pending_commands >= 0) {
if (Edge* edge = plan_.FindWork()) {
string command = edge->EvaluateCommand(true);
printf("RUN_CMD %s \n", command.c_str());
for (int i = 0; i < edge->outputs_.size(); i++) {
Node* subnode = edge->outputs_[i];
for (int i = 0; i < subnode->out_edges().size(); i++) {
Edge* subedge = subnode->out_edges()[i];
string subcommand = subedge->EvaluateCommand(true);
printf("RUN_CMD %s \n", subcommand.c_str());
}
}
}
--pending_commands;
}
Because it would get stuck when trying to execute a bsc.exe command with posix_spawn at: ninja/subprocess-posix.cc at 3a477ee7cac769d25f0a8993612a7ea59411e48c · rescript-lang/ninja · GitHub
Not sure if this will even spit out all cmd’s, only tested it with a 2 .res files project, but I’m able to generate all the .ast .cmi .cmt .cmj files and can analyse them with a browser version of rescript-vscode/analysis at master · rescript-lang/rescript-vscode · GitHub. And real binary format, not base64 encoded.
So now ninja probably never cleanly finishes it’s stuff and always does a full rebuild, it actually builds nothing and just works as a .ninja file parser/reader, I think.
Is this even the right approach, running ninja in the browser? Maybe a bit overkill? I have already spend way too much time on this, but I could imagine emulating this posix_spawn call with a webworker postMessage. So if you have any tipps/ideas/hints on how to get ninja working, please let me know!
Anyways, for me that’s the coolest project I have ever worked on and I absolutely Love Rescript! I always had an eye on reasonml and after the recent syntax changes I gave rescript a try and boom (dumped all my typescript code)
Next part will be building a repl, something like https://stackblitz.com/ has.