Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility for better simulator reloads #78

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
49 changes: 30 additions & 19 deletions compilers/jsio_compile/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var supportedEnvs = {
};

var _interface = null;
var compiler = null;

exports.start = function(/*optional*/ args, opts) {
if (opts && opts['interface']) {
Expand Down Expand Up @@ -38,6 +39,10 @@ exports.start = function(/*optional*/ args, opts) {
}
}

exports.getCompiler = function() {
return compiler;
}

function getPackage(fileName) {
try {
var pkg = eval('(' + J.__env.fetch(fileName) + ')');
Expand Down Expand Up @@ -209,7 +214,7 @@ exports.run = function(args, opts) {
}

// run the actual compiler
var compiler = J('import jsio.preprocessors.compiler');
compiler = J('import jsio.preprocessors.compiler');
compiler.setCompilerOpts({
debugLevel: debugLevel,
compressor: opts.compressor || ('compress' in _interface ? bind(_interface, 'compress') : null),
Expand All @@ -222,23 +227,7 @@ exports.run = function(args, opts) {
rawOpts: opts
});

compiler.compile('import jsio.base');

if (opts.additionalDeps) {
var deps = opts.additionalDeps;
var n = deps.length;

for (var i = 0; i < n; ++i) {
logger.info('compiling dependencies...', deps[i]);
compiler.compile(deps[i]);
}
}

logger.info('compiling main program', initial);

compiler.compile(initial);

compiler.generateSrc(opts, function(src) {
var onFinish = function(src) {
if (opts.appendImport) {
src = src + ';' + JSIO + '("' + initial + '")';
}
Expand All @@ -248,6 +237,28 @@ exports.run = function(args, opts) {
}

_interface.onFinish(opts, src);
});
};

if (!opts.noCompile) {
compiler.compile('import jsio.base');

if (opts.additionalDeps) {
var deps = opts.additionalDeps;
var n = deps.length;

for (var i = 0; i < n; ++i) {
logger.info('compiling dependencies...', deps[i]);
compiler.compile(deps[i]);
}
}

logger.info('compiling main program', initial);

compiler.compile(initial);

compiler.generateSrc(opts, onFinish);
} else {
onFinish(compiler.getJsioSrc(opts.includeJsio));
}
}

Loading