diff options
Diffstat (limited to 'bitbake/lib/bb/data.py')
| -rw-r--r-- | bitbake/lib/bb/data.py | 138 |
1 files changed, 2 insertions, 136 deletions
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py index c3bb1a1f43..5938277273 100644 --- a/bitbake/lib/bb/data.py +++ b/bitbake/lib/bb/data.py | |||
| @@ -410,142 +410,8 @@ def emit_env(o=sys.__stdout__, d = init(), all=False): | |||
| 410 | emit_var(e, o, d) and o.write('\n') | 410 | emit_var(e, o, d) and o.write('\n') |
| 411 | 411 | ||
| 412 | def update_data(d): | 412 | def update_data(d): |
| 413 | """Modifies the environment vars according to local overrides and commands. | 413 | """Performs final steps upon the datastore, including application of overrides""" |
| 414 | Examples: | 414 | d.finalize() |
| 415 | Appending to a variable: | ||
| 416 | >>> d = init() | ||
| 417 | >>> setVar('TEST', 'this is a', d) | ||
| 418 | >>> setVar('TEST_append', ' test', d) | ||
| 419 | >>> setVar('TEST_append', ' of the emergency broadcast system.', d) | ||
| 420 | >>> update_data(d) | ||
| 421 | >>> print getVar('TEST', d) | ||
| 422 | this is a test of the emergency broadcast system. | ||
| 423 | |||
| 424 | Prepending to a variable: | ||
| 425 | >>> setVar('TEST', 'virtual/libc', d) | ||
| 426 | >>> setVar('TEST_prepend', 'virtual/tmake ', d) | ||
| 427 | >>> setVar('TEST_prepend', 'virtual/patcher ', d) | ||
| 428 | >>> update_data(d) | ||
| 429 | >>> print getVar('TEST', d) | ||
| 430 | virtual/patcher virtual/tmake virtual/libc | ||
| 431 | |||
| 432 | Overrides: | ||
| 433 | >>> setVar('TEST_arm', 'target', d) | ||
| 434 | >>> setVar('TEST_ramses', 'machine', d) | ||
| 435 | >>> setVar('TEST_local', 'local', d) | ||
| 436 | >>> setVar('OVERRIDES', 'arm', d) | ||
| 437 | |||
| 438 | >>> setVar('TEST', 'original', d) | ||
| 439 | >>> update_data(d) | ||
| 440 | >>> print getVar('TEST', d) | ||
| 441 | target | ||
| 442 | |||
| 443 | >>> setVar('OVERRIDES', 'arm:ramses:local', d) | ||
| 444 | >>> setVar('TEST', 'original', d) | ||
| 445 | >>> update_data(d) | ||
| 446 | >>> print getVar('TEST', d) | ||
| 447 | local | ||
| 448 | |||
| 449 | CopyMonster: | ||
| 450 | >>> e = d.createCopy() | ||
| 451 | >>> setVar('TEST_foo', 'foo', e) | ||
| 452 | >>> update_data(e) | ||
| 453 | >>> print getVar('TEST', e) | ||
| 454 | local | ||
| 455 | |||
| 456 | >>> setVar('OVERRIDES', 'arm:ramses:local:foo', e) | ||
| 457 | >>> update_data(e) | ||
| 458 | >>> print getVar('TEST', e) | ||
| 459 | foo | ||
| 460 | |||
| 461 | >>> f = d.createCopy() | ||
| 462 | >>> setVar('TEST_moo', 'something', f) | ||
| 463 | >>> setVar('OVERRIDES', 'moo:arm:ramses:local:foo', e) | ||
| 464 | >>> update_data(e) | ||
| 465 | >>> print getVar('TEST', e) | ||
| 466 | foo | ||
| 467 | |||
| 468 | |||
| 469 | >>> h = init() | ||
| 470 | >>> setVar('SRC_URI', 'file://append.foo;patch=1 ', h) | ||
| 471 | >>> g = h.createCopy() | ||
| 472 | >>> setVar('SRC_URI_append_arm', 'file://other.foo;patch=1', g) | ||
| 473 | >>> setVar('OVERRIDES', 'arm:moo', g) | ||
| 474 | >>> update_data(g) | ||
| 475 | >>> print getVar('SRC_URI', g) | ||
| 476 | file://append.foo;patch=1 file://other.foo;patch=1 | ||
| 477 | |||
| 478 | """ | ||
| 479 | bb.msg.debug(2, bb.msg.domain.Data, "update_data()") | ||
| 480 | |||
| 481 | # now ask the cookie monster for help | ||
| 482 | #print "Cookie Monster" | ||
| 483 | #print "Append/Prepend %s" % d._special_values | ||
| 484 | #print "Overrides %s" % d._seen_overrides | ||
| 485 | |||
| 486 | overrides = (getVar('OVERRIDES', d, 1) or "").split(':') or [] | ||
| 487 | |||
| 488 | # | ||
| 489 | # Well let us see what breaks here. We used to iterate | ||
| 490 | # over each variable and apply the override and then | ||
| 491 | # do the line expanding. | ||
| 492 | # If we have bad luck - which we will have - the keys | ||
| 493 | # where in some order that is so important for this | ||
| 494 | # method which we don't have anymore. | ||
| 495 | # Anyway we will fix that and write test cases this | ||
| 496 | # time. | ||
| 497 | |||
| 498 | # | ||
| 499 | # First we apply all overrides | ||
| 500 | # Then we will handle _append and _prepend | ||
| 501 | # | ||
| 502 | |||
| 503 | for o in overrides: | ||
| 504 | # calculate '_'+override | ||
| 505 | l = len(o)+1 | ||
| 506 | |||
| 507 | # see if one should even try | ||
| 508 | if not d._seen_overrides.has_key(o): | ||
| 509 | continue | ||
| 510 | |||
| 511 | vars = d._seen_overrides[o] | ||
| 512 | for var in vars: | ||
| 513 | name = var[:-l] | ||
| 514 | try: | ||
| 515 | d[name] = d[var] | ||
| 516 | except: | ||
| 517 | bb.msg.note(1, bb.msg.domain.Data, "Untracked delVar") | ||
| 518 | |||
| 519 | # now on to the appends and prepends | ||
| 520 | if d._special_values.has_key('_append'): | ||
| 521 | appends = d._special_values['_append'] or [] | ||
| 522 | for append in appends: | ||
| 523 | for (a, o) in getVarFlag(append, '_append', d) or []: | ||
| 524 | # maybe the OVERRIDE was not yet added so keep the append | ||
| 525 | if (o and o in overrides) or not o: | ||
| 526 | delVarFlag(append, '_append', d) | ||
| 527 | if o and not o in overrides: | ||
| 528 | continue | ||
| 529 | |||
| 530 | sval = getVar(append,d) or "" | ||
| 531 | sval+=a | ||
| 532 | setVar(append, sval, d) | ||
| 533 | |||
| 534 | |||
| 535 | if d._special_values.has_key('_prepend'): | ||
| 536 | prepends = d._special_values['_prepend'] or [] | ||
| 537 | |||
| 538 | for prepend in prepends: | ||
| 539 | for (a, o) in getVarFlag(prepend, '_prepend', d) or []: | ||
| 540 | # maybe the OVERRIDE was not yet added so keep the prepend | ||
| 541 | if (o and o in overrides) or not o: | ||
| 542 | delVarFlag(prepend, '_prepend', d) | ||
| 543 | if o and not o in overrides: | ||
| 544 | continue | ||
| 545 | |||
| 546 | sval = a + (getVar(prepend,d) or "") | ||
| 547 | setVar(prepend, sval, d) | ||
| 548 | |||
| 549 | 415 | ||
| 550 | def inherits_class(klass, d): | 416 | def inherits_class(klass, d): |
| 551 | val = getVar('__inherit_cache', d) or [] | 417 | val = getVar('__inherit_cache', d) or [] |
