diff --git a/lib/contracts/compiler.js b/lib/contracts/compiler.js index 450067da..15f13b16 100644 --- a/lib/contracts/compiler.js +++ b/lib/contracts/compiler.js @@ -7,6 +7,7 @@ class Compiler { this.plugins = options.plugins; this.logger = options.logger; this.solcVersion = options.solcVersion; + this.contractDirectories = options.contractDirectories; } compile_contracts(contractFiles, cb) { @@ -56,7 +57,12 @@ class Compiler { function prepareInput(callback) { async.each(contractFiles, function(file, fileCb) { - let filename = file.filename.replace('app/contracts/', ''); + let filename = file.filename; + + for (let directory of self.contractDirectories) { + filename = filename.replace(directory, ''); + } + file.content(function(fileContent) { input[filename] = fileContent; fileCb(); diff --git a/lib/contracts/contracts.js b/lib/contracts/contracts.js index 559fa327..8c7616f4 100644 --- a/lib/contracts/contracts.js +++ b/lib/contracts/contracts.js @@ -8,6 +8,7 @@ let Compiler = require('./compiler.js'); class ContractsManager { constructor(options) { this.contractFiles = options.contractFiles; + this.contractDirectories = options.contractDirectories; this.contractsConfig = options.contractsConfig; this.contracts = {}; this.logger = options.logger; @@ -25,7 +26,7 @@ class ContractsManager { let self = this; async.waterfall([ function compileContracts(callback) { - let compiler = new Compiler({plugins: self.plugins, logger: self.logger, solcVersion: self.solcVersion}); + let compiler = new Compiler({plugins: self.plugins, logger: self.logger, solcVersion: self.solcVersion, contractDirectories: self.contractDirectories}); compiler.compile_contracts(self.contractFiles, function (err, compiledObject) { self.compiledContracts = compiledObject; callback(err); diff --git a/lib/contracts/deploy_manager.js b/lib/contracts/deploy_manager.js index 975abae0..9614af1f 100644 --- a/lib/contracts/deploy_manager.js +++ b/lib/contracts/deploy_manager.js @@ -26,6 +26,7 @@ class DeployManager { function buildContracts(callback) { let contractsManager = new ContractsManager({ contractFiles: self.config.contractsFiles, + contractDirectories: self.config.contractDirectories, contractsConfig: self.config.contractsConfig, logger: self.logger, plugins: self.plugins diff --git a/lib/core/config.js b/lib/core/config.js index 53825ea4..fc7c2847 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -198,6 +198,12 @@ Config.prototype.loadWebServerConfigFile = function() { Config.prototype.loadEmbarkConfigFile = function() { var contracts = this.embarkConfig.contracts; this.contractsFiles = this.loadFiles(contracts); + // determine contract 'root' directories + this.contractDirectories = contracts.map((dir) => { + return dir.split("**")[0]; + }).map((dir) => { + return dir.split("*.")[0]; + }); this.buildDir = this.embarkConfig.buildDir; this.configDir = this.embarkConfig.config;