From 6ae697f36a9e6c15b5ac3388686f275e3bda0da7 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 20 Aug 2018 09:27:23 -0400 Subject: [PATCH] add solc options --- lib/core/config.js | 15 ++++++++++++++- lib/modules/solidity/index.js | 5 +++-- test_apps/test_app/embark.json | 6 ++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/core/config.js b/lib/core/config.js index 66e3259b..6582b205 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -54,11 +54,11 @@ Config.prototype.loadConfigFiles = function(options) { this.embarkConfig = fs.readJSONSync(options.embarkConfig); this.embarkConfig.plugins = this.embarkConfig.plugins || {}; + this.loadEmbarkConfigFile(); this.plugins = new Plugins({plugins: this.embarkConfig.plugins, logger: this.logger, interceptLogs: interceptLogs, events: this.events, config: this, context: this.context, env: this.env}); this.plugins.loadPlugins(); - this.loadEmbarkConfigFile(); this.loadBlockchainConfigFile(); this.loadStorageConfigFile(); this.loadCommunicationConfigFile(); @@ -329,6 +329,17 @@ Config.prototype.loadWebServerConfigFile = function() { }; Config.prototype.loadEmbarkConfigFile = function() { + var configObject = { + options: { + solc: { + "optimize": true, + "optimize-runs": 200 + } + } + }; + + this.embarkConfig = this._mergeConfig(this.embarkConfig, configObject, true); + const contracts = this.embarkConfig.contracts; const newContractsFiles = this.loadFiles(contracts); if (!this.contractFiles || newContractsFiles.length !== this.contractFiles.length || !deepEqual(newContractsFiles, this.contractFiles)) { @@ -348,6 +359,8 @@ Config.prototype.loadEmbarkConfigFile = function() { this.buildDir = this.embarkConfig.buildDir; this.configDir = this.embarkConfig.config; + + }; Config.prototype.loadPipelineConfigFile = function() { diff --git a/lib/modules/solidity/index.js b/lib/modules/solidity/index.js index 2bcfebf2..aeaa7320 100644 --- a/lib/modules/solidity/index.js +++ b/lib/modules/solidity/index.js @@ -11,6 +11,7 @@ class Solidity { this.solcAlreadyLoaded = false; this.solcW = null; this.useDashboard = options.useDashboard; + this.options = embark.config.embarkConfig.options.solc; embark.registerCompiler(".sol", this.compile_solidity.bind(this)); } @@ -65,8 +66,8 @@ class Solidity { sources: input, settings: { optimizer: { - enabled: true, - runs: 200 + enabled: self.options.optimize, + runs: self.options["optimize-runs"] }, outputSelection: { '*': { diff --git a/test_apps/test_app/embark.json b/test_apps/test_app/embark.json index ed132b71..322e0b5f 100644 --- a/test_apps/test_app/embark.json +++ b/test_apps/test_app/embark.json @@ -21,5 +21,11 @@ }, "plugins": { "embark-service": {} + }, + "options": { + "solc": { + "optimize": true, + "optimize-runs": 200 + } } }