Merge pull request #437 from embark-framework/no_solc_reload
don't unnecessary reload solc
This commit is contained in:
commit
566bcc71ae
|
@ -7,6 +7,8 @@ class Solidity {
|
||||||
this.logger = embark.logger;
|
this.logger = embark.logger;
|
||||||
this.events = embark.events;
|
this.events = embark.events;
|
||||||
this.contractDirectories = options.contractDirectories;
|
this.contractDirectories = options.contractDirectories;
|
||||||
|
this.solcAlreadyLoaded = false;
|
||||||
|
this.solcW = null;
|
||||||
|
|
||||||
embark.registerCompiler(".sol", this.compile_solidity.bind(this));
|
embark.registerCompiler(".sol", this.compile_solidity.bind(this));
|
||||||
}
|
}
|
||||||
|
@ -17,7 +19,6 @@ class Solidity {
|
||||||
}
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
let input = {};
|
let input = {};
|
||||||
let solcW;
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function prepareInput(callback) {
|
function prepareInput(callback) {
|
||||||
async.each(contractFiles,
|
async.each(contractFiles,
|
||||||
|
@ -44,14 +45,14 @@ class Solidity {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
function loadCompiler(callback) {
|
function loadCompiler(callback) {
|
||||||
// TODO: there ino need to load this twice
|
if (self.solcAlreadyLoaded) {
|
||||||
solcW = new SolcW({logger: self.logger, events: self.events});
|
|
||||||
if (solcW.isCompilerLoaded()) {
|
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
self.solcW = new SolcW({logger: self.logger, events: self.events});
|
||||||
|
|
||||||
self.logger.info(__("loading solc compiler") + "..");
|
self.logger.info(__("loading solc compiler") + "..");
|
||||||
solcW.load_compiler(function (err) {
|
self.solcW.load_compiler(function (err) {
|
||||||
|
self.solcAlreadyLoaded = true;
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -73,7 +74,7 @@ class Solidity {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
solcW.compile(jsonObj, function (output) {
|
self.solcW.compile(jsonObj, function (output) {
|
||||||
if (output.errors) {
|
if (output.errors) {
|
||||||
for (let i=0; i<output.errors.length; i++) {
|
for (let i=0; i<output.errors.length; i++) {
|
||||||
if (output.errors[i].type === 'Warning') {
|
if (output.errors[i].type === 'Warning') {
|
||||||
|
|
|
@ -49,7 +49,9 @@ class SolcW {
|
||||||
}
|
}
|
||||||
|
|
||||||
compile(jsonObj, done) {
|
compile(jsonObj, done) {
|
||||||
|
const self = this;
|
||||||
this.solcProcess.subscribeTo('result', 'compilation', (msg) => {
|
this.solcProcess.subscribeTo('result', 'compilation', (msg) => {
|
||||||
|
self.solcProcess.unsubscribeTo('result', 'compilation');
|
||||||
done(JSON.parse(msg.output));
|
done(JSON.parse(msg.output));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue