summaryrefslogtreecommitdiffstats
path: root/external/poky/bitbake/lib/bb/tinfoil.py
diff options
context:
space:
mode:
Diffstat (limited to 'external/poky/bitbake/lib/bb/tinfoil.py')
-rw-r--r--external/poky/bitbake/lib/bb/tinfoil.py195
1 files changed, 86 insertions, 109 deletions
diff --git a/external/poky/bitbake/lib/bb/tinfoil.py b/external/poky/bitbake/lib/bb/tinfoil.py
index 368264f3..8c9b6b8c 100644
--- a/external/poky/bitbake/lib/bb/tinfoil.py
+++ b/external/poky/bitbake/lib/bb/tinfoil.py
@@ -4,18 +4,8 @@
# Copyright (C) 2011 Mentor Graphics Corporation
# Copyright (C) 2006-2012 Richard Purdie
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
+# SPDX-License-Identifier: GPL-2.0-only
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import logging
import os
@@ -23,6 +13,7 @@ import sys
import atexit
import re
from collections import OrderedDict, defaultdict
+from functools import partial
import bb.cache
import bb.cooker
@@ -31,8 +22,8 @@ import bb.taskdata
import bb.utils
import bb.command
import bb.remotedata
-from bb.cookerdata import CookerConfiguration, ConfigParameters
-from bb.main import setup_bitbake, BitBakeConfigParameters, BBMainException
+from bb.cookerdata import CookerConfiguration
+from bb.main import setup_bitbake, BitBakeConfigParameters
import bb.fetch2
@@ -54,66 +45,69 @@ class TinfoilUIException(Exception):
class TinfoilCommandFailed(Exception):
"""Exception raised when run_command fails"""
+class TinfoilDataStoreConnectorVarHistory:
+ def __init__(self, tinfoil, dsindex):
+ self.tinfoil = tinfoil
+ self.dsindex = dsindex
+
+ def remoteCommand(self, cmd, *args, **kwargs):
+ return self.tinfoil.run_command('dataStoreConnectorVarHistCmd', self.dsindex, cmd, args, kwargs)
+
+ def __getattr__(self, name):
+ if not hasattr(bb.data_smart.VariableHistory, name):
+ raise AttributeError("VariableHistory has no such method %s" % name)
+
+ newfunc = partial(self.remoteCommand, name)
+ setattr(self, name, newfunc)
+ return newfunc
+
+class TinfoilDataStoreConnectorIncHistory:
+ def __init__(self, tinfoil, dsindex):
+ self.tinfoil = tinfoil
+ self.dsindex = dsindex
+
+ def remoteCommand(self, cmd, *args, **kwargs):
+ return self.tinfoil.run_command('dataStoreConnectorIncHistCmd', self.dsindex, cmd, args, kwargs)
+
+ def __getattr__(self, name):
+ if not hasattr(bb.data_smart.IncludeHistory, name):
+ raise AttributeError("IncludeHistory has no such method %s" % name)
+
+ newfunc = partial(self.remoteCommand, name)
+ setattr(self, name, newfunc)
+ return newfunc
+
class TinfoilDataStoreConnector:
- """Connector object used to enable access to datastore objects via tinfoil"""
+ """
+ Connector object used to enable access to datastore objects via tinfoil
+ Method calls are transmitted to the remote datastore for processing, if a datastore is
+ returned we return a connector object for the new store
+ """
def __init__(self, tinfoil, dsindex):
self.tinfoil = tinfoil
self.dsindex = dsindex
- def getVar(self, name):
- value = self.tinfoil.run_command('dataStoreConnectorFindVar', self.dsindex, name)
- overrides = None
- if isinstance(value, dict):
- if '_connector_origtype' in value:
- value['_content'] = self.tinfoil._reconvert_type(value['_content'], value['_connector_origtype'])
- del value['_connector_origtype']
- if '_connector_overrides' in value:
- overrides = value['_connector_overrides']
- del value['_connector_overrides']
- return value, overrides
- def getKeys(self):
- return set(self.tinfoil.run_command('dataStoreConnectorGetKeys', self.dsindex))
- def getVarHistory(self, name):
- return self.tinfoil.run_command('dataStoreConnectorGetVarHistory', self.dsindex, name)
- def expandPythonRef(self, varname, expr, d):
- ds = bb.remotedata.RemoteDatastores.transmit_datastore(d)
- ret = self.tinfoil.run_command('dataStoreConnectorExpandPythonRef', ds, varname, expr)
+ self.varhistory = TinfoilDataStoreConnectorVarHistory(tinfoil, dsindex)
+ self.inchistory = TinfoilDataStoreConnectorIncHistory(tinfoil, dsindex)
+
+ def remoteCommand(self, cmd, *args, **kwargs):
+ ret = self.tinfoil.run_command('dataStoreConnectorCmd', self.dsindex, cmd, args, kwargs)
+ if isinstance(ret, bb.command.DataStoreConnectionHandle):
+ return TinfoilDataStoreConnector(self.tinfoil, ret.dsindex)
return ret
- def setVar(self, varname, value):
- if self.dsindex is None:
- self.tinfoil.run_command('setVariable', varname, value)
- else:
- # Not currently implemented - indicate that setting should
- # be redirected to local side
- return True
- def setVarFlag(self, varname, flagname, value):
- if self.dsindex is None:
- self.tinfoil.run_command('dataStoreConnectorSetVarFlag', self.dsindex, varname, flagname, value)
- else:
- # Not currently implemented - indicate that setting should
- # be redirected to local side
- return True
- def delVar(self, varname):
- if self.dsindex is None:
- self.tinfoil.run_command('dataStoreConnectorDelVar', self.dsindex, varname)
- else:
- # Not currently implemented - indicate that setting should
- # be redirected to local side
- return True
- def delVarFlag(self, varname, flagname):
- if self.dsindex is None:
- self.tinfoil.run_command('dataStoreConnectorDelVar', self.dsindex, varname, flagname)
- else:
- # Not currently implemented - indicate that setting should
- # be redirected to local side
- return True
- def renameVar(self, name, newname):
- if self.dsindex is None:
- self.tinfoil.run_command('dataStoreConnectorRenameVar', self.dsindex, name, newname)
- else:
- # Not currently implemented - indicate that setting should
- # be redirected to local side
- return True
+
+ def __getattr__(self, name):
+ if not hasattr(bb.data._dict_type, name):
+ raise AttributeError("Data store has no such method %s" % name)
+
+ newfunc = partial(self.remoteCommand, name)
+ setattr(self, name, newfunc)
+ return newfunc
+
+ def __iter__(self):
+ keys = self.tinfoil.run_command('dataStoreConnectorCmd', self.dsindex, "keys", [], {})
+ for k in keys:
+ yield k
class TinfoilCookerAdapter:
"""
@@ -137,12 +131,13 @@ class TinfoilCookerAdapter:
class TinfoilRecipeCacheAdapter:
""" cooker.recipecache adapter """
- def __init__(self, tinfoil):
+ def __init__(self, tinfoil, mc=''):
self.tinfoil = tinfoil
+ self.mc = mc
self._cache = {}
def get_pkg_pn_fn(self):
- pkg_pn = defaultdict(list, self.tinfoil.run_command('getRecipes') or [])
+ pkg_pn = defaultdict(list, self.tinfoil.run_command('getRecipes', self.mc) or [])
pkg_fn = {}
for pn, fnlist in pkg_pn.items():
for fn in fnlist:
@@ -161,27 +156,27 @@ class TinfoilCookerAdapter:
self.get_pkg_pn_fn()
return self._cache[name]
elif name == 'deps':
- attrvalue = defaultdict(list, self.tinfoil.run_command('getRecipeDepends') or [])
+ attrvalue = defaultdict(list, self.tinfoil.run_command('getRecipeDepends', self.mc) or [])
elif name == 'rundeps':
- attrvalue = defaultdict(lambda: defaultdict(list), self.tinfoil.run_command('getRuntimeDepends') or [])
+ attrvalue = defaultdict(lambda: defaultdict(list), self.tinfoil.run_command('getRuntimeDepends', self.mc) or [])
elif name == 'runrecs':
- attrvalue = defaultdict(lambda: defaultdict(list), self.tinfoil.run_command('getRuntimeRecommends') or [])
+ attrvalue = defaultdict(lambda: defaultdict(list), self.tinfoil.run_command('getRuntimeRecommends', self.mc) or [])
elif name == 'pkg_pepvpr':
- attrvalue = self.tinfoil.run_command('getRecipeVersions') or {}
+ attrvalue = self.tinfoil.run_command('getRecipeVersions', self.mc) or {}
elif name == 'inherits':
- attrvalue = self.tinfoil.run_command('getRecipeInherits') or {}
+ attrvalue = self.tinfoil.run_command('getRecipeInherits', self.mc) or {}
elif name == 'bbfile_priority':
- attrvalue = self.tinfoil.run_command('getBbFilePriority') or {}
+ attrvalue = self.tinfoil.run_command('getBbFilePriority', self.mc) or {}
elif name == 'pkg_dp':
- attrvalue = self.tinfoil.run_command('getDefaultPreference') or {}
+ attrvalue = self.tinfoil.run_command('getDefaultPreference', self.mc) or {}
elif name == 'fn_provides':
- attrvalue = self.tinfoil.run_command('getRecipeProvides') or {}
+ attrvalue = self.tinfoil.run_command('getRecipeProvides', self.mc) or {}
elif name == 'packages':
- attrvalue = self.tinfoil.run_command('getRecipePackages') or {}
+ attrvalue = self.tinfoil.run_command('getRecipePackages', self.mc) or {}
elif name == 'packages_dynamic':
- attrvalue = self.tinfoil.run_command('getRecipePackagesDynamic') or {}
+ attrvalue = self.tinfoil.run_command('getRecipePackagesDynamic', self.mc) or {}
elif name == 'rproviders':
- attrvalue = self.tinfoil.run_command('getRProviders') or {}
+ attrvalue = self.tinfoil.run_command('getRProviders', self.mc) or {}
else:
raise AttributeError("%s instance has no attribute '%s'" % (self.__class__.__name__, name))
@@ -192,8 +187,9 @@ class TinfoilCookerAdapter:
self.tinfoil = tinfoil
self.collection = self.TinfoilCookerCollectionAdapter(tinfoil)
self.recipecaches = {}
- # FIXME all machines
self.recipecaches[''] = self.TinfoilRecipeCacheAdapter(tinfoil)
+ for mc in (tinfoil.config_data.getVar('BBMULTICONFIG') or '').split():
+ self.recipecaches[mc] = self.TinfoilRecipeCacheAdapter(tinfoil, mc)
self._cache = {}
def __getattr__(self, name):
# Grab these only when they are requested since they aren't always used
@@ -420,9 +416,7 @@ class Tinfoil:
self.run_actions(config_params)
self.recipes_parsed = True
- self.config_data = bb.data.init()
- connector = TinfoilDataStoreConnector(self, None)
- self.config_data.setVar('_remote_data', connector)
+ self.config_data = TinfoilDataStoreConnector(self, 0)
self.cooker = TinfoilCookerAdapter(self)
self.cooker_data = self.cooker.recipecaches['']
else:
@@ -511,11 +505,11 @@ class Tinfoil:
"""
return OrderedDict(self.run_command('getSkippedRecipes'))
- def get_all_providers(self):
- return defaultdict(list, self.run_command('allProviders'))
+ def get_all_providers(self, mc=''):
+ return defaultdict(list, self.run_command('allProviders', mc))
- def find_providers(self):
- return self.run_command('findProviders')
+ def find_providers(self, mc=''):
+ return self.run_command('findProviders', mc)
def find_best_provider(self, pn):
return self.run_command('findBestProvider', pn)
@@ -634,9 +628,6 @@ class Tinfoil:
appends: True to apply bbappends, False otherwise
appendlist: optional list of bbappend files to apply, if you
want to filter them
- config_data: custom config datastore to use. NOTE: if you
- specify config_data then you cannot use a virtual
- specification for fn.
"""
if self.tracking:
# Enable history tracking just for the parse operation
@@ -645,8 +636,8 @@ class Tinfoil:
if appends and appendlist == []:
appends = False
if config_data:
- dctr = bb.remotedata.RemoteDatastores.transmit_datastore(config_data)
- dscon = self.run_command('parseRecipeFile', fn, appends, appendlist, dctr)
+ config_data = bb.data.createCopy(config_data)
+ dscon = self.run_command('parseRecipeFile', fn, appends, appendlist, config_data.dsindex)
else:
dscon = self.run_command('parseRecipeFile', fn, appends, appendlist)
if dscon:
@@ -733,21 +724,9 @@ class Tinfoil:
# Borrowed from knotty, instead somewhat hackily we use the helper
# as the object to store "shutdown" on
helper = bb.ui.uihelper.BBUIHelper()
- # We set up logging optionally in the constructor so now we need to
- # grab the handlers to pass to TerminalFilter
- console = None
- errconsole = None
- for handler in self.logger.handlers:
- if isinstance(handler, logging.StreamHandler):
- if handler.stream == sys.stdout:
- console = handler
- elif handler.stream == sys.stderr:
- errconsole = handler
- format_str = "%(levelname)s: %(message)s"
- format = bb.msg.BBLogFormatter(format_str)
helper.shutdown = 0
parseprogress = None
- termfilter = bb.ui.knotty.TerminalFilter(helper, helper, console, errconsole, format, quiet=self.quiet)
+ termfilter = bb.ui.knotty.TerminalFilter(helper, helper, self.logger.handlers, quiet=self.quiet)
try:
while True:
try:
@@ -869,9 +848,7 @@ class Tinfoil:
newobj = origtype(obj)
if isinstance(newobj, bb.command.DataStoreConnectionHandle):
- connector = TinfoilDataStoreConnector(self, newobj.dsindex)
- newobj = bb.data.init()
- newobj.setVar('_remote_data', connector)
+ newobj = TinfoilDataStoreConnector(self, newobj.dsindex)
return newobj