Skip to content

Commit

Permalink
Fix issue with multiple parallel outputs on LD
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoralves authored Sep 14, 2017
1 parent 9fd8bb0 commit 90cd945
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ app.post('/api/upload',function(req,res)
compilationOutput = '';
compilationEnded = false;
compilationSuccess = false;
compileProgram(uploadedFileName);
optimizeCode(uploadedFileName);
});
});

Expand Down Expand Up @@ -370,6 +370,41 @@ function showMainPage(req,res)
res.send(htmlString);
}

function optimizeCode(fileName)
{
console.log('optimizing ST code...');
compilationOutput += 'optimizing ST code...\r\n';
var optimizer = spawn('./st_optimizer', ['./st_files/' + fileName, './st_files/' + fileName]);

optimizer.stdout.on('data', function(data)
{
console.log('' + data);
compilationOutput += data;
compilationOutput += '\r\n';
});
optimizer.stderr.on('data', function(data)
{
console.log('' + data);
compilationOutput += data;
compilationOutput += '\r\n';
});
optimizer.on('close', function(code)
{
if (code != 0)
{
console.log('Error optimizing program. Please check console log');
compilationOutput += 'Error optimizing program. Please check console log\r\n';
compilationEnded = true;
}
else
{
console.log('Program optimized successfully');
compilationOutput += 'Program optimized successfully\r\n';
compileProgram(fileName);
}
});
}

function compileProgram(fileName)
{
console.log('compiling new program...');
Expand Down

0 comments on commit 90cd945

Please sign in to comment.