diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-01-23 00:52:21 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-01-22 12:45:44 +0000 |
commit | 76a281c870621f5b5608d098a70504c6069ccd11 (patch) | |
tree | 424154ecbd9cff7be886487d5c5c23bc16259a87 | |
parent | 11a1f496304b5273a13dac0acb27815ecfcb8714 (diff) | |
download | poky-76a281c870621f5b5608d098a70504c6069ccd11.tar.gz |
bitbake: taskdata: add the ability to access world targets list
In certain circumstances it can be useful to get access to the world
targets list from a recipe in order to add dependencies on some or all
of the items in it. If a special function, 'calculate_extra_depends' is
defined in the recipe, and the recipe is to be built, then call it at
the right point before we calculate which tasks should be run. The
function can append items to the "deps" list in order to add
dependencies. This is not as tidy a solution as I would have liked, but
it does at least do the job.
As part of this change, the buildWorldTargets function was moved to
bb.providers to make it possible to call from taskdata.
Part of the implementation of [YOCTO #8600].
(Bitbake rev: aba0dce57c889495ec5c13919991a060aeff65d2)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/cache.py | 5 | ||||
-rw-r--r-- | bitbake/lib/bb/cooker.py | 24 | ||||
-rw-r--r-- | bitbake/lib/bb/providers.py | 26 | ||||
-rw-r--r-- | bitbake/lib/bb/taskdata.py | 17 |
4 files changed, 48 insertions, 24 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py index 83f2ff1561..8485eb467a 100644 --- a/bitbake/lib/bb/cache.py +++ b/bitbake/lib/bb/cache.py | |||
@@ -43,7 +43,7 @@ except ImportError: | |||
43 | logger.info("Importing cPickle failed. " | 43 | logger.info("Importing cPickle failed. " |
44 | "Falling back to a very slow implementation.") | 44 | "Falling back to a very slow implementation.") |
45 | 45 | ||
46 | __cache_version__ = "148" | 46 | __cache_version__ = "149" |
47 | 47 | ||
48 | def getCacheFile(path, filename, data_hash): | 48 | def getCacheFile(path, filename, data_hash): |
49 | return os.path.join(path, filename + "." + data_hash) | 49 | return os.path.join(path, filename + "." + data_hash) |
@@ -144,6 +144,7 @@ class CoreRecipeInfo(RecipeInfoCommon): | |||
144 | self.fakerootenv = self.getvar('FAKEROOTENV', metadata) | 144 | self.fakerootenv = self.getvar('FAKEROOTENV', metadata) |
145 | self.fakerootdirs = self.getvar('FAKEROOTDIRS', metadata) | 145 | self.fakerootdirs = self.getvar('FAKEROOTDIRS', metadata) |
146 | self.fakerootnoenv = self.getvar('FAKEROOTNOENV', metadata) | 146 | self.fakerootnoenv = self.getvar('FAKEROOTNOENV', metadata) |
147 | self.extradepsfunc = self.getvar('calculate_extra_depends', metadata) | ||
147 | 148 | ||
148 | @classmethod | 149 | @classmethod |
149 | def init_cacheData(cls, cachedata): | 150 | def init_cacheData(cls, cachedata): |
@@ -179,6 +180,7 @@ class CoreRecipeInfo(RecipeInfoCommon): | |||
179 | cachedata.fakerootenv = {} | 180 | cachedata.fakerootenv = {} |
180 | cachedata.fakerootnoenv = {} | 181 | cachedata.fakerootnoenv = {} |
181 | cachedata.fakerootdirs = {} | 182 | cachedata.fakerootdirs = {} |
183 | cachedata.extradepsfunc = {} | ||
182 | 184 | ||
183 | def add_cacheData(self, cachedata, fn): | 185 | def add_cacheData(self, cachedata, fn): |
184 | cachedata.task_deps[fn] = self.task_deps | 186 | cachedata.task_deps[fn] = self.task_deps |
@@ -246,6 +248,7 @@ class CoreRecipeInfo(RecipeInfoCommon): | |||
246 | cachedata.fakerootenv[fn] = self.fakerootenv | 248 | cachedata.fakerootenv[fn] = self.fakerootenv |
247 | cachedata.fakerootnoenv[fn] = self.fakerootnoenv | 249 | cachedata.fakerootnoenv[fn] = self.fakerootnoenv |
248 | cachedata.fakerootdirs[fn] = self.fakerootdirs | 250 | cachedata.fakerootdirs[fn] = self.fakerootdirs |
251 | cachedata.extradepsfunc[fn] = self.extradepsfunc | ||
249 | 252 | ||
250 | 253 | ||
251 | 254 | ||
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 74190ec9a7..9c58d95006 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -1109,28 +1109,6 @@ class BBCooker: | |||
1109 | tree = self.generatePkgDepTreeData(pkgs, 'build') | 1109 | tree = self.generatePkgDepTreeData(pkgs, 'build') |
1110 | bb.event.fire(bb.event.TargetsTreeGenerated(tree), self.data) | 1110 | bb.event.fire(bb.event.TargetsTreeGenerated(tree), self.data) |
1111 | 1111 | ||
1112 | def buildWorldTargetList(self): | ||
1113 | """ | ||
1114 | Build package list for "bitbake world" | ||
1115 | """ | ||
1116 | parselog.debug(1, "collating packages for \"world\"") | ||
1117 | for f in self.recipecache.possible_world: | ||
1118 | terminal = True | ||
1119 | pn = self.recipecache.pkg_fn[f] | ||
1120 | |||
1121 | for p in self.recipecache.pn_provides[pn]: | ||
1122 | if p.startswith('virtual/'): | ||
1123 | parselog.debug(2, "World build skipping %s due to %s provider starting with virtual/", f, p) | ||
1124 | terminal = False | ||
1125 | break | ||
1126 | for pf in self.recipecache.providers[p]: | ||
1127 | if self.recipecache.pkg_fn[pf] != pn: | ||
1128 | parselog.debug(2, "World build skipping %s due to both us and %s providing %s", f, pf, p) | ||
1129 | terminal = False | ||
1130 | break | ||
1131 | if terminal: | ||
1132 | self.recipecache.world_target.add(pn) | ||
1133 | |||
1134 | def interactiveMode( self ): | 1112 | def interactiveMode( self ): |
1135 | """Drop off into a shell""" | 1113 | """Drop off into a shell""" |
1136 | try: | 1114 | try: |
@@ -1591,7 +1569,7 @@ class BBCooker: | |||
1591 | parselog.warn("Explicit target \"%s\" is in ASSUME_PROVIDED, ignoring" % pkg) | 1569 | parselog.warn("Explicit target \"%s\" is in ASSUME_PROVIDED, ignoring" % pkg) |
1592 | 1570 | ||
1593 | if 'world' in pkgs_to_build: | 1571 | if 'world' in pkgs_to_build: |
1594 | self.buildWorldTargetList() | 1572 | bb.providers.buildWorldTargetList(self.recipecache) |
1595 | pkgs_to_build.remove('world') | 1573 | pkgs_to_build.remove('world') |
1596 | for t in self.recipecache.world_target: | 1574 | for t in self.recipecache.world_target: |
1597 | pkgs_to_build.append(t) | 1575 | pkgs_to_build.append(t) |
diff --git a/bitbake/lib/bb/providers.py b/bitbake/lib/bb/providers.py index 637e1fab96..68c8d592d2 100644 --- a/bitbake/lib/bb/providers.py +++ b/bitbake/lib/bb/providers.py | |||
@@ -379,3 +379,29 @@ def getRuntimeProviders(dataCache, rdepend): | |||
379 | logger.debug(1, "Assuming %s is a dynamic package, but it may not exist" % rdepend) | 379 | logger.debug(1, "Assuming %s is a dynamic package, but it may not exist" % rdepend) |
380 | 380 | ||
381 | return rproviders | 381 | return rproviders |
382 | |||
383 | |||
384 | def buildWorldTargetList(dataCache): | ||
385 | """ | ||
386 | Build package list for "bitbake world" | ||
387 | """ | ||
388 | if dataCache.world_target: | ||
389 | return | ||
390 | |||
391 | logger.debug(1, "collating packages for \"world\"") | ||
392 | for f in dataCache.possible_world: | ||
393 | terminal = True | ||
394 | pn = dataCache.pkg_fn[f] | ||
395 | |||
396 | for p in dataCache.pn_provides[pn]: | ||
397 | if p.startswith('virtual/'): | ||
398 | logger.debug(2, "World build skipping %s due to %s provider starting with virtual/", f, p) | ||
399 | terminal = False | ||
400 | break | ||
401 | for pf in dataCache.providers[p]: | ||
402 | if dataCache.pkg_fn[pf] != pn: | ||
403 | logger.debug(2, "World build skipping %s due to both us and %s providing %s", f, pf, p) | ||
404 | terminal = False | ||
405 | break | ||
406 | if terminal: | ||
407 | dataCache.world_target.add(pn) | ||
diff --git a/bitbake/lib/bb/taskdata.py b/bitbake/lib/bb/taskdata.py index 39c899ebb7..6e4d149e5a 100644 --- a/bitbake/lib/bb/taskdata.py +++ b/bitbake/lib/bb/taskdata.py | |||
@@ -172,6 +172,8 @@ class TaskData: | |||
172 | if fnid in self.tasks_fnid: | 172 | if fnid in self.tasks_fnid: |
173 | return | 173 | return |
174 | 174 | ||
175 | self.add_extra_deps(fn, dataCache) | ||
176 | |||
175 | for task in task_deps['tasks']: | 177 | for task in task_deps['tasks']: |
176 | 178 | ||
177 | # Work out task dependencies | 179 | # Work out task dependencies |
@@ -242,6 +244,21 @@ class TaskData: | |||
242 | self.fail_fnid(fnid) | 244 | self.fail_fnid(fnid) |
243 | return | 245 | return |
244 | 246 | ||
247 | def add_extra_deps(self, fn, dataCache): | ||
248 | func = dataCache.extradepsfunc.get(fn, None) | ||
249 | if func: | ||
250 | bb.providers.buildWorldTargetList(dataCache) | ||
251 | pn = dataCache.pkg_fn[fn] | ||
252 | params = {'deps': dataCache.deps[fn], | ||
253 | 'world_target': dataCache.world_target, | ||
254 | 'pkg_pn': dataCache.pkg_pn, | ||
255 | 'self_pn': pn} | ||
256 | funcname = '_%s_calculate_extra_depends' % pn.replace('-', '_') | ||
257 | paramlist = ','.join(params.keys()) | ||
258 | func = 'def %s(%s):\n%s\n\n%s(%s)' % (funcname, paramlist, func, funcname, paramlist) | ||
259 | bb.utils.better_exec(func, params) | ||
260 | |||
261 | |||
245 | def have_build_target(self, target): | 262 | def have_build_target(self, target): |
246 | """ | 263 | """ |
247 | Have we a build target matching this name? | 264 | Have we a build target matching this name? |