Skip to content

Commit

Permalink
Remove hardcoded target in Main plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
hakantunc committed Mar 3, 2016
1 parent 1f6c898 commit 8f3146d
Show file tree
Hide file tree
Showing 7 changed files with 381,856 additions and 356,442 deletions.
27 changes: 20 additions & 7 deletions src/plugins/Main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ define([ 'plugin/PluginConfig',
Main.prototype.main = function (callback) {
var self = this;
var path = require('path');
var target = self._getTarget(self.activeNode);

if ( (self._currentConfig.goal === 'compileApp'|| self._currentConfig.goal === 'generateModule') && !target) {
return callCallback('No target', false);
}

switch (self._currentConfig.goal) {
case 'generateNescCode':
Expand All @@ -57,7 +62,7 @@ define([ 'plugin/PluginConfig',
case 'generateModule':
self.logger.info('generateModule');
var module_util = new ModuleUtil(self);
module_util.generateModule(self.activeNode, 'exp430')
module_util.generateModule(self.activeNode, target)
.then (function () {
return self.save('Internal structure of a module is generated');
})
Expand All @@ -67,10 +72,10 @@ define([ 'plugin/PluginConfig',
break;
case 'compileApp':
self.logger.info('compileApp');
NescUtil.compileApp(self, self.activeNode, 'exp430')
NescUtil.compileApp(self, self.activeNode, target)
.then(function (tmp_path) {
var name = self.core.getAttribute(self.activeNode, 'name');
return NescUtil.addBlobs(self, path.join(tmp_path, 'build/exp430'), name);
return NescUtil.addBlobs(self, path.join(tmp_path, 'build', target), name);
})
.then(function (download_url) {
self.createMessage(self.activeNode, {
Expand All @@ -85,7 +90,7 @@ define([ 'plugin/PluginConfig',
break;
case 'importApp':
self.logger.info('importApp for', self._currentConfig.app_path);
var importer_util = new ImporterUtil(self, 'exp430');
var importer_util = new ImporterUtil(self, self._currentConfig.target);
importer_util.importAComponentFromPath(self._currentConfig.app_path)
.then(function () {
return self.save(self._currentConfig.app_path + ' ..imported');
Expand All @@ -98,11 +103,11 @@ define([ 'plugin/PluginConfig',
});
break;
case 'importTos':
self.logger.info('import Tos for', 'exp430');
importer_util = new ImporterUtil(self, 'exp430');
self.logger.info('import Tos for', self._currentConfig.target);
importer_util = new ImporterUtil(self, self._currentConfig.target);
importer_util.importAllTosComponents()
.then(function () {
return self.save('Tos imported for exp430');
return self.save('Tos imported for ' + self._currentConfig.target);
})
.then(function () {
callCallback(null, true);
Expand All @@ -120,5 +125,13 @@ define([ 'plugin/PluginConfig',

};

Main.prototype._getTarget = function (node) {
var p = this.core.getParent(node);
if (p) {
return this.core.getAttribute(p, 'target');
}
return null;
};

return Main;
});
1 change: 1 addition & 0 deletions src/plugins/utils/ImporterUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ ImporterUtil.prototype._mkdirp = function (file_path) {
base: self._context.META.Folder
});
self._core.setAttribute(dir_node, 'name', dir);
self._core.setAttribute(dir_node, 'target', self._target);
self._registry_paths.folders[curr_path] = self._core.getPath(dir_node);
self._nodes[self._registry_paths.folders[curr_path]] = dir_node;
}
Expand Down
11 changes: 7 additions & 4 deletions src/scripts/cli-import
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ program
.option('-n --new', 'Create new project')
.option('-p --project [string]', 'Project [mandatory]')
.option('-b --branch [string]', 'Branch [default is master]')
.option('-t --target', 'Target platform')
.option('-t --target', 'Target platform [default is exp430')
.option('-r --recursive', 'Recursive')
.option('-a --all', 'Import all TOS')
.parse(process.argv);
Expand Down Expand Up @@ -50,7 +50,8 @@ if (program.new) {
var obj = {};
if (program.all) {
obj = {
goal: 'importTos'
goal: 'importTos',
target: program.target || 'exp430'
};
run_plugin();
} else if (program.recursive) {
Expand All @@ -61,7 +62,8 @@ if (program.all) {
if (fs.existsSync(path.join(dir_path, file, 'Makefile'))) {
obj = {
goal: 'importApp',
app_path: path.join(dir_path, file)
app_path: path.join(dir_path, file),
target: program.target || 'exp430'
};
run_plugin();
}
Expand All @@ -71,7 +73,8 @@ if (program.all) {
var app_path = path.resolve(process.cwd(), program.args[0]);
obj = {
goal: 'importApp',
app_path: app_path
app_path: app_path,
target: program.target || 'exp430'
};
run_plugin();
}
Expand Down
Loading

0 comments on commit 8f3146d

Please sign in to comment.