diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-12-13 20:07:08 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-12-14 12:25:07 +0000 |
commit | f1f3a112a02aef2e7094b4700c9a7d341ee01275 (patch) | |
tree | 25a577d27671a21492f60a4dafdc88138116e02f /bitbake | |
parent | 8c33063a1de7234e681675ee45ec7a376c84cefe (diff) | |
download | poky-f1f3a112a02aef2e7094b4700c9a7d341ee01275.tar.gz |
bitbake: tinfoil: implement server-side recipe parsing
It's not really practical for us to parse recipes on the client side, we
need to do it on the server because that's where we have the full python
environment (including any "pure" python functions defined in classes).
Thus, add some functions to tinfoil do this including a few shortcut
functions.
(Bitbake rev: 8f635815d191c9d848a92d51fdbf5e9fd3da1727)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/command.py | 44 | ||||
-rw-r--r-- | bitbake/lib/bb/tinfoil.py | 54 |
2 files changed, 81 insertions, 17 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py index d5be86dab8..b296b8ce84 100644 --- a/bitbake/lib/bb/command.py +++ b/bitbake/lib/bb/command.py | |||
@@ -493,6 +493,50 @@ class CommandsSync: | |||
493 | varparse = bb.data_smart.VariableParse(varname, datastore) | 493 | varparse = bb.data_smart.VariableParse(varname, datastore) |
494 | return varparse.python_sub(expr) | 494 | return varparse.python_sub(expr) |
495 | 495 | ||
496 | def dataStoreConnectorRelease(self, command, params): | ||
497 | dsindex = params[0] | ||
498 | if dsindex <= 0: | ||
499 | raise CommandError('dataStoreConnectorRelease: invalid index %d' % dsindex) | ||
500 | command.remotedatastores.release(dsindex) | ||
501 | |||
502 | def parseRecipeFile(self, command, params): | ||
503 | """ | ||
504 | Parse the specified recipe file (with or without bbappends) | ||
505 | and return a datastore object representing the environment | ||
506 | for the recipe. | ||
507 | """ | ||
508 | fn = params[0] | ||
509 | appends = params[1] | ||
510 | appendlist = params[2] | ||
511 | if len(params) > 3: | ||
512 | config_data_dict = params[3] | ||
513 | config_data = command.remotedatastores.receive_datastore(config_data_dict) | ||
514 | else: | ||
515 | config_data = None | ||
516 | |||
517 | if appends: | ||
518 | if appendlist is not None: | ||
519 | appendfiles = appendlist | ||
520 | else: | ||
521 | appendfiles = command.cooker.collection.get_file_appends(fn) | ||
522 | else: | ||
523 | appendfiles = [] | ||
524 | # We are calling bb.cache locally here rather than on the server, | ||
525 | # but that's OK because it doesn't actually need anything from | ||
526 | # the server barring the global datastore (which we have a remote | ||
527 | # version of) | ||
528 | if config_data: | ||
529 | # We have to use a different function here if we're passing in a datastore | ||
530 | # NOTE: we took a copy above, so we don't do it here again | ||
531 | envdata = bb.cache.parse_recipe(config_data, fn, appendfiles)[''] | ||
532 | else: | ||
533 | # Use the standard path | ||
534 | parser = bb.cache.NoCache(command.cooker.databuilder) | ||
535 | envdata = parser.loadDataFull(fn, appendfiles) | ||
536 | idx = command.remotedatastores.store(envdata) | ||
537 | return DataStoreConnectionHandle(idx) | ||
538 | parseRecipeFile.readonly = True | ||
539 | |||
496 | class CommandsAsync: | 540 | class CommandsAsync: |
497 | """ | 541 | """ |
498 | A class of asynchronous commands | 542 | A class of asynchronous commands |
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py index 459f6c1286..c551a9f1f7 100644 --- a/bitbake/lib/bb/tinfoil.py +++ b/bitbake/lib/bb/tinfoil.py | |||
@@ -26,6 +26,7 @@ from collections import OrderedDict, defaultdict | |||
26 | import bb.cache | 26 | import bb.cache |
27 | import bb.cooker | 27 | import bb.cooker |
28 | import bb.providers | 28 | import bb.providers |
29 | import bb.taskdata | ||
29 | import bb.utils | 30 | import bb.utils |
30 | import bb.command | 31 | import bb.command |
31 | from bb.cookerdata import CookerConfiguration, ConfigParameters | 32 | from bb.cookerdata import CookerConfiguration, ConfigParameters |
@@ -90,7 +91,7 @@ class TinfoilCookerAdapter: | |||
90 | def __init__(self, tinfoil): | 91 | def __init__(self, tinfoil): |
91 | self.tinfoil = tinfoil | 92 | self.tinfoil = tinfoil |
92 | def get_file_appends(self, fn): | 93 | def get_file_appends(self, fn): |
93 | return self.tinfoil.run_command('getFileAppends', fn) | 94 | return self.tinfoil.get_file_appends(fn) |
94 | def __getattr__(self, name): | 95 | def __getattr__(self, name): |
95 | if name == 'overlayed': | 96 | if name == 'overlayed': |
96 | return self.tinfoil.get_overlayed_recipes() | 97 | return self.tinfoil.get_overlayed_recipes() |
@@ -305,6 +306,34 @@ class Tinfoil: | |||
305 | def get_runtime_providers(self, rdep): | 306 | def get_runtime_providers(self, rdep): |
306 | return self.run_command('getRuntimeProviders', rdep) | 307 | return self.run_command('getRuntimeProviders', rdep) |
307 | 308 | ||
309 | def get_recipe_file(self, pn): | ||
310 | """ | ||
311 | Get the file name for the specified recipe/target. Raises | ||
312 | bb.providers.NoProvider if there is no match or the recipe was | ||
313 | skipped. | ||
314 | """ | ||
315 | best = self.find_best_provider(pn) | ||
316 | if not best: | ||
317 | skiplist = self.get_skipped_recipes() | ||
318 | taskdata = bb.taskdata.TaskData(None, skiplist=skiplist) | ||
319 | skipreasons = taskdata.get_reasons(pn) | ||
320 | if skipreasons: | ||
321 | raise bb.providers.NoProvider(skipreasons) | ||
322 | else: | ||
323 | raise bb.providers.NoProvider('Unable to find any recipe file matching %s' % pn) | ||
324 | return best[3] | ||
325 | |||
326 | def get_file_appends(self, fn): | ||
327 | return self.run_command('getFileAppends', fn) | ||
328 | |||
329 | def parse_recipe(self, pn): | ||
330 | """ | ||
331 | Parse the specified recipe and return a datastore object | ||
332 | representing the environment for the recipe. | ||
333 | """ | ||
334 | fn = self.get_recipe_file(pn) | ||
335 | return self.parse_recipe_file(fn) | ||
336 | |||
308 | def parse_recipe_file(self, fn, appends=True, appendlist=None, config_data=None): | 337 | def parse_recipe_file(self, fn, appends=True, appendlist=None, config_data=None): |
309 | """ | 338 | """ |
310 | Parse the specified recipe file (with or without bbappends) | 339 | Parse the specified recipe file (with or without bbappends) |
@@ -322,24 +351,15 @@ class Tinfoil: | |||
322 | """ | 351 | """ |
323 | if appends and appendlist == []: | 352 | if appends and appendlist == []: |
324 | appends = False | 353 | appends = False |
325 | if appends: | ||
326 | if appendlist: | ||
327 | appendfiles = appendlist | ||
328 | else: | ||
329 | if not hasattr(self.cooker, 'collection'): | ||
330 | raise Exception('You must call tinfoil.prepare() with config_only=False in order to get bbappends') | ||
331 | appendfiles = self.cooker.collection.get_file_appends(fn) | ||
332 | else: | ||
333 | appendfiles = None | ||
334 | if config_data: | 354 | if config_data: |
335 | # We have to use a different function here if we're passing in a datastore | 355 | dctr = bb.remotedata.RemoteDatastores.transmit_datastore(config_data) |
336 | localdata = bb.data.createCopy(config_data) | 356 | dscon = self.run_command('parseRecipeFile', fn, appends, appendlist, dctr) |
337 | envdata = bb.cache.parse_recipe(localdata, fn, appendfiles)[''] | 357 | else: |
358 | dscon = self.run_command('parseRecipeFile', fn, appends, appendlist) | ||
359 | if dscon: | ||
360 | return self._reconvert_type(dscon, 'DataStoreConnectionHandle') | ||
338 | else: | 361 | else: |
339 | # Use the standard path | 362 | return None |
340 | parser = bb.cache.NoCache(self.cooker.databuilder) | ||
341 | envdata = parser.loadDataFull(fn, appendfiles) | ||
342 | return envdata | ||
343 | 363 | ||
344 | def build_file(self, buildfile, task): | 364 | def build_file(self, buildfile, task): |
345 | """ | 365 | """ |