summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-07-16 15:10:22 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2010-07-16 15:10:40 +0100
commit63e6ba85677b8aa9f4cf9942a1fccbb8a8c72660 (patch)
tree56be00c10b229ddc5e63bf1f02d7ac5c23ba8381 /bitbake/lib
parentc4fde248b14d4be9cab6d0eff85f9d7f852a4b65 (diff)
downloadpoky-63e6ba85677b8aa9f4cf9942a1fccbb8a8c72660.tar.gz
bitbake: Add support for .bbappend files (see mailing lists for detais)
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/cache.py12
-rw-r--r--bitbake/lib/bb/cooker.py63
-rw-r--r--bitbake/lib/bb/parse/ast.py6
-rw-r--r--bitbake/lib/bb/runqueue.py2
4 files changed, 55 insertions, 28 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index da4546640a..b5c7043c64 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -165,7 +165,7 @@ class Cache:
165 #bb.msg.debug(2, bb.msg.domain.Cache, "realfn2virtual %s and %s to %s" % (realfn, cls, "virtual:" + cls + ":" + realfn)) 165 #bb.msg.debug(2, bb.msg.domain.Cache, "realfn2virtual %s and %s to %s" % (realfn, cls, "virtual:" + cls + ":" + realfn))
166 return "virtual:" + cls + ":" + realfn 166 return "virtual:" + cls + ":" + realfn
167 167
168 def loadDataFull(self, virtualfn, cfgData): 168 def loadDataFull(self, virtualfn, appends, cfgData):
169 """ 169 """
170 Return a complete set of data for fn. 170 Return a complete set of data for fn.
171 To do this, we need to parse the file. 171 To do this, we need to parse the file.
@@ -175,10 +175,10 @@ class Cache:
175 175
176 bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s (full)" % fn) 176 bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s (full)" % fn)
177 177
178 bb_data = self.load_bbfile(fn, cfgData) 178 bb_data = self.load_bbfile(fn, appends, cfgData)
179 return bb_data[cls] 179 return bb_data[cls]
180 180
181 def loadData(self, fn, cfgData, cacheData): 181 def loadData(self, fn, appends, cfgData, cacheData):
182 """ 182 """
183 Load a subset of data for fn. 183 Load a subset of data for fn.
184 If the cached data is valid we do nothing, 184 If the cached data is valid we do nothing,
@@ -206,7 +206,7 @@ class Cache:
206 206
207 bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s" % fn) 207 bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s" % fn)
208 208
209 bb_data = self.load_bbfile(fn, cfgData) 209 bb_data = self.load_bbfile(fn, appends, cfgData)
210 210
211 for data in bb_data: 211 for data in bb_data:
212 virtualfn = self.realfn2virtual(fn, data) 212 virtualfn = self.realfn2virtual(fn, data)
@@ -439,7 +439,7 @@ class Cache:
439 self.getVar('__BB_DONT_CACHE', file_name, True) 439 self.getVar('__BB_DONT_CACHE', file_name, True)
440 self.getVar('__VARIANTS', file_name, True) 440 self.getVar('__VARIANTS', file_name, True)
441 441
442 def load_bbfile( self, bbfile, config): 442 def load_bbfile(self, bbfile, appends, config):
443 """ 443 """
444 Load and parse one .bb build file 444 Load and parse one .bb build file
445 Return the data and whether parsing resulted in the file being skipped 445 Return the data and whether parsing resulted in the file being skipped
@@ -463,6 +463,8 @@ class Cache:
463 chdir_back = True 463 chdir_back = True
464 data.setVar('TOPDIR', bbfile_loc, bb_data) 464 data.setVar('TOPDIR', bbfile_loc, bb_data)
465 try: 465 try:
466 if appends:
467 data.setVar('__BBAPPEND', " ".join(appends), bb_data)
466 bb_data = parse.handle(bbfile, bb_data) # read .bb data 468 bb_data = parse.handle(bbfile, bb_data) # read .bb data
467 if chdir_back: os.chdir(oldpath) 469 if chdir_back: os.chdir(oldpath)
468 return bb_data 470 return bb_data
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 52a402cd91..0992ec4c2e 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -226,7 +226,7 @@ class BBCooker:
226 226
227 if fn: 227 if fn:
228 try: 228 try:
229 envdata = self.bb_cache.loadDataFull(fn, self.configuration.data) 229 envdata = self.bb_cache.loadDataFull(fn, self.get_file_appends(fn), self.configuration.data)
230 except IOError as e: 230 except IOError as e:
231 bb.msg.error(bb.msg.domain.Parsing, "Unable to read %s: %s" % (fn, e)) 231 bb.msg.error(bb.msg.domain.Parsing, "Unable to read %s: %s" % (fn, e))
232 raise 232 raise
@@ -637,7 +637,7 @@ class BBCooker:
637 self.buildSetVars() 637 self.buildSetVars()
638 638
639 # Load data into the cache for fn and parse the loaded cache data 639 # Load data into the cache for fn and parse the loaded cache data
640 the_data = self.bb_cache.loadDataFull(fn, self.configuration.data) 640 the_data = self.bb_cache.loadDataFull(fn, self.get_file_appends(fn), self.configuration.data)
641 self.bb_cache.setData(fn, buildfile, the_data) 641 self.bb_cache.setData(fn, buildfile, the_data)
642 self.bb_cache.handle_data(fn, self.status) 642 self.bb_cache.handle_data(fn, self.status)
643 643
@@ -778,7 +778,6 @@ class BBCooker:
778 778
779 self.handleCollections( bb.data.getVar("BBFILE_COLLECTIONS", self.configuration.data, 1) ) 779 self.handleCollections( bb.data.getVar("BBFILE_COLLECTIONS", self.configuration.data, 1) )
780 780
781 bb.msg.debug(1, bb.msg.domain.Collection, "collecting .bb files")
782 (filelist, masked) = self.collect_bbfiles() 781 (filelist, masked) = self.collect_bbfiles()
783 bb.data.renameVar("__depends", "__base_depends", self.configuration.data) 782 bb.data.renameVar("__depends", "__base_depends", self.configuration.data)
784 783
@@ -817,7 +816,7 @@ class BBCooker:
817 return bbfiles 816 return bbfiles
818 817
819 def find_bbfiles( self, path ): 818 def find_bbfiles( self, path ):
820 """Find all the .bb files in a directory""" 819 """Find all the .bb and .bbappend files in a directory"""
821 from os.path import join 820 from os.path import join
822 821
823 found = [] 822 found = []
@@ -825,7 +824,7 @@ class BBCooker:
825 for ignored in ('SCCS', 'CVS', '.svn'): 824 for ignored in ('SCCS', 'CVS', '.svn'):
826 if ignored in dirs: 825 if ignored in dirs:
827 dirs.remove(ignored) 826 dirs.remove(ignored)
828 found += [join(dir, f) for f in files if f.endswith('.bb')] 827 found += [join(dir, f) for f in files if (f.endswith('.bb') or f.endswith('.bbappend'))]
829 828
830 return found 829 return found
831 830
@@ -834,6 +833,8 @@ class BBCooker:
834 parsed, cached, skipped, masked = 0, 0, 0, 0 833 parsed, cached, skipped, masked = 0, 0, 0, 0
835 self.bb_cache = bb.cache.init(self) 834 self.bb_cache = bb.cache.init(self)
836 835
836 bb.msg.debug(1, bb.msg.domain.Collection, "collecting .bb files")
837
837 files = (data.getVar( "BBFILES", self.configuration.data, 1 ) or "").split() 838 files = (data.getVar( "BBFILES", self.configuration.data, 1 ) or "").split()
838 data.setVar("BBFILES", " ".join(files), self.configuration.data) 839 data.setVar("BBFILES", " ".join(files), self.configuration.data)
839 840
@@ -848,9 +849,7 @@ class BBCooker:
848 for f in files: 849 for f in files:
849 if os.path.isdir(f): 850 if os.path.isdir(f):
850 dirfiles = self.find_bbfiles(f) 851 dirfiles = self.find_bbfiles(f)
851 if dirfiles: 852 newfiles.update(dirfiles)
852 newfiles.update(dirfiles)
853 continue
854 else: 853 else:
855 globbed = glob.glob(f) 854 globbed = glob.glob(f)
856 if not globbed and os.path.exists(f): 855 if not globbed and os.path.exists(f):
@@ -859,23 +858,45 @@ class BBCooker:
859 858
860 bbmask = bb.data.getVar('BBMASK', self.configuration.data, 1) 859 bbmask = bb.data.getVar('BBMASK', self.configuration.data, 1)
861 860
862 if not bbmask: 861 if bbmask:
863 return (list(newfiles), 0) 862 try:
864 863 bbmask_compiled = re.compile(bbmask)
865 try: 864 except sre_constants.error:
866 bbmask_compiled = re.compile(bbmask) 865 bb.msg.fatal(bb.msg.domain.Collection, "BBMASK is not a valid regular expression.")
867 except sre_constants.error:
868 bb.msg.fatal(bb.msg.domain.Collection, "BBMASK is not a valid regular expression.")
869 866
870 finalfiles = [] 867 bbfiles = []
868 bbappend = []
871 for f in newfiles: 869 for f in newfiles:
872 if bbmask_compiled.search(f): 870 if bbmask and bbmask_compiled.search(f):
873 bb.msg.debug(1, bb.msg.domain.Collection, "skipping masked file %s" % f) 871 bb.msg.debug(1, bb.msg.domain.Collection, "skipping masked file %s" % f)
874 masked += 1 872 masked += 1
875 continue 873 continue
876 finalfiles.append(f) 874 if f.endswith('.bb'):
877 875 bbfiles.append(f)
878 return (finalfiles, masked) 876 elif f.endswith('.bbappend'):
877 bbappend.append(f)
878 else:
879 bb.msg.note(1, bb.msg.domain.Collection, "File %s of unknown filetype in BBFILES? Ignorning..." % f)
880
881 # Build a list of .bbappend files for each .bb file
882 self.appendlist = {}
883 for f in bbappend:
884 base = os.path.basename(f).replace('.bbappend', '.bb')
885 if not base in self.appendlist:
886 self.appendlist[base] = []
887 self.appendlist[base].append(f)
888
889 return (bbfiles, masked)
890
891 def get_file_appends(self, fn):
892 """
893 Returns a list of .bbappend files to apply to fn
894 NB: collect_files() must have been called prior to this
895 """
896 f = os.path.basename(fn)
897 if f in self.appendlist:
898 return self.appendlist[f]
899 return []
879 900
880 def serve(self): 901 def serve(self):
881 902
@@ -945,7 +966,7 @@ class CookerParser:
945 f = self.filelist[self.pointer] 966 f = self.filelist[self.pointer]
946 967
947 try: 968 try:
948 fromCache, skipped, virtuals = cooker.bb_cache.loadData(f, cooker.configuration.data, cooker.status) 969 fromCache, skipped, virtuals = cooker.bb_cache.loadData(f, cooker.get_file_appends(f), cooker.configuration.data, cooker.status)
949 if fromCache: 970 if fromCache:
950 self.cached += 1 971 self.cached += 1
951 else: 972 else:
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py
index dae2e11154..eb24e0ddd4 100644
--- a/bitbake/lib/bb/parse/ast.py
+++ b/bitbake/lib/bb/parse/ast.py
@@ -357,8 +357,12 @@ def _expand_versions(versions):
357 versions = itertools.chain(newversions, versions) 357 versions = itertools.chain(newversions, versions)
358 358
359def multi_finalize(fn, d): 359def multi_finalize(fn, d):
360 safe_d = d 360 appends = (d.getVar("__BBAPPEND", True) or "").split()
361 for append in appends:
362 bb.msg.debug(2, bb.msg.domain.Parsing, "Appending .bbappend file " + append + " to " + fn)
363 bb.parse.BBHandler.handle(append, d, True)
361 364
365 safe_d = d
362 d = bb.data.createCopy(safe_d) 366 d = bb.data.createCopy(safe_d)
363 try: 367 try:
364 finalize(fn, d) 368 finalize(fn, d)
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index f9acd9ca2d..2830bc4ad9 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -1067,7 +1067,7 @@ class RunQueue:
1067 bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY", self, self.cooker.configuration.data) 1067 bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY", self, self.cooker.configuration.data)
1068 bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY2", fn, self.cooker.configuration.data) 1068 bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY2", fn, self.cooker.configuration.data)
1069 try: 1069 try:
1070 the_data = self.cooker.bb_cache.loadDataFull(fn, self.cooker.configuration.data) 1070 the_data = self.cooker.bb_cache.loadDataFull(fn, self.cooker.get_file_appends(fn), self.cooker.configuration.data)
1071 1071
1072 if not self.cooker.configuration.dry_run: 1072 if not self.cooker.configuration.dry_run:
1073 bb.build.exec_task(taskname, the_data) 1073 bb.build.exec_task(taskname, the_data)