Fix the way we pass compiler options instead of assuming via the environment
This commit is contained in:
parent
2c2e54b613
commit
05dea5844a
|
@ -332,7 +332,7 @@ Config.prototype.loadEmbarkConfigFile = function() {
|
|||
var configObject = {
|
||||
options: {
|
||||
solc: {
|
||||
"optimize": (this.env != 'test'),
|
||||
"optimize": true,
|
||||
"optimize-runs": 200
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,12 @@ class Compiler {
|
|||
this.events = embark.events;
|
||||
this.logger = embark.logger;
|
||||
|
||||
this.events.setCommandHandler("compiler:contracts", function(contractFiles, cb) {
|
||||
self.compile_contracts(contractFiles, cb);
|
||||
this.events.setCommandHandler("compiler:contracts", function(contractFiles, options, cb) {
|
||||
self.compile_contracts(contractFiles, options, cb);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
compile_contracts(contractFiles, cb) {
|
||||
compile_contracts(contractFiles, options, cb) {
|
||||
const self = this;
|
||||
let available_compilers = {};
|
||||
|
||||
|
@ -42,7 +41,7 @@ class Compiler {
|
|||
if (!matchingFiles || !matchingFiles.length) {
|
||||
return callback();
|
||||
}
|
||||
compiler.call(compiler, matchingFiles, function (err, compileResult) {
|
||||
compiler.call(compiler, matchingFiles, options, function (err, compileResult) {
|
||||
Object.assign(compiledObject, compileResult);
|
||||
callback(err, compileResult);
|
||||
});
|
||||
|
|
|
@ -17,6 +17,7 @@ class ContractsManager {
|
|||
this.deployOnlyOnConfig = false;
|
||||
this.compileError = false;
|
||||
this.compileOnceOnly = options.compileOnceOnly;
|
||||
this.disableOptimizations = options.disableOptimizations;
|
||||
|
||||
self.events.setCommandHandler('contracts:list', (cb) => {
|
||||
cb(self.compileError, self.listContracts());
|
||||
|
@ -63,6 +64,9 @@ class ContractsManager {
|
|||
build(done) {
|
||||
let self = this;
|
||||
self.contracts = {};
|
||||
|
||||
let compilerOptions = {disableOptimizations: this.disableOptimizations};
|
||||
|
||||
async.waterfall([
|
||||
function loadContractFiles(callback) {
|
||||
self.events.request("config:contractsFiles", (contractsFiles) => {
|
||||
|
@ -82,7 +86,7 @@ class ContractsManager {
|
|||
// Only compile once for tests
|
||||
return callback();
|
||||
}
|
||||
self.events.request("compiler:contracts", self.contractsFiles, function (err, compiledObject) {
|
||||
self.events.request("compiler:contracts", self.contractsFiles, compilerOptions, function (err, compiledObject) {
|
||||
self.compiledContracts = compiledObject;
|
||||
callback(err);
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ class Solidity {
|
|||
embark.registerCompiler(".sol", this.compile_solidity.bind(this));
|
||||
}
|
||||
|
||||
compile_solidity(contractFiles, cb) {
|
||||
compile_solidity(contractFiles, options, cb) {
|
||||
if (!contractFiles.length) {
|
||||
return cb();
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class Solidity {
|
|||
sources: input,
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: self.options.optimize,
|
||||
enabled: (!options.disableOptimizations && self.options.optimize),
|
||||
runs: self.options["optimize-runs"]
|
||||
},
|
||||
outputSelection: {
|
||||
|
|
|
@ -32,7 +32,7 @@ class Vyper {
|
|||
});
|
||||
}
|
||||
|
||||
compile_vyper(contractFiles, cb) {
|
||||
compile_vyper(contractFiles, _options, cb) {
|
||||
const self = this;
|
||||
if (!contractFiles || !contractFiles.length) {
|
||||
return cb();
|
||||
|
|
|
@ -109,7 +109,8 @@ class Test {
|
|||
});
|
||||
this.engine.startService("deployment", {
|
||||
trackContracts: false,
|
||||
compileOnceOnly: true
|
||||
compileOnceOnly: true,
|
||||
disableOptimizations: true
|
||||
});
|
||||
this.events.request('deploy:setGasLimit', 6000000);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ describe('embark.Compiler', function() {
|
|||
compiler.compile_solidity([
|
||||
readFile('test/contracts/simple_storage.sol'),
|
||||
readFile('test/contracts/token.sol')
|
||||
], function(err, compiledContracts) {
|
||||
], {}, function(err, compiledContracts) {
|
||||
assert.deepEqual(compiledContracts, expectedObject);
|
||||
done();
|
||||
});
|
||||
|
@ -122,7 +122,7 @@ describe('embark.Compiler', function() {
|
|||
compiler.compile_solidity([
|
||||
readFile('test/contracts/simple_storage.sol'),
|
||||
readFile('test/contracts/token.sol')
|
||||
], function(err, compiledContracts) {
|
||||
], {}, function(err, compiledContracts) {
|
||||
assert.deepEqual(compiledContracts, expectedObject);
|
||||
done();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue