Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # ex:ts=4:sw=4:sts=4:et |
| 2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- |
| 3 | """ |
| 4 | BitBake 'Data' implementations |
| 5 | |
| 6 | Functions for interacting with the data structure used by the |
| 7 | BitBake build tools. |
| 8 | |
| 9 | The expandKeys and update_data are the most expensive |
| 10 | operations. At night the cookie monster came by and |
| 11 | suggested 'give me cookies on setting the variables and |
| 12 | things will work out'. Taking this suggestion into account |
| 13 | applying the skills from the not yet passed 'Entwurf und |
| 14 | Analyse von Algorithmen' lecture and the cookie |
| 15 | monster seems to be right. We will track setVar more carefully |
| 16 | to have faster update_data and expandKeys operations. |
| 17 | |
| 18 | This is a trade-off between speed and memory again but |
| 19 | the speed is more critical here. |
| 20 | """ |
| 21 | |
| 22 | # Copyright (C) 2003, 2004 Chris Larson |
| 23 | # Copyright (C) 2005 Holger Hans Peter Freyther |
| 24 | # |
| 25 | # This program is free software; you can redistribute it and/or modify |
| 26 | # it under the terms of the GNU General Public License version 2 as |
| 27 | # published by the Free Software Foundation. |
| 28 | # |
| 29 | # This program is distributed in the hope that it will be useful, |
| 30 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 31 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 32 | # GNU General Public License for more details. |
| 33 | # |
| 34 | # You should have received a copy of the GNU General Public License along |
| 35 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 36 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 37 | # |
| 38 | # Based on functions from the base bb module, Copyright 2003 Holger Schurig |
| 39 | |
| 40 | import sys, os, re |
| 41 | if sys.argv[0][-5:] == "pydoc": |
| 42 | path = os.path.dirname(os.path.dirname(sys.argv[1])) |
| 43 | else: |
| 44 | path = os.path.dirname(os.path.dirname(sys.argv[0])) |
| 45 | sys.path.insert(0, path) |
| 46 | from itertools import groupby |
| 47 | |
| 48 | from bb import data_smart |
| 49 | from bb import codeparser |
| 50 | import bb |
| 51 | |
| 52 | logger = data_smart.logger |
| 53 | _dict_type = data_smart.DataSmart |
| 54 | |
| 55 | def init(): |
| 56 | """Return a new object representing the Bitbake data""" |
| 57 | return _dict_type() |
| 58 | |
| 59 | def init_db(parent = None): |
| 60 | """Return a new object representing the Bitbake data, |
| 61 | optionally based on an existing object""" |
| 62 | if parent is not None: |
| 63 | return parent.createCopy() |
| 64 | else: |
| 65 | return _dict_type() |
| 66 | |
| 67 | def createCopy(source): |
| 68 | """Link the source set to the destination |
| 69 | If one does not find the value in the destination set, |
| 70 | search will go on to the source set to get the value. |
| 71 | Value from source are copy-on-write. i.e. any try to |
| 72 | modify one of them will end up putting the modified value |
| 73 | in the destination set. |
| 74 | """ |
| 75 | return source.createCopy() |
| 76 | |
| 77 | def initVar(var, d): |
| 78 | """Non-destructive var init for data structure""" |
| 79 | d.initVar(var) |
| 80 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | def keys(d): |
| 82 | """Return a list of keys in d""" |
| 83 | return d.keys() |
| 84 | |
| 85 | |
| 86 | __expand_var_regexp__ = re.compile(r"\${[^{}]+}") |
| 87 | __expand_python_regexp__ = re.compile(r"\${@.+?}") |
| 88 | |
| 89 | def expand(s, d, varname = None): |
| 90 | """Variable expansion using the data store""" |
| 91 | return d.expand(s, varname) |
| 92 | |
| 93 | def expandKeys(alterdata, readdata = None): |
| 94 | if readdata == None: |
| 95 | readdata = alterdata |
| 96 | |
| 97 | todolist = {} |
| 98 | for key in alterdata: |
| 99 | if not '${' in key: |
| 100 | continue |
| 101 | |
| 102 | ekey = expand(key, readdata) |
| 103 | if key == ekey: |
| 104 | continue |
| 105 | todolist[key] = ekey |
| 106 | |
| 107 | # These two for loops are split for performance to maximise the |
| 108 | # usefulness of the expand cache |
| 109 | for key in sorted(todolist): |
| 110 | ekey = todolist[key] |
| 111 | newval = alterdata.getVar(ekey, False) |
| 112 | if newval is not None: |
| 113 | val = alterdata.getVar(key, False) |
| 114 | if val is not None: |
| 115 | bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval)) |
| 116 | alterdata.renameVar(key, ekey) |
| 117 | |
| 118 | def inheritFromOS(d, savedenv, permitted): |
| 119 | """Inherit variables from the initial environment.""" |
| 120 | exportlist = bb.utils.preserved_envvars_exported() |
| 121 | for s in savedenv.keys(): |
| 122 | if s in permitted: |
| 123 | try: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 124 | d.setVar(s, savedenv.getVar(s), op = 'from env') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 125 | if s in exportlist: |
| 126 | d.setVarFlag(s, "export", True, op = 'auto env export') |
| 127 | except TypeError: |
| 128 | pass |
| 129 | |
| 130 | def emit_var(var, o=sys.__stdout__, d = init(), all=False): |
| 131 | """Emit a variable to be sourced by a shell.""" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 132 | func = d.getVarFlag(var, "func", False) |
| 133 | if d.getVarFlag(var, 'python', False) and func: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 134 | return False |
| 135 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 136 | export = d.getVarFlag(var, "export", False) |
| 137 | unexport = d.getVarFlag(var, "unexport", False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 138 | if not all and not export and not unexport and not func: |
| 139 | return False |
| 140 | |
| 141 | try: |
| 142 | if all: |
| 143 | oval = d.getVar(var, False) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 144 | val = d.getVar(var) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 145 | except (KeyboardInterrupt, bb.build.FuncFailed): |
| 146 | raise |
| 147 | except Exception as exc: |
| 148 | o.write('# expansion of %s threw %s: %s\n' % (var, exc.__class__.__name__, str(exc))) |
| 149 | return False |
| 150 | |
| 151 | if all: |
| 152 | d.varhistory.emit(var, oval, val, o, d) |
| 153 | |
| 154 | if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all: |
| 155 | return False |
| 156 | |
| 157 | varExpanded = d.expand(var) |
| 158 | |
| 159 | if unexport: |
| 160 | o.write('unset %s\n' % varExpanded) |
| 161 | return False |
| 162 | |
| 163 | if val is None: |
| 164 | return False |
| 165 | |
| 166 | val = str(val) |
| 167 | |
| 168 | if varExpanded.startswith("BASH_FUNC_"): |
| 169 | varExpanded = varExpanded[10:-2] |
| 170 | val = val[3:] # Strip off "() " |
| 171 | o.write("%s() %s\n" % (varExpanded, val)) |
| 172 | o.write("export -f %s\n" % (varExpanded)) |
| 173 | return True |
| 174 | |
| 175 | if func: |
| 176 | # NOTE: should probably check for unbalanced {} within the var |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 177 | val = val.rstrip('\n') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 178 | o.write("%s() {\n%s\n}\n" % (varExpanded, val)) |
| 179 | return 1 |
| 180 | |
| 181 | if export: |
| 182 | o.write('export ') |
| 183 | |
| 184 | # if we're going to output this within doublequotes, |
| 185 | # to a shell, we need to escape the quotes in the var |
| 186 | alter = re.sub('"', '\\"', val) |
| 187 | alter = re.sub('\n', ' \\\n', alter) |
| 188 | alter = re.sub('\\$', '\\\\$', alter) |
| 189 | o.write('%s="%s"\n' % (varExpanded, alter)) |
| 190 | return False |
| 191 | |
| 192 | def emit_env(o=sys.__stdout__, d = init(), all=False): |
| 193 | """Emits all items in the data store in a format such that it can be sourced by a shell.""" |
| 194 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 195 | isfunc = lambda key: bool(d.getVarFlag(key, "func", False)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 196 | keys = sorted((key for key in d.keys() if not key.startswith("__")), key=isfunc) |
| 197 | grouped = groupby(keys, isfunc) |
| 198 | for isfunc, keys in grouped: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 199 | for key in sorted(keys): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 200 | emit_var(key, o, d, all and not isfunc) and o.write('\n') |
| 201 | |
| 202 | def exported_keys(d): |
| 203 | return (key for key in d.keys() if not key.startswith('__') and |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 204 | d.getVarFlag(key, 'export', False) and |
| 205 | not d.getVarFlag(key, 'unexport', False)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 206 | |
| 207 | def exported_vars(d): |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 208 | k = list(exported_keys(d)) |
| 209 | for key in k: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 210 | try: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 211 | value = d.getVar(key) |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 212 | except Exception as err: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 213 | bb.warn("%s: Unable to export ${%s}: %s" % (d.getVar("FILE"), key, err)) |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 214 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 215 | |
| 216 | if value is not None: |
| 217 | yield key, str(value) |
| 218 | |
| 219 | def emit_func(func, o=sys.__stdout__, d = init()): |
| 220 | """Emits all items in the data store in a format such that it can be sourced by a shell.""" |
| 221 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 222 | keys = (key for key in d.keys() if not key.startswith("__") and not d.getVarFlag(key, "func", False)) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 223 | for key in sorted(keys): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 224 | emit_var(key, o, d, False) |
| 225 | |
| 226 | o.write('\n') |
| 227 | emit_var(func, o, d, False) and o.write('\n') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 228 | newdeps = bb.codeparser.ShellParser(func, logger).parse_shell(d.getVar(func)) |
| 229 | newdeps |= set((d.getVarFlag(func, "vardeps") or "").split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 230 | seen = set() |
| 231 | while newdeps: |
| 232 | deps = newdeps |
| 233 | seen |= deps |
| 234 | newdeps = set() |
| 235 | for dep in deps: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 236 | if d.getVarFlag(dep, "func", False) and not d.getVarFlag(dep, "python", False): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 237 | emit_var(dep, o, d, False) and o.write('\n') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 238 | newdeps |= bb.codeparser.ShellParser(dep, logger).parse_shell(d.getVar(dep)) |
| 239 | newdeps |= set((d.getVarFlag(dep, "vardeps") or "").split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 240 | newdeps -= seen |
| 241 | |
| 242 | _functionfmt = """ |
| 243 | def {function}(d): |
| 244 | {body}""" |
| 245 | |
| 246 | def emit_func_python(func, o=sys.__stdout__, d = init()): |
| 247 | """Emits all items in the data store in a format such that it can be sourced by a shell.""" |
| 248 | |
| 249 | def write_func(func, o, call = False): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 250 | body = d.getVar(func, False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 251 | if not body.startswith("def"): |
| 252 | body = _functionfmt.format(function=func, body=body) |
| 253 | |
| 254 | o.write(body.strip() + "\n\n") |
| 255 | if call: |
| 256 | o.write(func + "(d)" + "\n\n") |
| 257 | |
| 258 | write_func(func, o, True) |
| 259 | pp = bb.codeparser.PythonParser(func, logger) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 260 | pp.parse_python(d.getVar(func, False)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 261 | newdeps = pp.execs |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 262 | newdeps |= set((d.getVarFlag(func, "vardeps") or "").split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 263 | seen = set() |
| 264 | while newdeps: |
| 265 | deps = newdeps |
| 266 | seen |= deps |
| 267 | newdeps = set() |
| 268 | for dep in deps: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 269 | if d.getVarFlag(dep, "func", False) and d.getVarFlag(dep, "python", False): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 270 | write_func(dep, o) |
| 271 | pp = bb.codeparser.PythonParser(dep, logger) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 272 | pp.parse_python(d.getVar(dep, False)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 273 | newdeps |= pp.execs |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 274 | newdeps |= set((d.getVarFlag(dep, "vardeps") or "").split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 275 | newdeps -= seen |
| 276 | |
| 277 | def update_data(d): |
| 278 | """Performs final steps upon the datastore, including application of overrides""" |
| 279 | d.finalize(parent = True) |
| 280 | |
| 281 | def build_dependencies(key, keys, shelldeps, varflagsexcl, d): |
| 282 | deps = set() |
| 283 | try: |
| 284 | if key[-1] == ']': |
| 285 | vf = key[:-1].split('[') |
| 286 | value = d.getVarFlag(vf[0], vf[1], False) |
| 287 | parser = d.expandWithRefs(value, key) |
| 288 | deps |= parser.references |
| 289 | deps = deps | (keys & parser.execs) |
| 290 | return deps, value |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 291 | varflags = d.getVarFlags(key, ["vardeps", "vardepvalue", "vardepsexclude", "exports", "postfuncs", "prefuncs", "lineno", "filename"]) or {} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 292 | vardeps = varflags.get("vardeps") |
| 293 | value = d.getVar(key, False) |
| 294 | |
| 295 | def handle_contains(value, contains, d): |
| 296 | newvalue = "" |
| 297 | for k in sorted(contains): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 298 | l = (d.getVar(k) or "").split() |
| 299 | for item in sorted(contains[k]): |
| 300 | for word in item.split(): |
| 301 | if not word in l: |
| 302 | newvalue += "\n%s{%s} = Unset" % (k, item) |
| 303 | break |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 304 | else: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 305 | newvalue += "\n%s{%s} = Set" % (k, item) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 306 | if not newvalue: |
| 307 | return value |
| 308 | if not value: |
| 309 | return newvalue |
| 310 | return value + newvalue |
| 311 | |
| 312 | if "vardepvalue" in varflags: |
| 313 | value = varflags.get("vardepvalue") |
| 314 | elif varflags.get("func"): |
| 315 | if varflags.get("python"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 316 | parser = bb.codeparser.PythonParser(key, logger) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 317 | if value and "\t" in value: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 318 | logger.warning("Variable %s contains tabs, please remove these (%s)" % (key, d.getVar("FILE"))) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 319 | parser.parse_python(value, filename=varflags.get("filename"), lineno=varflags.get("lineno")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 320 | deps = deps | parser.references |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 321 | deps = deps | (keys & parser.execs) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 322 | value = handle_contains(value, parser.contains, d) |
| 323 | else: |
| 324 | parsedvar = d.expandWithRefs(value, key) |
| 325 | parser = bb.codeparser.ShellParser(key, logger) |
| 326 | parser.parse_shell(parsedvar.value) |
| 327 | deps = deps | shelldeps |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 328 | deps = deps | parsedvar.references |
| 329 | deps = deps | (keys & parser.execs) | (keys & parsedvar.execs) |
| 330 | value = handle_contains(value, parsedvar.contains, d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 331 | if vardeps is None: |
| 332 | parser.log.flush() |
| 333 | if "prefuncs" in varflags: |
| 334 | deps = deps | set(varflags["prefuncs"].split()) |
| 335 | if "postfuncs" in varflags: |
| 336 | deps = deps | set(varflags["postfuncs"].split()) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 337 | if "exports" in varflags: |
| 338 | deps = deps | set(varflags["exports"].split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 339 | else: |
| 340 | parser = d.expandWithRefs(value, key) |
| 341 | deps |= parser.references |
| 342 | deps = deps | (keys & parser.execs) |
| 343 | value = handle_contains(value, parser.contains, d) |
| 344 | |
| 345 | if "vardepvalueexclude" in varflags: |
| 346 | exclude = varflags.get("vardepvalueexclude") |
| 347 | for excl in exclude.split('|'): |
| 348 | if excl: |
| 349 | value = value.replace(excl, '') |
| 350 | |
| 351 | # Add varflags, assuming an exclusion list is set |
| 352 | if varflagsexcl: |
| 353 | varfdeps = [] |
| 354 | for f in varflags: |
| 355 | if f not in varflagsexcl: |
| 356 | varfdeps.append('%s[%s]' % (key, f)) |
| 357 | if varfdeps: |
| 358 | deps |= set(varfdeps) |
| 359 | |
| 360 | deps |= set((vardeps or "").split()) |
| 361 | deps -= set(varflags.get("vardepsexclude", "").split()) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 362 | except bb.parse.SkipRecipe: |
| 363 | raise |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 364 | except Exception as e: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 365 | bb.warn("Exception during build_dependencies for %s" % key) |
| 366 | raise |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 367 | return deps, value |
| 368 | #bb.note("Variable %s references %s and calls %s" % (key, str(deps), str(execs))) |
| 369 | #d.setVarFlag(key, "vardeps", deps) |
| 370 | |
| 371 | def generate_dependencies(d): |
| 372 | |
| 373 | keys = set(key for key in d if not key.startswith("__")) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 374 | shelldeps = set(key for key in d.getVar("__exportlist", False) if d.getVarFlag(key, "export", False) and not d.getVarFlag(key, "unexport", False)) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 375 | varflagsexcl = d.getVar('BB_SIGNATURE_EXCLUDE_FLAGS') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 376 | |
| 377 | deps = {} |
| 378 | values = {} |
| 379 | |
| 380 | tasklist = d.getVar('__BBTASKS', False) or [] |
| 381 | for task in tasklist: |
| 382 | deps[task], values[task] = build_dependencies(task, keys, shelldeps, varflagsexcl, d) |
| 383 | newdeps = deps[task] |
| 384 | seen = set() |
| 385 | while newdeps: |
| 386 | nextdeps = newdeps |
| 387 | seen |= nextdeps |
| 388 | newdeps = set() |
| 389 | for dep in nextdeps: |
| 390 | if dep not in deps: |
| 391 | deps[dep], values[dep] = build_dependencies(dep, keys, shelldeps, varflagsexcl, d) |
| 392 | newdeps |= deps[dep] |
| 393 | newdeps -= seen |
| 394 | #print "For %s: %s" % (task, str(deps[task])) |
| 395 | return tasklist, deps, values |
| 396 | |
| 397 | def inherits_class(klass, d): |
| 398 | val = d.getVar('__inherit_cache', False) or [] |
| 399 | needle = os.path.join('classes', '%s.bbclass' % klass) |
| 400 | for v in val: |
| 401 | if v.endswith(needle): |
| 402 | return True |
| 403 | return False |