summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-04-08 15:43:47 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-07-02 15:41:31 +0100
commitc9c230b14a8202c31648c044e75e47022004014f (patch)
tree200d1ecf81848c41ff944f8fdba68a884fb3f48f /bitbake/lib
parent00e3915ca6b479f78177e16e27ff9ad8a7fbff02 (diff)
downloadpoky-c9c230b14a8202c31648c044e75e47022004014f.tar.gz
Move update_data into the DataSmart class as a finalize() method
(Bitbake rev: ff801397785567cb84b3615de86bff764d65decf) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/data.py138
-rw-r--r--bitbake/lib/bb/data_smart.py65
2 files changed, 67 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
412def update_data(d): 412def 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
550def inherits_class(klass, d): 416def inherits_class(klass, d):
551 val = getVar('__inherit_cache', d) or [] 417 val = getVar('__inherit_cache', d) or []
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index 77f1861381..6ea0182852 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -95,6 +95,71 @@ class DataSmart:
95 95
96 return s 96 return s
97 97
98 def finalize(self):
99 """Performs final steps upon the datastore, including application of overrides"""
100 overrides = (self.getVar("OVERRIDES", True) or "").split(":")
101
102 #
103 # Well let us see what breaks here. We used to iterate
104 # over each variable and apply the override and then
105 # do the line expanding.
106 # If we have bad luck - which we will have - the keys
107 # where in some order that is so important for this
108 # method which we don't have anymore.
109 # Anyway we will fix that and write test cases this
110 # time.
111
112 #
113 # First we apply all overrides
114 # Then we will handle _append and _prepend
115 #
116
117 for o in overrides:
118 # calculate '_'+override
119 l = len(o)+1
120
121 # see if one should even try
122 if not self._seen_overrides.has_key(o):
123 continue
124
125 vars = self._seen_overrides[o]
126 for var in vars:
127 name = var[:-l]
128 try:
129 self.renameVar(var, name)
130 except:
131 bb.msg.note(1, bb.msg.domain.Data, "Untracked delVar")
132
133 # now on to the appends and prepends
134 if self._special_values.has_key("_append"):
135 appends = self._special_values['_append'] or []
136 for append in appends:
137 for (a, o) in self.getVarFlag(append, '_append') or []:
138 # maybe the OVERRIDE was not yet added so keep the append
139 if (o and o in overrides) or not o:
140 self.delVarFlag(append, '_append')
141 if o and not o in overrides:
142 continue
143
144 sval = self.getVar(append, False) or ""
145 sval += a
146 self.setVar(append, sval)
147
148
149 if self._special_values.has_key("_prepend"):
150 prepends = self._special_values['_prepend'] or []
151
152 for prepend in prepends:
153 for (a, o) in self.getVarFlag(prepend, '_prepend') or []:
154 # maybe the OVERRIDE was not yet added so keep the prepend
155 if (o and o in overrides) or not o:
156 self.delVarFlag(prepend, '_prepend')
157 if o and not o in overrides:
158 continue
159
160 sval = a + (self.getVar(prepend, False) or "")
161 self.setVar(prepend, sval)
162
98 def initVar(self, var): 163 def initVar(self, var):
99 self.expand_cache = {} 164 self.expand_cache = {}
100 if not var in self.dict: 165 if not var in self.dict: