summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoão Henrique Ferreira de Freitas <joaohf@gmail.com>2014-05-14 22:37:28 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-05-21 09:09:02 +0100
commit32a811f71b9b54708cd06e18ab7e7a7690207a9d (patch)
tree3ba9da5a171bdf3df418fd133a87a01335e70207 /scripts
parent8af57a6ca269203b79aacfa3048dc177df2cf6ac (diff)
downloadpoky-32a811f71b9b54708cd06e18ab7e7a7690207a9d.tar.gz
wic: add support to look in all layers and get plugins
Plugins are looked in 'scripts/lib/mic/plugins/[type]/' directory on all BBLAYERS variable returned by bitbake environment. If found, it will be load at runtime. The user could create your own plugin and keep it inside its layers. For now the path must be <layer-dir>/scripts/lib/mic/plugins/[type]/. Where 'type' could be 'imager' or 'source'. (From OE-Core rev: bb6f5d7de1c7ce2680874a74949903db0f5bb91a) Signed-off-by: João Henrique Ferreira de Freitas <joaohf@gmail.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/mic/plugin.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/scripts/lib/mic/plugin.py b/scripts/lib/mic/plugin.py
index df03c15081..bec33d6164 100644
--- a/scripts/lib/mic/plugin.py
+++ b/scripts/lib/mic/plugin.py
@@ -20,12 +20,14 @@ import os, sys
20from mic import msger 20from mic import msger
21from mic import pluginbase 21from mic import pluginbase
22from mic.utils import errors 22from mic.utils import errors
23 23from mic.utils.oe.misc import *
24 24
25__ALL__ = ['PluginMgr', 'pluginmgr'] 25__ALL__ = ['PluginMgr', 'pluginmgr']
26 26
27PLUGIN_TYPES = ["imager", "source"] # TODO "hook" 27PLUGIN_TYPES = ["imager", "source"] # TODO "hook"
28 28
29PLUGIN_DIR = "/lib/mic/plugins" # relative to scripts
30SCRIPTS_PLUGIN_DIR = "scripts" + PLUGIN_DIR
29 31
30class PluginMgr(object): 32class PluginMgr(object):
31 plugin_dirs = {} 33 plugin_dirs = {}
@@ -42,8 +44,23 @@ class PluginMgr(object):
42 mic_path = os.path.dirname(__file__) 44 mic_path = os.path.dirname(__file__)
43 eos = mic_path.find('scripts') + len('scripts') 45 eos = mic_path.find('scripts') + len('scripts')
44 scripts_path = mic_path[:eos] 46 scripts_path = mic_path[:eos]
47 self.scripts_path = scripts_path
48 self.plugin_dir = scripts_path + PLUGIN_DIR
49 self.layers_path = None
50
51 def _build_plugin_dir_list(self, dl, ptype):
52 if self.layers_path is None:
53 self.layers_path = get_bitbake_var("BBLAYERS")
54 layer_dirs = []
55
56 for layer_path in self.layers_path.split():
57 path = os.path.join(layer_path, SCRIPTS_PLUGIN_DIR, ptype)
58 layer_dirs.append(path)
45 59
46 self.plugin_dir = scripts_path + "/lib/mic/plugins" 60 path = os.path.join(dl, ptype)
61 layer_dirs.append(path)
62
63 return layer_dirs
47 64
48 def append_dirs(self, dirs): 65 def append_dirs(self, dirs):
49 for path in dirs: 66 for path in dirs:
@@ -56,7 +73,7 @@ class PluginMgr(object):
56 path = os.path.abspath(os.path.expanduser(path)) 73 path = os.path.abspath(os.path.expanduser(path))
57 74
58 if not os.path.isdir(path): 75 if not os.path.isdir(path):
59 msger.warning("Plugin dir is not a directory or does not exist: %s"\ 76 msger.debug("Plugin dir is not a directory or does not exist: %s"\
60 % path) 77 % path)
61 return 78 return
62 79
@@ -93,8 +110,9 @@ class PluginMgr(object):
93 if ptype not in PLUGIN_TYPES: 110 if ptype not in PLUGIN_TYPES:
94 raise errors.CreatorError('%s is not valid plugin type' % ptype) 111 raise errors.CreatorError('%s is not valid plugin type' % ptype)
95 112
96 self._add_plugindir(os.path.join(self.plugin_dir, ptype)) 113 plugins_dir = self._build_plugin_dir_list(self.plugin_dir, ptype)
97 self._load_all() 114
115 self.append_dirs(plugins_dir)
98 116
99 return pluginbase.get_plugins(ptype) 117 return pluginbase.get_plugins(ptype)
100 118