Skip to content

Commit b06904c

Browse files
committed
messing around with serving wasm
1 parent 11b5050 commit b06904c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Source/Heavy/Toolchain.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ struct Toolchain {
8585
return process.readAllProcessOutput();
8686
}
8787

88+
ChildProcess startShellScriptLongRunning(String const& scriptText, ChildProcess* process)
89+
{
90+
File scriptFile = File::createTempFile(".sh");
91+
Toolchain::deleteTempFileLater(scriptFile);
92+
93+
auto const bash = String("#!/bin/bash\n");
94+
scriptFile.replaceWithText(bash + scriptText, false, false, "\n");
95+
#if JUCE_WINDOWS
96+
auto sh = Toolchain::dir.getChildFile("bin").getChildFile("sh.exe");
97+
auto arguments = StringArray { sh.getFullPathName(), "--login", scriptFile.getFullPathName().replaceCharacter('\\', '/') };
98+
#else
99+
scriptFile.setExecutePermission(true);
100+
auto arguments = scriptFile.getFullPathName();
101+
#endif
102+
return process;
103+
}
104+
88105
private:
89106
inline static SmallArray<File> tempFilesToDelete;
90107
};

Source/Heavy/WASMExporter.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ class WASMExporter : public ExporterBase {
110110
outputFile.getChildFile("ir").deleteRecursively();
111111
outputFile.getChildFile("hv").deleteRecursively();
112112

113+
114+
File serverExecutable = Toolchain::dir.getChildFile("bin").getChildFile("server" + exeSuffix);
115+
116+
auto serverScript = serverExecutable.getFullPathName() + " " + outdir + "/js/";
117+
118+
ChildProcess process;
119+
Toolchain::startShellScriptLongRunning(serverScript, process);
120+
process.start(arguments, ChildProcess::wantStdOut | ChildProcess::wantStdErr);
121+
122+
if (shouldQuit)
123+
{
124+
process.kill();
125+
return true;
126+
}
127+
113128
// Delay to get correct exit code
114129
Time::waitForMillisecondCounter(Time::getMillisecondCounter() + 300);
115130

0 commit comments

Comments
 (0)