diff options
Diffstat (limited to 'bitbake/lib')
46 files changed, 0 insertions, 15609 deletions
diff --git a/bitbake/lib/bb/COW.py b/bitbake/lib/bb/COW.py deleted file mode 100644 index e5063d60a8..0000000000 --- a/bitbake/lib/bb/COW.py +++ /dev/null @@ -1,320 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -# -# This is a copy on write dictionary and set which abuses classes to try and be nice and fast. -# -# Copyright (C) 2006 Tim Amsell -# -# 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. -# -# 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. -# -#Please Note: -# Be careful when using mutable types (ie Dict and Lists) - operations involving these are SLOW. -# Assign a file to __warn__ to get warnings about slow operations. -# - -from inspect import getmro - -import copy -import types, sets -types.ImmutableTypes = tuple([ \ - types.BooleanType, \ - types.ComplexType, \ - types.FloatType, \ - types.IntType, \ - types.LongType, \ - types.NoneType, \ - types.TupleType, \ - sets.ImmutableSet] + \ - list(types.StringTypes)) - -MUTABLE = "__mutable__" - -class COWMeta(type): - pass - -class COWDictMeta(COWMeta): - __warn__ = False - __hasmutable__ = False - __marker__ = tuple() - - def __str__(cls): - # FIXME: I have magic numbers! - return "<COWDict Level: %i Current Keys: %i>" % (cls.__count__, len(cls.__dict__) - 3) - __repr__ = __str__ - - def cow(cls): - class C(cls): - __count__ = cls.__count__ + 1 - return C - copy = cow - __call__ = cow - - def __setitem__(cls, key, value): - if not isinstance(value, types.ImmutableTypes): - if not isinstance(value, COWMeta): - cls.__hasmutable__ = True - key += MUTABLE - setattr(cls, key, value) - - def __getmutable__(cls, key, readonly=False): - nkey = key + MUTABLE - try: - return cls.__dict__[nkey] - except KeyError: - pass - - value = getattr(cls, nkey) - if readonly: - return value - - if not cls.__warn__ is False and not isinstance(value, COWMeta): - print >> cls.__warn__, "Warning: Doing a copy because %s is a mutable type." % key - try: - value = value.copy() - except AttributeError, e: - value = copy.copy(value) - setattr(cls, nkey, value) - return value - - __getmarker__ = [] - def __getreadonly__(cls, key, default=__getmarker__): - """\ - Get a value (even if mutable) which you promise not to change. - """ - return cls.__getitem__(key, default, True) - - def __getitem__(cls, key, default=__getmarker__, readonly=False): - try: - try: - value = getattr(cls, key) - except AttributeError: - value = cls.__getmutable__(key, readonly) - - # This is for values which have been deleted - if value is cls.__marker__: - raise AttributeError("key %s does not exist." % key) - - return value - except AttributeError, e: - if not default is cls.__getmarker__: - return default - - raise KeyError(str(e)) - - def __delitem__(cls, key): - cls.__setitem__(key, cls.__marker__) - - def __revertitem__(cls, key): - if not cls.__dict__.has_key(key): - key += MUTABLE - delattr(cls, key) - - def has_key(cls, key): - value = cls.__getreadonly__(key, cls.__marker__) - if value is cls.__marker__: - return False - return True - - def iter(cls, type, readonly=False): - for key in dir(cls): - if key.startswith("__"): - continue - - if key.endswith(MUTABLE): - key = key[:-len(MUTABLE)] - - if type == "keys": - yield key - - try: - if readonly: - value = cls.__getreadonly__(key) - else: - value = cls[key] - except KeyError: - continue - - if type == "values": - yield value - if type == "items": - yield (key, value) - raise StopIteration() - - def iterkeys(cls): - return cls.iter("keys") - def itervalues(cls, readonly=False): - if not cls.__warn__ is False and cls.__hasmutable__ and readonly is False: - print >> cls.__warn__, "Warning: If you arn't going to change any of the values call with True." - return cls.iter("values", readonly) - def iteritems(cls, readonly=False): - if not cls.__warn__ is False and cls.__hasmutable__ and readonly is False: - print >> cls.__warn__, "Warning: If you arn't going to change any of the values call with True." - return cls.iter("items", readonly) - -class COWSetMeta(COWDictMeta): - def __str__(cls): - # FIXME: I have magic numbers! - return "<COWSet Level: %i Current Keys: %i>" % (cls.__count__, len(cls.__dict__) -3) - __repr__ = __str__ - - def cow(cls): - class C(cls): - __count__ = cls.__count__ + 1 - return C - - def add(cls, value): - COWDictMeta.__setitem__(cls, repr(hash(value)), value) - - def remove(cls, value): - COWDictMeta.__delitem__(cls, repr(hash(value))) - - def __in__(cls, value): - return COWDictMeta.has_key(repr(hash(value))) - - def iterkeys(cls): - raise TypeError("sets don't have keys") - - def iteritems(cls): - raise TypeError("sets don't have 'items'") - -# These are the actual classes you use! -class COWDictBase(object): - __metaclass__ = COWDictMeta - __count__ = 0 - -class COWSetBase(object): - __metaclass__ = COWSetMeta - __count__ = 0 - -if __name__ == "__main__": - import sys - COWDictBase.__warn__ = sys.stderr - a = COWDictBase() - print "a", a - - a['a'] = 'a' - a['b'] = 'b' - a['dict'] = {} - - b = a.copy() - print "b", b - b['c'] = 'b' - - print - - print "a", a - for x in a.iteritems(): - print x - print "--" - print "b", b - for x in b.iteritems(): - print x - print - - b['dict']['a'] = 'b' - b['a'] = 'c' - - print "a", a - for x in a.iteritems(): - print x - print "--" - print "b", b - for x in b.iteritems(): - print x - print - - try: - b['dict2'] - except KeyError, e: - print "Okay!" - - a['set'] = COWSetBase() - a['set'].add("o1") - a['set'].add("o1") - a['set'].add("o2") - - print "a", a - for x in a['set'].itervalues(): - print x - print "--" - print "b", b - for x in b['set'].itervalues(): - print x - print - - b['set'].add('o3') - - print "a", a - for x in a['set'].itervalues(): - print x - print "--" - print "b", b - for x in b['set'].itervalues(): - print x - print - - a['set2'] = set() - a['set2'].add("o1") - a['set2'].add("o1") - a['set2'].add("o2") - - print "a", a - for x in a.iteritems(): - print x - print "--" - print "b", b - for x in b.iteritems(readonly=True): - print x - print - - del b['b'] - try: - print b['b'] - except KeyError: - print "Yay! deleted key raises error" - - if b.has_key('b'): - print "Boo!" - else: - print "Yay - has_key with delete works!" - - print "a", a - for x in a.iteritems(): - print x - print "--" - print "b", b - for x in b.iteritems(readonly=True): - print x - print - - b.__revertitem__('b') - - print "a", a - for x in a.iteritems(): - print x - print "--" - print "b", b - for x in b.iteritems(readonly=True): - print x - print - - b.__revertitem__('dict') - print "a", a - for x in a.iteritems(): - print x - print "--" - print "b", b - for x in b.iteritems(readonly=True): - print x - print diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py deleted file mode 100644 index 0460c96ff4..0000000000 --- a/bitbake/lib/bb/__init__.py +++ /dev/null @@ -1,1252 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -# -# BitBake Build System Python Library -# -# Copyright (C) 2003 Holger Schurig -# Copyright (C) 2003, 2004 Chris Larson -# -# Based on Gentoo's portage.py. -# -# 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. -# -# 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. - -__version__ = "1.8.9" - -__all__ = [ - - "debug", - "note", - "error", - "fatal", - - "mkdirhier", - "movefile", - - "tokenize", - "evaluate", - "flatten", - "relparse", - "ververify", - "isjustname", - "isspecific", - "pkgsplit", - "catpkgsplit", - "vercmp", - "pkgcmp", - "dep_parenreduce", - "dep_opconvert", - "digraph", - -# fetch - "decodeurl", - "encodeurl", - -# modules - "parse", - "data", - "event", - "build", - "fetch", - "manifest", - "methodpool", - "cache", - "runqueue", - "taskdata", - "providers", - ] - -whitespace = '\t\n\x0b\x0c\r ' -lowercase = 'abcdefghijklmnopqrstuvwxyz' - -import sys, os, types, re, string, bb -from bb import msg - -#projectdir = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0]))) -projectdir = os.getcwd() - -if "BBDEBUG" in os.environ: - level = int(os.environ["BBDEBUG"]) - if level: - bb.msg.set_debug_level(level) - -class VarExpandError(Exception): - pass - -class MalformedUrl(Exception): - """Exception raised when encountering an invalid url""" - - -####################################################################### -####################################################################### -# -# SECTION: Debug -# -# PURPOSE: little functions to make yourself known -# -####################################################################### -####################################################################### - -def plain(*args): - bb.msg.warn(''.join(args)) - -def debug(lvl, *args): - bb.msg.debug(lvl, None, ''.join(args)) - -def note(*args): - bb.msg.note(1, None, ''.join(args)) - -def warn(*args): - bb.msg.warn(1, None, ''.join(args)) - -def error(*args): - bb.msg.error(None, ''.join(args)) - -def fatal(*args): - bb.msg.fatal(None, ''.join(args)) - - -####################################################################### -####################################################################### -# -# SECTION: File -# -# PURPOSE: Basic file and directory tree related functions -# -####################################################################### -####################################################################### - -def mkdirhier(dir): - """Create a directory like 'mkdir -p', but does not complain if - directory already exists like os.makedirs - """ - - debug(3, "mkdirhier(%s)" % dir) - try: - os.makedirs(dir) - debug(2, "created " + dir) - except OSError, e: - if e.errno != 17: raise e - - -####################################################################### - -import stat - -def movefile(src,dest,newmtime=None,sstat=None): - """Moves a file from src to dest, preserving all permissions and - attributes; mtime will be preserved even when moving across - filesystems. Returns true on success and false on failure. Move is - atomic. - """ - - #print "movefile("+src+","+dest+","+str(newmtime)+","+str(sstat)+")" - try: - if not sstat: - sstat=os.lstat(src) - except Exception, e: - print "!!! Stating source file failed... movefile()" - print "!!!",e - return None - - destexists=1 - try: - dstat=os.lstat(dest) - except: - dstat=os.lstat(os.path.dirname(dest)) - destexists=0 - - if destexists: - if stat.S_ISLNK(dstat[stat.ST_MODE]): - try: - os.unlink(dest) - destexists=0 - except Exception, e: - pass - - if stat.S_ISLNK(sstat[stat.ST_MODE]): - try: - target=os.readlink(src) - if destexists and not stat.S_ISDIR(dstat[stat.ST_MODE]): - os.unlink(dest) - os.symlink(target,dest) -# os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) - os.unlink(src) - return os.lstat(dest) - except Exception, e: - print "!!! failed to properly create symlink:" - print "!!!",dest,"->",target - print "!!!",e - return None - - renamefailed=1 - if sstat[stat.ST_DEV]==dstat[stat.ST_DEV]: - try: - ret=os.rename(src,dest) - renamefailed=0 - except Exception, e: - import errno - if e[0]!=errno.EXDEV: - # Some random error. - print "!!! Failed to move",src,"to",dest - print "!!!",e - return None - # Invalid cross-device-link 'bind' mounted or actually Cross-Device - - if renamefailed: - didcopy=0 - if stat.S_ISREG(sstat[stat.ST_MODE]): - try: # For safety copy then move it over. - shutil.copyfile(src,dest+"#new") - os.rename(dest+"#new",dest) - didcopy=1 - except Exception, e: - print '!!! copy',src,'->',dest,'failed.' - print "!!!",e - return None - else: - #we don't yet handle special, so we need to fall back to /bin/mv - a=getstatusoutput("/bin/mv -f "+"'"+src+"' '"+dest+"'") - if a[0]!=0: - print "!!! Failed to move special file:" - print "!!! '"+src+"' to '"+dest+"'" - print "!!!",a - return None # failure - try: - if didcopy: - missingos.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) - os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown - os.unlink(src) - except Exception, e: - print "!!! Failed to chown/chmod/unlink in movefile()" - print "!!!",dest - print "!!!",e - return None - - if newmtime: - os.utime(dest,(newmtime,newmtime)) - else: - os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME])) - newmtime=sstat[stat.ST_MTIME] - return newmtime - - - -####################################################################### -####################################################################### -# -# SECTION: Download -# -# PURPOSE: Download via HTTP, FTP, CVS, BITKEEPER, handling of MD5-signatures -# and mirrors -# -####################################################################### -####################################################################### - -def decodeurl(url): - """Decodes an URL into the tokens (scheme, network location, path, - user, password, parameters). - - >>> decodeurl("http://www.google.com/index.html") - ('http', 'www.google.com', '/index.html', '', '', {}) - - CVS url with username, host and cvsroot. The cvs module to check out is in the - parameters: - - >>> decodeurl("cvs://anoncvs@cvs.handhelds.org/cvs;module=familiar/dist/ipkg") - ('cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', '', {'module': 'familiar/dist/ipkg'}) - - Dito, but this time the username has a password part. And we also request a special tag - to check out. - - >>> decodeurl("cvs://anoncvs:anonymous@cvs.handhelds.org/cvs;module=familiar/dist/ipkg;tag=V0-99-81") - ('cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', 'anonymous', {'tag': 'V0-99-81', 'module': 'familiar/dist/ipkg'}) - """ - - m = re.compile('(?P<type>[^:]*)://((?P<user>.+)@)?(?P<location>[^;]+)(;(?P<parm>.*))?').match(url) - if not m: - raise MalformedUrl(url) - - type = m.group('type') - location = m.group('location') - if not location: - raise MalformedUrl(url) - user = m.group('user') - parm = m.group('parm') - - locidx = location.find('/') - if locidx != -1: - host = location[:locidx] - path = location[locidx:] - else: - host = "" - path = location - if user: - m = re.compile('(?P<user>[^:]+)(:?(?P<pswd>.*))').match(user) - if m: - user = m.group('user') - pswd = m.group('pswd') - else: - user = '' - pswd = '' - - p = {} - if parm: - for s in parm.split(';'): - s1,s2 = s.split('=') - p[s1] = s2 - - return (type, host, path, user, pswd, p) - -####################################################################### - -def encodeurl(decoded): - """Encodes a URL from tokens (scheme, network location, path, - user, password, parameters). - - >>> encodeurl(['http', 'www.google.com', '/index.html', '', '', {}]) - 'http://www.google.com/index.html' - - CVS with username, host and cvsroot. The cvs module to check out is in the - parameters: - - >>> encodeurl(['cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', '', {'module': 'familiar/dist/ipkg'}]) - 'cvs://anoncvs@cvs.handhelds.org/cvs;module=familiar/dist/ipkg' - - Dito, but this time the username has a password part. And we also request a special tag - to check out. - - >>> encodeurl(['cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', 'anonymous', {'tag': 'V0-99-81', 'module': 'familiar/dist/ipkg'}]) - 'cvs://anoncvs:anonymous@cvs.handhelds.org/cvs;tag=V0-99-81;module=familiar/dist/ipkg' - """ - - (type, host, path, user, pswd, p) = decoded - - if not type or not path: - fatal("invalid or missing parameters for url encoding") - url = '%s://' % type - if user: - url += "%s" % user - if pswd: - url += ":%s" % pswd - url += "@" - if host: - url += "%s" % host - url += "%s" % path - if p: - for parm in p.keys(): - url += ";%s=%s" % (parm, p[parm]) - - return url - -####################################################################### - -def which(path, item, direction = 0): - """ - Locate a file in a PATH - """ - - paths = (path or "").split(':') - if direction != 0: - paths.reverse() - - for p in (path or "").split(':'): - next = os.path.join(p, item) - if os.path.exists(next): - return next - - return "" - -####################################################################### - - - - -####################################################################### -####################################################################### -# -# SECTION: Dependency -# -# PURPOSE: Compare build & run dependencies -# -####################################################################### -####################################################################### - -def tokenize(mystring): - """Breaks a string like 'foo? (bar) oni? (blah (blah))' into (possibly embedded) lists: - - >>> tokenize("x") - ['x'] - >>> tokenize("x y") - ['x', 'y'] - >>> tokenize("(x y)") - [['x', 'y']] - >>> tokenize("(x y) b c") - [['x', 'y'], 'b', 'c'] - >>> tokenize("foo? (bar) oni? (blah (blah))") - ['foo?', ['bar'], 'oni?', ['blah', ['blah']]] - >>> tokenize("sys-apps/linux-headers nls? (sys-devel/gettext)") - ['sys-apps/linux-headers', 'nls?', ['sys-devel/gettext']] - """ - - newtokens = [] - curlist = newtokens - prevlists = [] - level = 0 - accum = "" - for x in mystring: - if x=="(": - if accum: - curlist.append(accum) - accum="" - prevlists.append(curlist) - curlist=[] - level=level+1 - elif x==")": - if accum: - curlist.append(accum) - accum="" - if level==0: - print "!!! tokenizer: Unmatched left parenthesis in:\n'"+mystring+"'" - return None - newlist=curlist - curlist=prevlists.pop() - curlist.append(newlist) - level=level-1 - elif x in whitespace: - if accum: - curlist.append(accum) - accum="" - else: - accum=accum+x - if accum: - curlist.append(accum) - if (level!=0): - print "!!! tokenizer: Exiting with unterminated parenthesis in:\n'"+mystring+"'" - return None - return newtokens - - -####################################################################### - -def evaluate(tokens,mydefines,allon=0): - """Removes tokens based on whether conditional definitions exist or not. - Recognizes ! - - >>> evaluate(['sys-apps/linux-headers', 'nls?', ['sys-devel/gettext']], {}) - ['sys-apps/linux-headers'] - - Negate the flag: - - >>> evaluate(['sys-apps/linux-headers', '!nls?', ['sys-devel/gettext']], {}) - ['sys-apps/linux-headers', ['sys-devel/gettext']] - - Define 'nls': - - >>> evaluate(['sys-apps/linux-headers', 'nls?', ['sys-devel/gettext']], {"nls":1}) - ['sys-apps/linux-headers', ['sys-devel/gettext']] - - Turn allon on: - - >>> evaluate(['sys-apps/linux-headers', 'nls?', ['sys-devel/gettext']], {}, True) - ['sys-apps/linux-headers', ['sys-devel/gettext']] - """ - - if tokens == None: - return None - mytokens = tokens + [] # this copies the list - pos = 0 - while pos < len(mytokens): - if type(mytokens[pos]) == types.ListType: - evaluate(mytokens[pos], mydefines) - if not len(mytokens[pos]): - del mytokens[pos] - continue - elif mytokens[pos][-1] == "?": - cur = mytokens[pos][:-1] - del mytokens[pos] - if allon: - if cur[0] == "!": - del mytokens[pos] - else: - if cur[0] == "!": - if (cur[1:] in mydefines) and (pos < len(mytokens)): - del mytokens[pos] - continue - elif (cur not in mydefines) and (pos < len(mytokens)): - del mytokens[pos] - continue - pos = pos + 1 - return mytokens - - -####################################################################### - -def flatten(mytokens): - """Converts nested arrays into a flat arrays: - - >>> flatten([1,[2,3]]) - [1, 2, 3] - >>> flatten(['sys-apps/linux-headers', ['sys-devel/gettext']]) - ['sys-apps/linux-headers', 'sys-devel/gettext'] - """ - - newlist=[] - for x in mytokens: - if type(x)==types.ListType: - newlist.extend(flatten(x)) - else: - newlist.append(x) - return newlist - - -####################################################################### - -_package_weights_ = {"pre":-2,"p":0,"alpha":-4,"beta":-3,"rc":-1} # dicts are unordered -_package_ends_ = ["pre", "p", "alpha", "beta", "rc", "cvs", "bk", "HEAD" ] # so we need ordered list - -def relparse(myver): - """Parses the last elements of a version number into a triplet, that can - later be compared: - - >>> relparse('1.2_pre3') - [1.2, -2, 3.0] - >>> relparse('1.2b') - [1.2, 98, 0] - >>> relparse('1.2') - [1.2, 0, 0] - """ - - number = 0 - p1 = 0 - p2 = 0 - mynewver = myver.split('_') - if len(mynewver)==2: - # an _package_weights_ - number = float(mynewver[0]) - match = 0 - for x in _package_ends_: - elen = len(x) - if mynewver[1][:elen] == x: - match = 1 - p1 = _package_weights_[x] - try: - p2 = float(mynewver[1][elen:]) - except: - p2 = 0 - break - if not match: - # normal number or number with letter at end - divider = len(myver)-1 - if myver[divider:] not in "1234567890": - # letter at end - p1 = ord(myver[divider:]) - number = float(myver[0:divider]) - else: - number = float(myver) - else: - # normal number or number with letter at end - divider = len(myver)-1 - if myver[divider:] not in "1234567890": - #letter at end - p1 = ord(myver[divider:]) - number = float(myver[0:divider]) - else: - number = float(myver) - return [number,p1,p2] - - -####################################################################### - -__ververify_cache__ = {} - -def ververify(myorigval,silent=1): - """Returns 1 if given a valid version string, els 0. Valid versions are in the format - - <v1>.<v2>...<vx>[a-z,_{_package_weights_}[vy]] - - >>> ververify('2.4.20') - 1 - >>> ververify('2.4..20') # two dots - 0 - >>> ververify('2.x.20') # 'x' is not numeric - 0 - >>> ververify('2.4.20a') - 1 - >>> ververify('2.4.20cvs') # only one trailing letter - 0 - >>> ververify('1a') - 1 - >>> ververify('test_a') # no version at all - 0 - >>> ververify('2.4.20_beta1') - 1 - >>> ververify('2.4.20_beta') - 1 - >>> ververify('2.4.20_wrongext') # _wrongext is no valid trailer - 0 - """ - - # Lookup the cache first - try: - return __ververify_cache__[myorigval] - except KeyError: - pass - - if len(myorigval) == 0: - if not silent: - error("package version is empty") - __ververify_cache__[myorigval] = 0 - return 0 - myval = myorigval.split('.') - if len(myval)==0: - if not silent: - error("package name has empty version string") - __ververify_cache__[myorigval] = 0 - return 0 - # all but the last version must be a numeric - for x in myval[:-1]: - if not len(x): - if not silent: - error("package version has two points in a row") - __ververify_cache__[myorigval] = 0 - return 0 - try: - foo = int(x) - except: - if not silent: - error("package version contains non-numeric '"+x+"'") - __ververify_cache__[myorigval] = 0 - return 0 - if not len(myval[-1]): - if not silent: - error("package version has trailing dot") - __ververify_cache__[myorigval] = 0 - return 0 - try: - foo = int(myval[-1]) - __ververify_cache__[myorigval] = 1 - return 1 - except: - pass - - # ok, our last component is not a plain number or blank, let's continue - if myval[-1][-1] in lowercase: - try: - foo = int(myval[-1][:-1]) - return 1 - __ververify_cache__[myorigval] = 1 - # 1a, 2.0b, etc. - except: - pass - # ok, maybe we have a 1_alpha or 1_beta2; let's see - ep=string.split(myval[-1],"_") - if len(ep)!= 2: - if not silent: - error("package version has more than one letter at then end") - __ververify_cache__[myorigval] = 0 - return 0 - try: - foo = string.atoi(ep[0]) - except: - # this needs to be numeric, i.e. the "1" in "1_alpha" - if not silent: - error("package version must have numeric part before the '_'") - __ververify_cache__[myorigval] = 0 - return 0 - - for mye in _package_ends_: - if ep[1][0:len(mye)] == mye: - if len(mye) == len(ep[1]): - # no trailing numeric is ok - __ververify_cache__[myorigval] = 1 - return 1 - else: - try: - foo = string.atoi(ep[1][len(mye):]) - __ververify_cache__[myorigval] = 1 - return 1 - except: - # if no _package_weights_ work, *then* we return 0 - pass - if not silent: - error("package version extension after '_' is invalid") - __ververify_cache__[myorigval] = 0 - return 0 - - -def isjustname(mypkg): - myparts = string.split(mypkg,'-') - for x in myparts: - if ververify(x): - return 0 - return 1 - - -_isspecific_cache_={} - -def isspecific(mypkg): - "now supports packages with no category" - try: - return __isspecific_cache__[mypkg] - except: - pass - - mysplit = string.split(mypkg,"/") - if not isjustname(mysplit[-1]): - __isspecific_cache__[mypkg] = 1 - return 1 - __isspecific_cache__[mypkg] = 0 - return 0 - - -####################################################################### - -__pkgsplit_cache__={} - -def pkgsplit(mypkg, silent=1): - - """This function can be used as a package verification function. If - it is a valid name, pkgsplit will return a list containing: - [pkgname, pkgversion(norev), pkgrev ]. - - >>> pkgsplit('') - >>> pkgsplit('x') - >>> pkgsplit('x-') - >>> pkgsplit('-1') - >>> pkgsplit('glibc-1.2-8.9-r7') - >>> pkgsplit('glibc-2.2.5-r7') - ['glibc', '2.2.5', 'r7'] - >>> pkgsplit('foo-1.2-1') - >>> pkgsplit('Mesa-3.0') - ['Mesa', '3.0', 'r0'] - """ - - try: - return __pkgsplit_cache__[mypkg] - except KeyError: - pass - - myparts = string.split(mypkg,'-') - if len(myparts) < 2: - if not silent: - error("package name without name or version part") - __pkgsplit_cache__[mypkg] = None - return None - for x in myparts: - if len(x) == 0: - if not silent: - error("package name with empty name or version part") - __pkgsplit_cache__[mypkg] = None - return None - # verify rev - revok = 0 - myrev = myparts[-1] - ververify(myrev, silent) - if len(myrev) and myrev[0] == "r": - try: - string.atoi(myrev[1:]) - revok = 1 - except: - pass - if revok: - if ververify(myparts[-2]): - if len(myparts) == 2: - __pkgsplit_cache__[mypkg] = None - return None - else: - for x in myparts[:-2]: - if ververify(x): - __pkgsplit_cache__[mypkg]=None - return None - # names can't have versiony looking parts - myval=[string.join(myparts[:-2],"-"),myparts[-2],myparts[-1]] - __pkgsplit_cache__[mypkg]=myval - return myval - else: - __pkgsplit_cache__[mypkg] = None - return None - - elif ververify(myparts[-1],silent): - if len(myparts)==1: - if not silent: - print "!!! Name error in",mypkg+": missing name part." - __pkgsplit_cache__[mypkg]=None - return None - else: - for x in myparts[:-1]: - if ververify(x): - if not silent: error("package name has multiple version parts") - __pkgsplit_cache__[mypkg] = None - return None - myval = [string.join(myparts[:-1],"-"), myparts[-1],"r0"] - __pkgsplit_cache__[mypkg] = myval - return myval - else: - __pkgsplit_cache__[mypkg] = None - return None - - -####################################################################### - -__catpkgsplit_cache__ = {} - -def catpkgsplit(mydata,silent=1): - """returns [cat, pkgname, version, rev ] - - >>> catpkgsplit('sys-libs/glibc-1.2-r7') - ['sys-libs', 'glibc', '1.2', 'r7'] - >>> catpkgsplit('glibc-1.2-r7') - [None, 'glibc', '1.2', 'r7'] - """ - - try: - return __catpkgsplit_cache__[mydata] - except KeyError: - pass - - cat = os.path.basename(os.path.dirname(mydata)) - mydata = os.path.join(cat, os.path.basename(mydata)) - if mydata[-3:] == '.bb': - mydata = mydata[:-3] - - mysplit = mydata.split("/") - p_split = None - splitlen = len(mysplit) - if splitlen == 1: - retval = [None] - p_split = pkgsplit(mydata,silent) - else: - retval = [mysplit[splitlen - 2]] - p_split = pkgsplit(mysplit[splitlen - 1],silent) - if not p_split: - __catpkgsplit_cache__[mydata] = None - return None - retval.extend(p_split) - __catpkgsplit_cache__[mydata] = retval - return retval - - -####################################################################### - -__vercmp_cache__ = {} - -def vercmp(val1,val2): - """This takes two version strings and returns an integer to tell you whether - the versions are the same, val1>val2 or val2>val1. - - >>> vercmp('1', '2') - -1.0 - >>> vercmp('2', '1') - 1.0 - >>> vercmp('1', '1.0') - 0 - >>> vercmp('1', '1.1') - -1.0 - >>> vercmp('1.1', '1_p2') - 1.0 - """ - - # quick short-circuit - if val1 == val2: - return 0 - valkey = val1+" "+val2 - - # cache lookup - try: - return __vercmp_cache__[valkey] - try: - return - __vercmp_cache__[val2+" "+val1] - except KeyError: - pass - except KeyError: - pass - - # consider 1_p2 vc 1.1 - # after expansion will become (1_p2,0) vc (1,1) - # then 1_p2 is compared with 1 before 0 is compared with 1 - # to solve the bug we need to convert it to (1,0_p2) - # by splitting _prepart part and adding it back _after_expansion - - val1_prepart = val2_prepart = '' - if val1.count('_'): - val1, val1_prepart = val1.split('_', 1) - if val2.count('_'): - val2, val2_prepart = val2.split('_', 1) - - # replace '-' by '.' - # FIXME: Is it needed? can val1/2 contain '-'? - - val1 = string.split(val1,'-') - if len(val1) == 2: - val1[0] = val1[0] +"."+ val1[1] - val2 = string.split(val2,'-') - if len(val2) == 2: - val2[0] = val2[0] +"."+ val2[1] - - val1 = string.split(val1[0],'.') - val2 = string.split(val2[0],'.') - - # add back decimal point so that .03 does not become "3" ! - for x in range(1,len(val1)): - if val1[x][0] == '0' : - val1[x] = '.' + val1[x] - for x in range(1,len(val2)): - if val2[x][0] == '0' : - val2[x] = '.' + val2[x] - - # extend varion numbers - if len(val2) < len(val1): - val2.extend(["0"]*(len(val1)-len(val2))) - elif len(val1) < len(val2): - val1.extend(["0"]*(len(val2)-len(val1))) - - # add back _prepart tails - if val1_prepart: - val1[-1] += '_' + val1_prepart - if val2_prepart: - val2[-1] += '_' + val2_prepart - # The above code will extend version numbers out so they - # have the same number of digits. - for x in range(0,len(val1)): - cmp1 = relparse(val1[x]) - cmp2 = relparse(val2[x]) - for y in range(0,3): - myret = cmp1[y] - cmp2[y] - if myret != 0: - __vercmp_cache__[valkey] = myret - return myret - __vercmp_cache__[valkey] = 0 - return 0 - - -####################################################################### - -def pkgcmp(pkg1,pkg2): - """ Compares two packages, which should have been split via - pkgsplit(). if the return value val is less than zero, then pkg2 is - newer than pkg1, zero if equal and positive if older. - - >>> pkgcmp(['glibc', '2.2.5', 'r7'], ['glibc', '2.2.5', 'r7']) - 0 - >>> pkgcmp(['glibc', '2.2.5', 'r4'], ['glibc', '2.2.5', 'r7']) - -1 - >>> pkgcmp(['glibc', '2.2.5', 'r7'], ['glibc', '2.2.5', 'r2']) - 1 - """ - - mycmp = vercmp(pkg1[1],pkg2[1]) - if mycmp > 0: - return 1 - if mycmp < 0: - return -1 - r1=string.atoi(pkg1[2][1:]) - r2=string.atoi(pkg2[2][1:]) - if r1 > r2: - return 1 - if r2 > r1: - return -1 - return 0 - - -####################################################################### - -def dep_parenreduce(mysplit, mypos=0): - """Accepts a list of strings, and converts '(' and ')' surrounded items to sub-lists: - - >>> dep_parenreduce(['']) - [''] - >>> dep_parenreduce(['1', '2', '3']) - ['1', '2', '3'] - >>> dep_parenreduce(['1', '(', '2', '3', ')', '4']) - ['1', ['2', '3'], '4'] - """ - - while mypos < len(mysplit): - if mysplit[mypos] == "(": - firstpos = mypos - mypos = mypos + 1 - while mypos < len(mysplit): - if mysplit[mypos] == ")": - mysplit[firstpos:mypos+1] = [mysplit[firstpos+1:mypos]] - mypos = firstpos - break - elif mysplit[mypos] == "(": - # recurse - mysplit = dep_parenreduce(mysplit,mypos) - mypos = mypos + 1 - mypos = mypos + 1 - return mysplit - - -def dep_opconvert(mysplit, myuse): - "Does dependency operator conversion" - - mypos = 0 - newsplit = [] - while mypos < len(mysplit): - if type(mysplit[mypos]) == types.ListType: - newsplit.append(dep_opconvert(mysplit[mypos],myuse)) - mypos += 1 - elif mysplit[mypos] == ")": - # mismatched paren, error - return None - elif mysplit[mypos]=="||": - if ((mypos+1)>=len(mysplit)) or (type(mysplit[mypos+1])!=types.ListType): - # || must be followed by paren'd list - return None - try: - mynew = dep_opconvert(mysplit[mypos+1],myuse) - except Exception, e: - error("unable to satisfy OR dependancy: " + string.join(mysplit," || ")) - raise e - mynew[0:0] = ["||"] - newsplit.append(mynew) - mypos += 2 - elif mysplit[mypos][-1] == "?": - # use clause, i.e "gnome? ( foo bar )" - # this is a quick and dirty hack so that repoman can enable all USE vars: - if (len(myuse) == 1) and (myuse[0] == "*"): - # enable it even if it's ! (for repoman) but kill it if it's - # an arch variable that isn't for this arch. XXX Sparc64? - if (mysplit[mypos][:-1] not in settings.usemask) or \ - (mysplit[mypos][:-1]==settings["ARCH"]): - enabled=1 - else: - enabled=0 - else: - if mysplit[mypos][0] == "!": - myusevar = mysplit[mypos][1:-1] - enabled = not myusevar in myuse - #if myusevar in myuse: - # enabled = 0 - #else: - # enabled = 1 - else: - myusevar=mysplit[mypos][:-1] - enabled = myusevar in myuse - #if myusevar in myuse: - # enabled=1 - #else: - # enabled=0 - if (mypos +2 < len(mysplit)) and (mysplit[mypos+2] == ":"): - # colon mode - if enabled: - # choose the first option - if type(mysplit[mypos+1]) == types.ListType: - newsplit.append(dep_opconvert(mysplit[mypos+1],myuse)) - else: - newsplit.append(mysplit[mypos+1]) - else: - # choose the alternate option - if type(mysplit[mypos+1]) == types.ListType: - newsplit.append(dep_opconvert(mysplit[mypos+3],myuse)) - else: - newsplit.append(mysplit[mypos+3]) - mypos += 4 - else: - # normal use mode - if enabled: - if type(mysplit[mypos+1]) == types.ListType: - newsplit.append(dep_opconvert(mysplit[mypos+1],myuse)) - else: - newsplit.append(mysplit[mypos+1]) - # otherwise, continue - mypos += 2 - else: - # normal item - newsplit.append(mysplit[mypos]) - mypos += 1 - return newsplit - -class digraph: - """beautiful directed graph object""" - - def __init__(self): - self.dict={} - #okeys = keys, in order they were added (to optimize firstzero() ordering) - self.okeys=[] - self.__callback_cache=[] - - def __str__(self): - str = "" - for key in self.okeys: - str += "%s:\t%s\n" % (key, self.dict[key][1]) - return str - - def addnode(self,mykey,myparent): - if not mykey in self.dict: - self.okeys.append(mykey) - if myparent==None: - self.dict[mykey]=[0,[]] - else: - self.dict[mykey]=[0,[myparent]] - self.dict[myparent][0]=self.dict[myparent][0]+1 - return - if myparent and (not myparent in self.dict[mykey][1]): - self.dict[mykey][1].append(myparent) - self.dict[myparent][0]=self.dict[myparent][0]+1 - - def delnode(self,mykey, ref = 1): - """Delete a node - - If ref is 1, remove references to this node from other nodes. - If ref is 2, remove nodes that reference this node.""" - if not mykey in self.dict: - return - for x in self.dict[mykey][1]: - self.dict[x][0]=self.dict[x][0]-1 - del self.dict[mykey] - while 1: - try: - self.okeys.remove(mykey) - except ValueError: - break - if ref: - __kill = [] - for k in self.okeys: - if mykey in self.dict[k][1]: - if ref == 1 or ref == 2: - self.dict[k][1].remove(mykey) - if ref == 2: - __kill.append(k) - for l in __kill: - self.delnode(l, ref) - - def allnodes(self): - "returns all nodes in the dictionary" - keys = self.dict.keys() - ret = [] - for key in keys: - ret.append(key) - ret.sort() - return ret - - def firstzero(self): - "returns first node with zero references, or NULL if no such node exists" - for x in self.okeys: - if self.dict[x][0]==0: - return x - return None - - def firstnonzero(self): - "returns first node with nonzero references, or NULL if no such node exists" - for x in self.okeys: - if self.dict[x][0]!=0: - return x - return None - - - def allzeros(self): - "returns all nodes with zero references, or NULL if no such node exists" - zerolist = [] - for x in self.dict.keys(): - if self.dict[x][0]==0: - zerolist.append(x) - return zerolist - - def hasallzeros(self): - "returns 0/1, Are all nodes zeros? 1 : 0" - zerolist = [] - for x in self.dict.keys(): - if self.dict[x][0]!=0: - return 0 - return 1 - - def empty(self): - if len(self.dict)==0: - return 1 - return 0 - - def hasnode(self,mynode): - return mynode in self.dict - - def getparents(self, item): - if not self.hasnode(item): - return [] - parents = self.dict[item][1] - ret = [] - for parent in parents: - ret.append(parent) - ret.sort() - return ret - - def getchildren(self, item): - if not self.hasnode(item): - return [] - children = [i for i in self.okeys if item in self.getparents(i)] - return children - - def walkdown(self, item, callback, debug = None, usecache = False): - if not self.hasnode(item): - return 0 - - if usecache: - if self.__callback_cache.count(item): - if debug: - print "hit cache for item: %s" % item - return 1 - - parents = self.getparents(item) - children = self.getchildren(item) - for p in parents: - if p in children: -# print "%s is both parent and child of %s" % (p, item) - if usecache: - self.__callback_cache.append(p) - ret = callback(self, p) - if ret == 0: - return 0 - continue - if item == p: - print "eek, i'm my own parent!" - return 0 - if debug: - print "item: %s, p: %s" % (item, p) - ret = self.walkdown(p, callback, debug, usecache) - if ret == 0: - return 0 - if usecache: - self.__callback_cache.append(item) - return callback(self, item) - - def walkup(self, item, callback): - if not self.hasnode(item): - return 0 - - parents = self.getparents(item) - children = self.getchildren(item) - for c in children: - if c in parents: - ret = callback(self, item) - if ret == 0: - return 0 - continue - if item == c: - print "eek, i'm my own child!" - return 0 - ret = self.walkup(c, callback) - if ret == 0: - return 0 - return callback(self, item) - - def copy(self): - mygraph=digraph() - for x in self.dict.keys(): - mygraph.dict[x]=self.dict[x][:] - mygraph.okeys=self.okeys[:] - return mygraph - -if __name__ == "__main__": - import doctest, bb - doctest.testmod(bb) diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py deleted file mode 100644 index 501f4f8206..0000000000 --- a/bitbake/lib/bb/build.py +++ /dev/null @@ -1,463 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -# -# BitBake 'Build' implementation -# -# Core code for function execution and task handling in the -# BitBake build tools. -# -# Copyright (C) 2003, 2004 Chris Larson -# -# Based on Gentoo's portage.py. -# -# 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. -# -# 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. -# -#Based on functions from the base bb module, Copyright 2003 Holger Schurig - -from bb import data, fetch, event, mkdirhier, utils -import bb, os - -# events -class FuncFailed(Exception): - """Executed function failed""" - -class EventException(Exception): - """Exception which is associated with an Event.""" - - def __init__(self, msg, event): - self.args = msg, event - -class TaskBase(event.Event): - """Base class for task events""" - - def __init__(self, t, d ): - self._task = t - event.Event.__init__(self, d) - - def getTask(self): - return self._task - - def setTask(self, task): - self._task = task - - task = property(getTask, setTask, None, "task property") - -class TaskStarted(TaskBase): - """Task execution started""" - -class TaskSucceeded(TaskBase): - """Task execution completed""" - -class TaskFailed(TaskBase): - """Task execution failed""" - -class InvalidTask(TaskBase): - """Invalid Task""" - -# functions - -def exec_func(func, d, dirs = None): - """Execute an BB 'function'""" - - body = data.getVar(func, d) - if not body: - return - - cleandirs = (data.expand(data.getVarFlag(func, 'cleandirs', d), d) or "").split() - for cdir in cleandirs: - os.system("rm -rf %s" % cdir) - - if not dirs: - dirs = (data.expand(data.getVarFlag(func, 'dirs', d), d) or "").split() - for adir in dirs: - mkdirhier(adir) - - if len(dirs) > 0: - adir = dirs[-1] - else: - adir = data.getVar('B', d, 1) - - adir = data.expand(adir, d) - - try: - prevdir = os.getcwd() - except OSError: - prevdir = data.expand('${TOPDIR}', d) - if adir and os.access(adir, os.F_OK): - os.chdir(adir) - - if data.getVarFlag(func, "python", d): - exec_func_python(func, d) - else: - exec_func_shell(func, d) - - if os.path.exists(prevdir): - os.chdir(prevdir) - -def exec_func_python(func, d): - """Execute a python BB 'function'""" - import re, os - - tmp = "def " + func + "():\n%s" % data.getVar(func, d) - tmp += '\n' + func + '()' - comp = utils.better_compile(tmp, func, bb.data.getVar('FILE', d, 1) ) - prevdir = os.getcwd() - g = {} # globals - g['bb'] = bb - g['os'] = os - g['d'] = d - utils.better_exec(comp,g,tmp, bb.data.getVar('FILE',d,1)) - if os.path.exists(prevdir): - os.chdir(prevdir) - -def exec_func_shell(func, d): - """Execute a shell BB 'function' Returns true if execution was successful. - - For this, it creates a bash shell script in the tmp dectory, writes the local - data into it and finally executes. The output of the shell will end in a log file and stdout. - - Note on directory behavior. The 'dirs' varflag should contain a list - of the directories you need created prior to execution. The last - item in the list is where we will chdir/cd to. - """ - import sys - - deps = data.getVarFlag(func, 'deps', d) - check = data.getVarFlag(func, 'check', d) - interact = data.getVarFlag(func, 'interactive', d) - if check in globals(): - if globals()[check](func, deps): - return - - global logfile - t = data.getVar('T', d, 1) - if not t: - return 0 - mkdirhier(t) - logfile = "%s/log.%s.%s" % (t, func, str(os.getpid())) - runfile = "%s/run.%s.%s" % (t, func, str(os.getpid())) - - f = open(runfile, "w") - f.write("#!/bin/sh -e\n") - if bb.msg.debug_level['default'] > 0: f.write("set -x\n") - data.emit_env(f, d) - - f.write("cd %s\n" % os.getcwd()) - if func: f.write("%s\n" % func) - f.close() - os.chmod(runfile, 0775) - if not func: - bb.msg.error(bb.msg.domain.Build, "Function not specified") - raise FuncFailed() - - # open logs - si = file('/dev/null', 'r') - try: - if bb.msg.debug_level['default'] > 0: - so = os.popen("tee \"%s\"" % logfile, "w") - else: - so = file(logfile, 'w') - except OSError, e: - bb.msg.error(bb.msg.domain.Build, "opening log file: %s" % e) - pass - - se = so - - if not interact: - # dup the existing fds so we dont lose them - osi = [os.dup(sys.stdin.fileno()), sys.stdin.fileno()] - oso = [os.dup(sys.stdout.fileno()), sys.stdout.fileno()] - ose = [os.dup(sys.stderr.fileno()), sys.stderr.fileno()] - - # replace those fds with our own - os.dup2(si.fileno(), osi[1]) - os.dup2(so.fileno(), oso[1]) - os.dup2(se.fileno(), ose[1]) - - # execute function - prevdir = os.getcwd() - if data.getVarFlag(func, "fakeroot", d): - maybe_fakeroot = "PATH=\"%s\" fakeroot " % bb.data.getVar("PATH", d, 1) - else: - maybe_fakeroot = '' - lang_environment = "LC_ALL=C " - ret = os.system('%s%ssh -e %s' % (lang_environment, maybe_fakeroot, runfile)) - try: - os.chdir(prevdir) - except: - pass - - if not interact: - # restore the backups - os.dup2(osi[0], osi[1]) - os.dup2(oso[0], oso[1]) - os.dup2(ose[0], ose[1]) - - # close our logs - si.close() - so.close() - se.close() - - # close the backup fds - os.close(osi[0]) - os.close(oso[0]) - os.close(ose[0]) - - if ret==0: - if bb.msg.debug_level['default'] > 0: - os.remove(runfile) -# os.remove(logfile) - return - else: - bb.msg.error(bb.msg.domain.Build, "function %s failed" % func) - if data.getVar("BBINCLUDELOGS", d): - bb.msg.error(bb.msg.domain.Build, "log data follows (%s)" % logfile) - number_of_lines = data.getVar("BBINCLUDELOGS_LINES", d) - if number_of_lines: - os.system('tail -n%s %s' % (number_of_lines, logfile)) - else: - f = open(logfile, "r") - while True: - l = f.readline() - if l == '': - break - l = l.rstrip() - print '| %s' % l - f.close() - else: - bb.msg.error(bb.msg.domain.Build, "see log in %s" % logfile) - raise FuncFailed( logfile ) - - -def exec_task(task, d): - """Execute an BB 'task' - - The primary difference between executing a task versus executing - a function is that a task exists in the task digraph, and therefore - has dependencies amongst other tasks.""" - - # check if the task is in the graph.. - task_graph = data.getVar('_task_graph', d) - if not task_graph: - task_graph = bb.digraph() - data.setVar('_task_graph', task_graph, d) - task_cache = data.getVar('_task_cache', d) - if not task_cache: - task_cache = [] - data.setVar('_task_cache', task_cache, d) - if not task_graph.hasnode(task): - raise EventException("Missing node in task graph", InvalidTask(task, d)) - - # check whether this task needs executing.. - if stamp_is_current(task, d): - return 1 - - # follow digraph path up, then execute our way back down - def execute(graph, item): - if data.getVarFlag(item, 'task', d): - if item in task_cache: - return 1 - - if task != item: - # deeper than toplevel, exec w/ deps - exec_task(item, d) - return 1 - - try: - bb.msg.debug(1, bb.msg.domain.Build, "Executing task %s" % item) - old_overrides = data.getVar('OVERRIDES', d, 0) - localdata = data.createCopy(d) - data.setVar('OVERRIDES', 'task_%s:%s' % (item, old_overrides), localdata) - data.update_data(localdata) - event.fire(TaskStarted(item, localdata)) - exec_func(item, localdata) - event.fire(TaskSucceeded(item, localdata)) - task_cache.append(item) - data.setVar('_task_cache', task_cache, d) - except FuncFailed, reason: - bb.msg.note(1, bb.msg.domain.Build, "Task failed: %s" % reason ) - failedevent = TaskFailed(item, d) - event.fire(failedevent) - raise EventException("Function failed in task: %s" % reason, failedevent) - - if data.getVarFlag(task, 'dontrundeps', d): - execute(None, task) - else: - task_graph.walkdown(task, execute) - - # make stamp, or cause event and raise exception - if not data.getVarFlag(task, 'nostamp', d): - make_stamp(task, d) - -def extract_stamp_data(d, fn): - """ - Extracts stamp data from d which is either a data dictonary (fn unset) - or a dataCache entry (fn set). - """ - if fn: - return (d.task_queues[fn], d.stamp[fn], d.task_deps[fn]) - task_graph = data.getVar('_task_graph', d) - if not task_graph: - task_graph = bb.digraph() - data.setVar('_task_graph', task_graph, d) - return (task_graph, data.getVar('STAMP', d, 1), None) - -def extract_stamp(d, fn): - """ - Extracts stamp format which is either a data dictonary (fn unset) - or a dataCache entry (fn set). - """ - if fn: - return d.stamp[fn] - return data.getVar('STAMP', d, 1) - -def stamp_is_current(task, d, file_name = None, checkdeps = 1): - """ - Check status of a given task's stamp. - Returns 0 if it is not current and needs updating. - (d can be a data dict or dataCache) - """ - - (task_graph, stampfn, taskdep) = extract_stamp_data(d, file_name) - - if not stampfn: - return 0 - - stampfile = "%s.%s" % (stampfn, task) - if not os.access(stampfile, os.F_OK): - return 0 - - if checkdeps == 0: - return 1 - - import stat - tasktime = os.stat(stampfile)[stat.ST_MTIME] - - _deps = [] - def checkStamp(graph, task): - # check for existance - if file_name: - if 'nostamp' in taskdep and task in taskdep['nostamp']: - return 1 - else: - if data.getVarFlag(task, 'nostamp', d): - return 1 - - if not stamp_is_current(task, d, file_name, 0 ): - return 0 - - depfile = "%s.%s" % (stampfn, task) - deptime = os.stat(depfile)[stat.ST_MTIME] - if deptime > tasktime: - return 0 - return 1 - - return task_graph.walkdown(task, checkStamp) - -def stamp_internal(task, d, file_name): - """ - Internal stamp helper function - Removes any stamp for the given task - Makes sure the stamp directory exists - Returns the stamp path+filename - """ - stamp = extract_stamp(d, file_name) - if not stamp: - return - stamp = "%s.%s" % (stamp, task) - mkdirhier(os.path.dirname(stamp)) - # Remove the file and recreate to force timestamp - # change on broken NFS filesystems - if os.access(stamp, os.F_OK): - os.remove(stamp) - return stamp - -def make_stamp(task, d, file_name = None): - """ - Creates/updates a stamp for a given task - (d can be a data dict or dataCache) - """ - stamp = stamp_internal(task, d, file_name) - if stamp: - f = open(stamp, "w") - f.close() - -def del_stamp(task, d, file_name = None): - """ - Removes a stamp for a given task - (d can be a data dict or dataCache) - """ - stamp_internal(task, d, file_name) - -def add_tasks(tasklist, d): - task_graph = data.getVar('_task_graph', d) - task_deps = data.getVar('_task_deps', d) - if not task_graph: - task_graph = bb.digraph() - if not task_deps: - task_deps = {} - - for task in tasklist: - deps = tasklist[task] - task = data.expand(task, d) - - data.setVarFlag(task, 'task', 1, d) - task_graph.addnode(task, None) - for dep in deps: - dep = data.expand(dep, d) - if not task_graph.hasnode(dep): - task_graph.addnode(dep, None) - task_graph.addnode(task, dep) - - flags = data.getVarFlags(task, d) - def getTask(name): - if name in flags: - deptask = data.expand(flags[name], d) - if not name in task_deps: - task_deps[name] = {} - task_deps[name][task] = deptask - getTask('depends') - getTask('deptask') - getTask('rdeptask') - getTask('recrdeptask') - getTask('nostamp') - - # don't assume holding a reference - data.setVar('_task_graph', task_graph, d) - data.setVar('_task_deps', task_deps, d) - -def remove_task(task, kill, d): - """Remove an BB 'task'. - - If kill is 1, also remove tasks that depend on this task.""" - - task_graph = data.getVar('_task_graph', d) - if not task_graph: - task_graph = bb.digraph() - if not task_graph.hasnode(task): - return - - data.delVarFlag(task, 'task', d) - ref = 1 - if kill == 1: - ref = 2 - task_graph.delnode(task, ref) - data.setVar('_task_graph', task_graph, d) - -def task_exists(task, d): - task_graph = data.getVar('_task_graph', d) - if not task_graph: - task_graph = bb.digraph() - data.setVar('_task_graph', task_graph, d) - return task_graph.hasnode(task) diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py deleted file mode 100644 index 7d7e66ebd2..0000000000 --- a/bitbake/lib/bb/cache.py +++ /dev/null @@ -1,436 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -# -# BitBake 'Event' implementation -# -# Caching of bitbake variables before task execution - -# Copyright (C) 2006 Richard Purdie - -# but small sections based on code from bin/bitbake: -# Copyright (C) 2003, 2004 Chris Larson -# Copyright (C) 2003, 2004 Phil Blundell -# Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer -# Copyright (C) 2005 Holger Hans Peter Freyther -# Copyright (C) 2005 ROAD GmbH -# -# 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. -# -# 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 os, re -import bb.data -import bb.utils -from sets import Set - -try: - import cPickle as pickle -except ImportError: - import pickle - bb.msg.note(1, bb.msg.domain.Cache, "Importing cPickle failed. Falling back to a very slow implementation.") - -__cache_version__ = "127" - -class Cache: - """ - BitBake Cache implementation - """ - def __init__(self, cooker): - - - self.cachedir = bb.data.getVar("CACHE", cooker.configuration.data, True) - self.clean = {} - self.depends_cache = {} - self.data = None - self.data_fn = None - - if self.cachedir in [None, '']: - self.has_cache = False - bb.msg.note(1, bb.msg.domain.Cache, "Not using a cache. Set CACHE = <directory> to enable.") - else: - self.has_cache = True - self.cachefile = os.path.join(self.cachedir,"bb_cache.dat") - - bb.msg.debug(1, bb.msg.domain.Cache, "Using cache in '%s'" % self.cachedir) - try: - os.stat( self.cachedir ) - except OSError: - bb.mkdirhier( self.cachedir ) - - if self.has_cache and (self.mtime(self.cachefile)): - try: - p = pickle.Unpickler( file(self.cachefile,"rb")) - self.depends_cache, version_data = p.load() - if version_data['CACHE_VER'] != __cache_version__: - raise ValueError, 'Cache Version Mismatch' - if version_data['BITBAKE_VER'] != bb.__version__: - raise ValueError, 'Bitbake Version Mismatch' - except EOFError: - bb.msg.note(1, bb.msg.domain.Cache, "Truncated cache found, rebuilding...") - self.depends_cache = {} - except (ValueError, KeyError): - bb.msg.note(1, bb.msg.domain.Cache, "Invalid cache found, rebuilding...") - self.depends_cache = {} - - if self.depends_cache: - for fn in self.depends_cache.keys(): - self.clean[fn] = "" - self.cacheValidUpdate(fn) - - def getVar(self, var, fn, exp = 0): - """ - Gets the value of a variable - (similar to getVar in the data class) - - There are two scenarios: - 1. We have cached data - serve from depends_cache[fn] - 2. We're learning what data to cache - serve from data - backend but add a copy of the data to the cache. - """ - - if fn in self.clean: - return self.depends_cache[fn][var] - - if not fn in self.depends_cache: - self.depends_cache[fn] = {} - - if fn != self.data_fn: - # We're trying to access data in the cache which doesn't exist - # yet setData hasn't been called to setup the right access. Very bad. - bb.msg.error(bb.msg.domain.Cache, "Parsing error data_fn %s and fn %s don't match" % (self.data_fn, fn)) - - result = bb.data.getVar(var, self.data, exp) - self.depends_cache[fn][var] = result - return result - - def setData(self, fn, data): - """ - Called to prime bb_cache ready to learn which variables to cache. - Will be followed by calls to self.getVar which aren't cached - but can be fulfilled from self.data. - """ - self.data_fn = fn - self.data = data - - # Make sure __depends makes the depends_cache - self.getVar("__depends", fn, True) - self.depends_cache[fn]["CACHETIMESTAMP"] = bb.parse.cached_mtime(fn) - - def loadDataFull(self, fn, cfgData): - """ - Return a complete set of data for fn. - To do this, we need to parse the file. - """ - bb_data, skipped = self.load_bbfile(fn, cfgData) - return bb_data - - def loadData(self, fn, cfgData): - """ - Load a subset of data for fn. - If the cached data is valid we do nothing, - To do this, we need to parse the file and set the system - to record the variables accessed. - Return the cache status and whether the file was skipped when parsed - """ - if self.cacheValid(fn): - if "SKIPPED" in self.depends_cache[fn]: - return True, True - return True, False - - bb_data, skipped = self.load_bbfile(fn, cfgData) - self.setData(fn, bb_data) - return False, skipped - - def cacheValid(self, fn): - """ - Is the cache valid for fn? - Fast version, no timestamps checked. - """ - # Is cache enabled? - if not self.has_cache: - return False - if fn in self.clean: - return True - return False - - def cacheValidUpdate(self, fn): - """ - Is the cache valid for fn? - Make thorough (slower) checks including timestamps. - """ - # Is cache enabled? - if not self.has_cache: - return False - - # Check file still exists - if self.mtime(fn) == 0: - bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s not longer exists" % fn) - self.remove(fn) - return False - - # File isn't in depends_cache - if not fn in self.depends_cache: - bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s is not cached" % fn) - self.remove(fn) - return False - - # Check the file's timestamp - if bb.parse.cached_mtime(fn) > self.getVar("CACHETIMESTAMP", fn, True): - bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s changed" % fn) - self.remove(fn) - return False - - # Check dependencies are still valid - depends = self.getVar("__depends", fn, True) - for f,old_mtime in depends: - # Check if file still exists - if self.mtime(f) == 0: - return False - - new_mtime = bb.parse.cached_mtime(f) - if (new_mtime > old_mtime): - bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s's dependency %s changed" % (fn, f)) - self.remove(fn) - return False - - bb.msg.debug(2, bb.msg.domain.Cache, "Depends Cache: %s is clean" % fn) - if not fn in self.clean: - self.clean[fn] = "" - - return True - - def skip(self, fn): - """ - Mark a fn as skipped - Called from the parser - """ - if not fn in self.depends_cache: - self.depends_cache[fn] = {} - self.depends_cache[fn]["SKIPPED"] = "1" - - def remove(self, fn): - """ - Remove a fn from the cache - Called from the parser in error cases - """ - bb.msg.debug(1, bb.msg.domain.Cache, "Removing %s from cache" % fn) - if fn in self.depends_cache: - del self.depends_cache[fn] - if fn in self.clean: - del self.clean[fn] - - def sync(self): - """ - Save the cache - Called from the parser when complete (or exiting) - """ - - if not self.has_cache: - return - - version_data = {} - version_data['CACHE_VER'] = __cache_version__ - version_data['BITBAKE_VER'] = bb.__version__ - - p = pickle.Pickler(file(self.cachefile, "wb" ), -1 ) - p.dump([self.depends_cache, version_data]) - - def mtime(self, cachefile): - return bb.parse.cached_mtime_noerror(cachefile) - - def handle_data(self, file_name, cacheData): - """ - Save data we need into the cache - """ - - pn = self.getVar('PN', file_name, True) - pe = self.getVar('PE', file_name, True) or "0" - pv = self.getVar('PV', file_name, True) - pr = self.getVar('PR', file_name, True) - dp = int(self.getVar('DEFAULT_PREFERENCE', file_name, True) or "0") - provides = Set([pn] + (self.getVar("PROVIDES", file_name, True) or "").split()) - depends = bb.utils.explode_deps(self.getVar("DEPENDS", file_name, True) or "") - packages = (self.getVar('PACKAGES', file_name, True) or "").split() - packages_dynamic = (self.getVar('PACKAGES_DYNAMIC', file_name, True) or "").split() - rprovides = (self.getVar("RPROVIDES", file_name, True) or "").split() - - cacheData.task_queues[file_name] = self.getVar("_task_graph", file_name, True) - cacheData.task_deps[file_name] = self.getVar("_task_deps", file_name, True) - - # build PackageName to FileName lookup table - if pn not in cacheData.pkg_pn: - cacheData.pkg_pn[pn] = [] - cacheData.pkg_pn[pn].append(file_name) - - cacheData.stamp[file_name] = self.getVar('STAMP', file_name, True) - - # build FileName to PackageName lookup table - cacheData.pkg_fn[file_name] = pn - cacheData.pkg_pepvpr[file_name] = (pe,pv,pr) - cacheData.pkg_dp[file_name] = dp - - # Build forward and reverse provider hashes - # Forward: virtual -> [filenames] - # Reverse: PN -> [virtuals] - if pn not in cacheData.pn_provides: - cacheData.pn_provides[pn] = Set() - cacheData.pn_provides[pn] |= provides - - cacheData.fn_provides[file_name] = Set() - for provide in provides: - if provide not in cacheData.providers: - cacheData.providers[provide] = [] - cacheData.providers[provide].append(file_name) - cacheData.fn_provides[file_name].add(provide) - - cacheData.deps[file_name] = Set() - for dep in depends: - cacheData.all_depends.add(dep) - cacheData.deps[file_name].add(dep) - - # Build reverse hash for PACKAGES, so runtime dependencies - # can be be resolved (RDEPENDS, RRECOMMENDS etc.) - for package in packages: - if not package in cacheData.packages: - cacheData.packages[package] = [] - cacheData.packages[package].append(file_name) - rprovides += (self.getVar("RPROVIDES_%s" % package, file_name, 1) or "").split() - - for package in packages_dynamic: - if not package in cacheData.packages_dynamic: - cacheData.packages_dynamic[package] = [] - cacheData.packages_dynamic[package].append(file_name) - - for rprovide in rprovides: - if not rprovide in cacheData.rproviders: - cacheData.rproviders[rprovide] = [] - cacheData.rproviders[rprovide].append(file_name) - - # Build hash of runtime depends and rececommends - - def add_dep(deplist, deps): - for dep in deps: - if not dep in deplist: - deplist[dep] = "" - - if not file_name in cacheData.rundeps: - cacheData.rundeps[file_name] = {} - if not file_name in cacheData.runrecs: - cacheData.runrecs[file_name] = {} - - for package in packages + [pn]: - if not package in cacheData.rundeps[file_name]: - cacheData.rundeps[file_name][package] = {} - if not package in cacheData.runrecs[file_name]: - cacheData.runrecs[file_name][package] = {} - - add_dep(cacheData.rundeps[file_name][package], bb.utils.explode_deps(self.getVar('RDEPENDS', file_name, True) or "")) - add_dep(cacheData.runrecs[file_name][package], bb.utils.explode_deps(self.getVar('RRECOMMENDS', file_name, True) or "")) - add_dep(cacheData.rundeps[file_name][package], bb.utils.explode_deps(self.getVar("RDEPENDS_%s" % package, file_name, True) or "")) - add_dep(cacheData.runrecs[file_name][package], bb.utils.explode_deps(self.getVar("RRECOMMENDS_%s" % package, file_name, True) or "")) - - # Collect files we may need for possible world-dep - # calculations - if not self.getVar('BROKEN', file_name, True) and not self.getVar('EXCLUDE_FROM_WORLD', file_name, True): - cacheData.possible_world.append(file_name) - - - def load_bbfile( self, bbfile , config): - """ - Load and parse one .bb build file - Return the data and whether parsing resulted in the file being skipped - """ - - import bb - from bb import utils, data, parse, debug, event, fatal - - # expand tmpdir to include this topdir - data.setVar('TMPDIR', data.getVar('TMPDIR', config, 1) or "", config) - bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) - oldpath = os.path.abspath(os.getcwd()) - if self.mtime(bbfile_loc): - os.chdir(bbfile_loc) - bb_data = data.init_db(config) - try: - bb_data = parse.handle(bbfile, bb_data) # read .bb data - os.chdir(oldpath) - return bb_data, False - except bb.parse.SkipPackage: - os.chdir(oldpath) - return bb_data, True - except: - os.chdir(oldpath) - raise - -def init(cooker): - """ - The Objective: Cache the minimum amount of data possible yet get to the - stage of building packages (i.e. tryBuild) without reparsing any .bb files. - - To do this, we intercept getVar calls and only cache the variables we see - being accessed. We rely on the cache getVar calls being made for all - variables bitbake might need to use to reach this stage. For each cached - file we need to track: - - * Its mtime - * The mtimes of all its dependencies - * Whether it caused a parse.SkipPackage exception - - Files causing parsing errors are evicted from the cache. - - """ - return Cache(cooker) - - - -#============================================================================# -# CacheData -#============================================================================# -class CacheData: - """ - The data structures we compile from the cached data - """ - - def __init__(self): - """ - Direct cache variables - (from Cache.handle_data) - """ - self.providers = {} - self.rproviders = {} - self.packages = {} - self.packages_dynamic = {} - self.possible_world = [] - self.pkg_pn = {} - self.pkg_fn = {} - self.pkg_pepvpr = {} - self.pkg_dp = {} - self.pn_provides = {} - self.fn_provides = {} - self.all_depends = Set() - self.deps = {} - self.rundeps = {} - self.runrecs = {} - self.task_queues = {} - self.task_deps = {} - self.stamp = {} - self.preferred = {} - - """ - Indirect Cache variables - (set elsewhere) - """ - self.ignored_dependencies = [] - self.world_target = Set() - self.bbfile_priority = {} - self.bbfile_config_priorities = [] diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py deleted file mode 100644 index c16709e552..0000000000 --- a/bitbake/lib/bb/cooker.py +++ /dev/null @@ -1,696 +0,0 @@ -#!/usr/bin/env python -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -# -# Copyright (C) 2003, 2004 Chris Larson -# Copyright (C) 2003, 2004 Phil Blundell -# Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer -# Copyright (C) 2005 Holger Hans Peter Freyther -# Copyright (C) 2005 ROAD GmbH -# Copyright (C) 2006 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. -# -# 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 sys, os, getopt, glob, copy, os.path, re, time -import bb -from bb import utils, data, parse, event, cache, providers, taskdata, runqueue -from sets import Set -import itertools, sre_constants - -parsespin = itertools.cycle( r'|/-\\' ) - -#============================================================================# -# BBCooker -#============================================================================# -class BBCooker: - """ - Manages one bitbake build run - """ - - def __init__(self, configuration): - self.status = None - - self.cache = None - self.bb_cache = None - - self.configuration = configuration - - if self.configuration.verbose: - bb.msg.set_verbose(True) - - if self.configuration.debug: - bb.msg.set_debug_level(self.configuration.debug) - else: - bb.msg.set_debug_level(0) - - if self.configuration.debug_domains: - bb.msg.set_debug_domains(self.configuration.debug_domains) - - self.configuration.data = bb.data.init() - - for f in self.configuration.file: - self.parseConfigurationFile( f ) - - self.parseConfigurationFile( os.path.join( "conf", "bitbake.conf" ) ) - - if not self.configuration.cmd: - self.configuration.cmd = bb.data.getVar("BB_DEFAULT_TASK", self.configuration.data) or "build" - - # - # Special updated configuration we use for firing events - # - self.configuration.event_data = bb.data.createCopy(self.configuration.data) - bb.data.update_data(self.configuration.event_data) - - # - # TOSTOP must not be set or our children will hang when they output - # - fd = sys.stdout.fileno() - if os.isatty(fd): - import termios - tcattr = termios.tcgetattr(fd) - if tcattr[3] & termios.TOSTOP: - bb.msg.note(1, bb.msg.domain.Build, "The terminal had the TOSTOP bit set, clearing...") - tcattr[3] = tcattr[3] & ~termios.TOSTOP - termios.tcsetattr(fd, termios.TCSANOW, tcattr) - - # Change nice level if we're asked to - nice = bb.data.getVar("BB_NICE_LEVEL", self.configuration.data, True) - if nice: - curnice = os.nice(0) - nice = int(nice) - curnice - bb.msg.note(2, bb.msg.domain.Build, "Renice to %s " % os.nice(nice)) - - - def tryBuildPackage(self, fn, item, task, the_data, build_depends): - """ - Build one task of a package, optionally build following task depends - """ - bb.event.fire(bb.event.PkgStarted(item, the_data)) - try: - if not build_depends: - bb.data.setVarFlag('do_%s' % task, 'dontrundeps', 1, the_data) - if not self.configuration.dry_run: - bb.build.exec_task('do_%s' % task, the_data) - bb.event.fire(bb.event.PkgSucceeded(item, the_data)) - return True - except bb.build.FuncFailed: - bb.msg.error(bb.msg.domain.Build, "task stack execution failed") - bb.event.fire(bb.event.PkgFailed(item, the_data)) - raise - except bb.build.EventException, e: - event = e.args[1] - bb.msg.error(bb.msg.domain.Build, "%s event exception, aborting" % bb.event.getName(event)) - bb.event.fire(bb.event.PkgFailed(item, the_data)) - raise - - def tryBuild( self, fn, build_depends): - """ - Build a provider and its dependencies. - build_depends is a list of previous build dependencies (not runtime) - If build_depends is empty, we're dealing with a runtime depends - """ - - the_data = self.bb_cache.loadDataFull(fn, self.configuration.data) - - item = self.status.pkg_fn[fn] - - if bb.build.stamp_is_current('do_%s' % self.configuration.cmd, the_data): - return True - - return self.tryBuildPackage(fn, item, self.configuration.cmd, the_data, build_depends) - - def showVersions(self): - pkg_pn = self.status.pkg_pn - preferred_versions = {} - latest_versions = {} - - # Sort by priority - for pn in pkg_pn.keys(): - (last_ver,last_file,pref_ver,pref_file) = bb.providers.findBestProvider(pn, self.configuration.data, self.status) - preferred_versions[pn] = (pref_ver, pref_file) - latest_versions[pn] = (last_ver, last_file) - - pkg_list = pkg_pn.keys() - pkg_list.sort() - - for p in pkg_list: - pref = preferred_versions[p] - latest = latest_versions[p] - - if pref != latest: - prefstr = pref[0][0] + ":" + pref[0][1] + '-' + pref[0][2] - else: - prefstr = "" - - print "%-30s %20s %20s" % (p, latest[0][0] + ":" + latest[0][1] + "-" + latest[0][2], - prefstr) - - - def showEnvironment( self ): - """Show the outer or per-package environment""" - if self.configuration.buildfile: - self.cb = None - self.bb_cache = bb.cache.init(self) - bf = self.matchFile(self.configuration.buildfile) - try: - self.configuration.data = self.bb_cache.loadDataFull(bf, self.configuration.data) - except IOError, e: - bb.msg.fatal(bb.msg.domain.Parsing, "Unable to read %s: %s" % (bf, e)) - except Exception, e: - bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e) - # emit variables and shell functions - try: - data.update_data( self.configuration.data ) - data.emit_env(sys.__stdout__, self.configuration.data, True) - except Exception, e: - bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e) - # emit the metadata which isnt valid shell - data.expandKeys( self.configuration.data ) - for e in self.configuration.data.keys(): - if data.getVarFlag( e, 'python', self.configuration.data ): - sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, data.getVar(e, self.configuration.data, 1))) - - def generateDotGraph( self, pkgs_to_build, ignore_deps ): - """ - Generate a task dependency graph. - - pkgs_to_build A list of packages that needs to be built - ignore_deps A list of names where processing of dependencies - should be stopped. e.g. dependencies that get - """ - - for dep in ignore_deps: - self.status.ignored_dependencies.add(dep) - - localdata = data.createCopy(self.configuration.data) - bb.data.update_data(localdata) - bb.data.expandKeys(localdata) - taskdata = bb.taskdata.TaskData(self.configuration.abort) - - runlist = [] - try: - for k in pkgs_to_build: - taskdata.add_provider(localdata, self.status, k) - runlist.append([k, "do_%s" % self.configuration.cmd]) - taskdata.add_unresolved(localdata, self.status) - except bb.providers.NoProvider: - sys.exit(1) - rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist) - rq.prepare_runqueue() - - seen_fnids = [] - depends_file = file('depends.dot', 'w' ) - tdepends_file = file('task-depends.dot', 'w' ) - print >> depends_file, "digraph depends {" - print >> tdepends_file, "digraph depends {" - rq.prio_map.reverse() - for task1 in range(len(rq.runq_fnid)): - task = rq.prio_map[task1] - taskname = rq.runq_task[task] - fnid = rq.runq_fnid[task] - fn = taskdata.fn_index[fnid] - pn = self.status.pkg_fn[fn] - version = "%s:%s-%s" % self.status.pkg_pepvpr[fn] - print >> tdepends_file, '"%s.%s" [label="%s %s\\n%s\\n%s"]' % (pn, taskname, pn, taskname, version, fn) - for dep in rq.runq_depends[task]: - depfn = taskdata.fn_index[rq.runq_fnid[dep]] - deppn = self.status.pkg_fn[depfn] - print >> tdepends_file, '"%s.%s" -> "%s.%s"' % (pn, rq.runq_task[task], deppn, rq.runq_task[dep]) - if fnid not in seen_fnids: - seen_fnids.append(fnid) - packages = [] - print >> depends_file, '"%s" [label="%s %s\\n%s"]' % (pn, pn, version, fn) - for depend in self.status.deps[fn]: - print >> depends_file, '"%s" -> "%s"' % (pn, depend) - rdepends = self.status.rundeps[fn] - for package in rdepends: - for rdepend in rdepends[package]: - print >> depends_file, '"%s" -> "%s" [style=dashed]' % (package, rdepend) - packages.append(package) - rrecs = self.status.runrecs[fn] - for package in rrecs: - for rdepend in rrecs[package]: - print >> depends_file, '"%s" -> "%s" [style=dashed]' % (package, rdepend) - if not package in packages: - packages.append(package) - for package in packages: - if package != pn: - print >> depends_file, '"%s" [label="%s(%s) %s\\n%s"]' % (package, package, pn, version, fn) - for depend in self.status.deps[fn]: - print >> depends_file, '"%s" -> "%s"' % (package, depend) - # Prints a flattened form of the above where subpackages of a package are merged into the main pn - #print >> depends_file, '"%s" [label="%s %s\\n%s\\n%s"]' % (pn, pn, taskname, version, fn) - #for rdep in taskdata.rdepids[fnid]: - # print >> depends_file, '"%s" -> "%s" [style=dashed]' % (pn, taskdata.run_names_index[rdep]) - #for dep in taskdata.depids[fnid]: - # print >> depends_file, '"%s" -> "%s"' % (pn, taskdata.build_names_index[dep]) - print >> depends_file, "}" - print >> tdepends_file, "}" - bb.msg.note(1, bb.msg.domain.Collection, "Dependencies saved to 'depends.dot'") - bb.msg.note(1, bb.msg.domain.Collection, "Task dependencies saved to 'task-depends.dot'") - - def buildDepgraph( self ): - all_depends = self.status.all_depends - pn_provides = self.status.pn_provides - - localdata = data.createCopy(self.configuration.data) - bb.data.update_data(localdata) - bb.data.expandKeys(localdata) - - def calc_bbfile_priority(filename): - for (regex, pri) in self.status.bbfile_config_priorities: - if regex.match(filename): - return pri - return 0 - - # Handle PREFERRED_PROVIDERS - for p in (bb.data.getVar('PREFERRED_PROVIDERS', localdata, 1) or "").split(): - try: - (providee, provider) = p.split(':') - except: - bb.msg.error(bb.msg.domain.Provider, "Malformed option in PREFERRED_PROVIDERS variable: %s" % p) - continue - if providee in self.status.preferred and self.status.preferred[providee] != provider: - bb.msg.error(bb.msg.domain.Provider, "conflicting preferences for %s: both %s and %s specified" % (providee, provider, self.status.preferred[providee])) - self.status.preferred[providee] = provider - - # Calculate priorities for each file - for p in self.status.pkg_fn.keys(): - self.status.bbfile_priority[p] = calc_bbfile_priority(p) - - def buildWorldTargetList(self): - """ - Build package list for "bitbake world" - """ - all_depends = self.status.all_depends - pn_provides = self.status.pn_provides - bb.msg.debug(1, bb.msg.domain.Parsing, "collating packages for \"world\"") - for f in self.status.possible_world: - terminal = True - pn = self.status.pkg_fn[f] - - for p in pn_provides[pn]: - if p.startswith('virtual/'): - bb.msg.debug(2, bb.msg.domain.Parsing, "World build skipping %s due to %s provider starting with virtual/" % (f, p)) - terminal = False - break - for pf in self.status.providers[p]: - if self.status.pkg_fn[pf] != pn: - bb.msg.debug(2, bb.msg.domain.Parsing, "World build skipping %s due to both us and %s providing %s" % (f, pf, p)) - terminal = False - break - if terminal: - self.status.world_target.add(pn) - - # drop reference count now - self.status.possible_world = None - self.status.all_depends = None - - def myProgressCallback( self, x, y, f, from_cache ): - """Update any tty with the progress change""" - if os.isatty(sys.stdout.fileno()): - sys.stdout.write("\rNOTE: Handling BitBake files: %s (%04d/%04d) [%2d %%]" % ( parsespin.next(), x, y, x*100/y ) ) - sys.stdout.flush() - else: - if x == 1: - sys.stdout.write("Parsing .bb files, please wait...") - sys.stdout.flush() - if x == y: - sys.stdout.write("done.") - sys.stdout.flush() - - def interactiveMode( self ): - """Drop off into a shell""" - try: - from bb import shell - except ImportError, details: - bb.msg.fatal(bb.msg.domain.Parsing, "Sorry, shell not available (%s)" % details ) - else: - bb.data.update_data( self.configuration.data ) - bb.data.expandKeys( self.configuration.data ) - shell.start( self ) - sys.exit( 0 ) - - def parseConfigurationFile( self, afile ): - try: - self.configuration.data = bb.parse.handle( afile, self.configuration.data ) - - # Add the handlers we inherited by INHERIT - # we need to do this manually as it is not guranteed - # we will pick up these classes... as we only INHERIT - # on .inc and .bb files but not on .conf - data = bb.data.createCopy( self.configuration.data ) - inherits = ["base"] + (bb.data.getVar('INHERIT', data, True ) or "").split() - for inherit in inherits: - data = bb.parse.handle( os.path.join('classes', '%s.bbclass' % inherit ), data, True ) - - # FIXME: This assumes that we included at least one .inc file - for var in bb.data.keys(data): - if bb.data.getVarFlag(var, 'handler', data): - bb.event.register(var,bb.data.getVar(var, data)) - - bb.fetch.fetcher_init(self.configuration.data) - - bb.event.fire(bb.event.ConfigParsed(self.configuration.data)) - - except IOError: - bb.msg.fatal(bb.msg.domain.Parsing, "Unable to open %s" % afile ) - except bb.parse.ParseError, details: - bb.msg.fatal(bb.msg.domain.Parsing, "Unable to parse %s (%s)" % (afile, details) ) - - def handleCollections( self, collections ): - """Handle collections""" - if collections: - collection_list = collections.split() - for c in collection_list: - regex = bb.data.getVar("BBFILE_PATTERN_%s" % c, self.configuration.data, 1) - if regex == None: - bb.msg.error(bb.msg.domain.Parsing, "BBFILE_PATTERN_%s not defined" % c) - continue - priority = bb.data.getVar("BBFILE_PRIORITY_%s" % c, self.configuration.data, 1) - if priority == None: - bb.msg.error(bb.msg.domain.Parsing, "BBFILE_PRIORITY_%s not defined" % c) - continue - try: - cre = re.compile(regex) - except re.error: - bb.msg.error(bb.msg.domain.Parsing, "BBFILE_PATTERN_%s \"%s\" is not a valid regular expression" % (c, regex)) - continue - try: - pri = int(priority) - self.status.bbfile_config_priorities.append((cre, pri)) - except ValueError: - bb.msg.error(bb.msg.domain.Parsing, "invalid value for BBFILE_PRIORITY_%s: \"%s\"" % (c, priority)) - - def buildSetVars(self): - """ - Setup any variables needed before starting a build - """ - if not bb.data.getVar("BUILDNAME", self.configuration.data): - bb.data.setVar("BUILDNAME", os.popen('date +%Y%m%d%H%M').readline().strip(), self.configuration.data) - bb.data.setVar("BUILDSTART", time.strftime('%m/%d/%Y %H:%M:%S',time.gmtime()),self.configuration.data) - - def matchFile(self, buildfile): - """ - Convert the fragment buildfile into a real file - Error if there are too many matches - """ - bf = os.path.abspath(buildfile) - try: - os.stat(bf) - return bf - except OSError: - (filelist, masked) = self.collect_bbfiles() - regexp = re.compile(buildfile) - matches = [] - for f in filelist: - if regexp.search(f) and os.path.isfile(f): - bf = f - matches.append(f) - if len(matches) != 1: - bb.msg.error(bb.msg.domain.Parsing, "Unable to match %s (%s matches found):" % (buildfile, len(matches))) - for f in matches: - bb.msg.error(bb.msg.domain.Parsing, " %s" % f) - sys.exit(1) - return matches[0] - - def buildFile(self, buildfile): - """ - Build the file matching regexp buildfile - """ - - bf = self.matchFile(buildfile) - - bbfile_data = bb.parse.handle(bf, self.configuration.data) - - # Remove stamp for target if force mode active - if self.configuration.force: - bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (self.configuration.cmd, bf)) - bb.build.del_stamp('do_%s' % self.configuration.cmd, bbfile_data) - - item = bb.data.getVar('PN', bbfile_data, 1) - try: - self.tryBuildPackage(bf, item, self.configuration.cmd, bbfile_data, True) - except bb.build.EventException: - bb.msg.error(bb.msg.domain.Build, "Build of '%s' failed" % item ) - - sys.exit(0) - - def buildTargets(self, targets): - """ - Attempt to build the targets specified - """ - - buildname = bb.data.getVar("BUILDNAME", self.configuration.data) - bb.event.fire(bb.event.BuildStarted(buildname, targets, self.configuration.event_data)) - - localdata = data.createCopy(self.configuration.data) - bb.data.update_data(localdata) - bb.data.expandKeys(localdata) - - taskdata = bb.taskdata.TaskData(self.configuration.abort) - - runlist = [] - try: - for k in targets: - taskdata.add_provider(localdata, self.status, k) - runlist.append([k, "do_%s" % self.configuration.cmd]) - taskdata.add_unresolved(localdata, self.status) - except bb.providers.NoProvider: - sys.exit(1) - - rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist) - rq.prepare_runqueue() - try: - failures = rq.execute_runqueue() - except runqueue.TaskFailure, fnids: - for fnid in fnids: - bb.msg.error(bb.msg.domain.Build, "'%s' failed" % taskdata.fn_index[fnid]) - sys.exit(1) - bb.event.fire(bb.event.BuildCompleted(buildname, targets, self.configuration.event_data, failures)) - - sys.exit(0) - - def updateCache(self): - # Import Psyco if available and not disabled - import platform - if platform.machine() in ['i386', 'i486', 'i586', 'i686']: - if not self.configuration.disable_psyco: - try: - import psyco - except ImportError: - bb.msg.note(1, bb.msg.domain.Collection, "Psyco JIT Compiler (http://psyco.sf.net) not available. Install it to increase performance.") - else: - psyco.bind( self.parse_bbfiles ) - else: - bb.msg.note(1, bb.msg.domain.Collection, "You have disabled Psyco. This decreases performance.") - - self.status = bb.cache.CacheData() - - ignore = bb.data.getVar("ASSUME_PROVIDED", self.configuration.data, 1) or "" - self.status.ignored_dependencies = Set( ignore.split() ) - - self.handleCollections( bb.data.getVar("BBFILE_COLLECTIONS", self.configuration.data, 1) ) - - bb.msg.debug(1, bb.msg.domain.Collection, "collecting .bb files") - (filelist, masked) = self.collect_bbfiles() - self.parse_bbfiles(filelist, masked, self.myProgressCallback) - bb.msg.debug(1, bb.msg.domain.Collection, "parsing complete") - - self.buildDepgraph() - - def cook(self): - """ - We are building stuff here. We do the building - from here. By default we try to execute task - build. - """ - - if self.configuration.show_environment: - self.showEnvironment() - sys.exit( 0 ) - - self.buildSetVars() - - if self.configuration.interactive: - self.interactiveMode() - - if self.configuration.buildfile is not None: - return self.buildFile(self.configuration.buildfile) - - # initialise the parsing status now we know we will need deps - self.updateCache() - - if self.configuration.parse_only: - bb.msg.note(1, bb.msg.domain.Collection, "Requested parsing .bb files only. Exiting.") - return 0 - - pkgs_to_build = self.configuration.pkgs_to_build - - bbpkgs = bb.data.getVar('BBPKGS', self.configuration.data, 1) - if bbpkgs: - pkgs_to_build.extend(bbpkgs.split()) - if len(pkgs_to_build) == 0 and not self.configuration.show_versions \ - and not self.configuration.show_environment: - print "Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help'" - print "for usage information." - sys.exit(0) - - try: - if self.configuration.show_versions: - self.showVersions() - sys.exit( 0 ) - if 'world' in pkgs_to_build: - self.buildWorldTargetList() - pkgs_to_build.remove('world') - for t in self.status.world_target: - pkgs_to_build.append(t) - - if self.configuration.dot_graph: - self.generateDotGraph( pkgs_to_build, self.configuration.ignored_dot_deps ) - sys.exit( 0 ) - - return self.buildTargets(pkgs_to_build) - - except KeyboardInterrupt: - bb.msg.note(1, bb.msg.domain.Collection, "KeyboardInterrupt - Build not completed.") - sys.exit(1) - - def get_bbfiles( self, path = os.getcwd() ): - """Get list of default .bb files by reading out the current directory""" - contents = os.listdir(path) - bbfiles = [] - for f in contents: - (root, ext) = os.path.splitext(f) - if ext == ".bb": - bbfiles.append(os.path.abspath(os.path.join(os.getcwd(),f))) - return bbfiles - - def find_bbfiles( self, path ): - """Find all the .bb files in a directory""" - from os.path import join - - found = [] - for dir, dirs, files in os.walk(path): - for ignored in ('SCCS', 'CVS', '.svn'): - if ignored in dirs: - dirs.remove(ignored) - found += [join(dir,f) for f in files if f.endswith('.bb')] - - return found - - def collect_bbfiles( self ): - """Collect all available .bb build files""" - parsed, cached, skipped, masked = 0, 0, 0, 0 - self.bb_cache = bb.cache.init(self) - - files = (data.getVar( "BBFILES", self.configuration.data, 1 ) or "").split() - data.setVar("BBFILES", " ".join(files), self.configuration.data) - - if not len(files): - files = self.get_bbfiles() - - if not len(files): - bb.msg.error(bb.msg.domain.Collection, "no files to build.") - - newfiles = [] - for f in files: - if os.path.isdir(f): - dirfiles = self.find_bbfiles(f) - if dirfiles: - newfiles += dirfiles - continue - newfiles += glob.glob(f) or [ f ] - - bbmask = bb.data.getVar('BBMASK', self.configuration.data, 1) - - if not bbmask: - return (newfiles, 0) - - try: - bbmask_compiled = re.compile(bbmask) - except sre_constants.error: - bb.msg.fatal(bb.msg.domain.Collection, "BBMASK is not a valid regular expression.") - - finalfiles = [] - for i in xrange( len( newfiles ) ): - f = newfiles[i] - if bbmask and bbmask_compiled.search(f): - bb.msg.debug(1, bb.msg.domain.Collection, "skipping masked file %s" % f) - masked += 1 - continue - finalfiles.append(f) - - return (finalfiles, masked) - - def parse_bbfiles(self, filelist, masked, progressCallback = None): - parsed, cached, skipped, error = 0, 0, 0, 0 - for i in xrange( len( filelist ) ): - f = filelist[i] - - bb.msg.debug(1, bb.msg.domain.Collection, "parsing %s" % f) - - # read a file's metadata - try: - fromCache, skip = self.bb_cache.loadData(f, self.configuration.data) - if skip: - skipped += 1 - bb.msg.debug(2, bb.msg.domain.Collection, "skipping %s" % f) - self.bb_cache.skip(f) - continue - elif fromCache: cached += 1 - else: parsed += 1 - deps = None - - # Disabled by RP as was no longer functional - # allow metadata files to add items to BBFILES - #data.update_data(self.pkgdata[f]) - #addbbfiles = self.bb_cache.getVar('BBFILES', f, False) or None - #if addbbfiles: - # for aof in addbbfiles.split(): - # if not files.count(aof): - # if not os.path.isabs(aof): - # aof = os.path.join(os.path.dirname(f),aof) - # files.append(aof) - - self.bb_cache.handle_data(f, self.status) - - # now inform the caller - if progressCallback is not None: - progressCallback( i + 1, len( filelist ), f, fromCache ) - - except IOError, e: - self.bb_cache.remove(f) - bb.msg.error(bb.msg.domain.Collection, "opening %s: %s" % (f, e)) - pass - except KeyboardInterrupt: - self.bb_cache.sync() - raise - except Exception, e: - error += 1 - self.bb_cache.remove(f) - bb.msg.error(bb.msg.domain.Collection, "%s while parsing %s" % (e, f)) - except: - self.bb_cache.remove(f) - raise - - if progressCallback is not None: - print "\r" # need newline after Handling Bitbake files message - bb.msg.note(1, bb.msg.domain.Collection, "Parsing finished. %d cached, %d parsed, %d skipped, %d masked." % ( cached, parsed, skipped, masked )) - - self.bb_cache.sync() - - if error > 0: - bb.msg.fatal(bb.msg.domain.Collection, "Parsing errors found, exiting...") diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py deleted file mode 100644 index 54b2615afb..0000000000 --- a/bitbake/lib/bb/data.py +++ /dev/null @@ -1,570 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'Data' implementations - -Functions for interacting with the data structure used by the -BitBake build tools. - -The expandData and update_data are the most expensive -operations. At night the cookie monster came by and -suggested 'give me cookies on setting the variables and -things will work out'. Taking this suggestion into account -applying the skills from the not yet passed 'Entwurf und -Analyse von Algorithmen' lecture and the cookie -monster seems to be right. We will track setVar more carefully -to have faster update_data and expandKeys operations. - -This is a treade-off between speed and memory again but -the speed is more critical here. -""" - -# Copyright (C) 2003, 2004 Chris Larson -# Copyright (C) 2005 Holger Hans Peter Freyther -# -# 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. -# -# 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. -# -#Based on functions from the base bb module, Copyright 2003 Holger Schurig - -import sys, os, re, time, types -if sys.argv[0][-5:] == "pydoc": - path = os.path.dirname(os.path.dirname(sys.argv[1])) -else: - path = os.path.dirname(os.path.dirname(sys.argv[0])) -sys.path.insert(0,path) - -from bb import data_smart -import bb - -_dict_type = data_smart.DataSmart - -def init(): - return _dict_type() - -def init_db(parent = None): - if parent: - return parent.createCopy() - else: - return _dict_type() - -def createCopy(source): - """Link the source set to the destination - If one does not find the value in the destination set, - search will go on to the source set to get the value. - Value from source are copy-on-write. i.e. any try to - modify one of them will end up putting the modified value - in the destination set. - """ - return source.createCopy() - -def initVar(var, d): - """Non-destructive var init for data structure""" - d.initVar(var) - - -def setVar(var, value, d): - """Set a variable to a given value - - Example: - >>> d = init() - >>> setVar('TEST', 'testcontents', d) - >>> print getVar('TEST', d) - testcontents - """ - d.setVar(var,value) - - -def getVar(var, d, exp = 0): - """Gets the value of a variable - - Example: - >>> d = init() - >>> setVar('TEST', 'testcontents', d) - >>> print getVar('TEST', d) - testcontents - """ - return d.getVar(var,exp) - - -def renameVar(key, newkey, d): - """Renames a variable from key to newkey - - Example: - >>> d = init() - >>> setVar('TEST', 'testcontents', d) - >>> renameVar('TEST', 'TEST2', d) - >>> print getVar('TEST2', d) - testcontents - """ - d.renameVar(key, newkey) - -def delVar(var, d): - """Removes a variable from the data set - - Example: - >>> d = init() - >>> setVar('TEST', 'testcontents', d) - >>> print getVar('TEST', d) - testcontents - >>> delVar('TEST', d) - >>> print getVar('TEST', d) - None - """ - d.delVar(var) - -def setVarFlag(var, flag, flagvalue, d): - """Set a flag for a given variable to a given value - - Example: - >>> d = init() - >>> setVarFlag('TEST', 'python', 1, d) - >>> print getVarFlag('TEST', 'python', d) - 1 - """ - d.setVarFlag(var,flag,flagvalue) - -def getVarFlag(var, flag, d): - """Gets given flag from given var - - Example: - >>> d = init() - >>> setVarFlag('TEST', 'python', 1, d) - >>> print getVarFlag('TEST', 'python', d) - 1 - """ - return d.getVarFlag(var,flag) - -def delVarFlag(var, flag, d): - """Removes a given flag from the variable's flags - - Example: - >>> d = init() - >>> setVarFlag('TEST', 'testflag', 1, d) - >>> print getVarFlag('TEST', 'testflag', d) - 1 - >>> delVarFlag('TEST', 'testflag', d) - >>> print getVarFlag('TEST', 'testflag', d) - None - - """ - d.delVarFlag(var,flag) - -def setVarFlags(var, flags, d): - """Set the flags for a given variable - - Note: - setVarFlags will not clear previous - flags. Think of this method as - addVarFlags - - Example: - >>> d = init() - >>> myflags = {} - >>> myflags['test'] = 'blah' - >>> setVarFlags('TEST', myflags, d) - >>> print getVarFlag('TEST', 'test', d) - blah - """ - d.setVarFlags(var,flags) - -def getVarFlags(var, d): - """Gets a variable's flags - - Example: - >>> d = init() - >>> setVarFlag('TEST', 'test', 'blah', d) - >>> print getVarFlags('TEST', d)['test'] - blah - """ - return d.getVarFlags(var) - -def delVarFlags(var, d): - """Removes a variable's flags - - Example: - >>> data = init() - >>> setVarFlag('TEST', 'testflag', 1, data) - >>> print getVarFlag('TEST', 'testflag', data) - 1 - >>> delVarFlags('TEST', data) - >>> print getVarFlags('TEST', data) - None - - """ - d.delVarFlags(var) - -def keys(d): - """Return a list of keys in d - - Example: - >>> d = init() - >>> setVar('TEST', 1, d) - >>> setVar('MOO' , 2, d) - >>> setVarFlag('TEST', 'test', 1, d) - >>> keys(d) - ['TEST', 'MOO'] - """ - return d.keys() - -def getData(d): - """Returns the data object used""" - return d - -def setData(newData, d): - """Sets the data object to the supplied value""" - d = newData - - -## -## Cookie Monsters' query functions -## -def _get_override_vars(d, override): - """ - Internal!!! - - Get the Names of Variables that have a specific - override. This function returns a iterable - Set or an empty list - """ - return [] - -def _get_var_flags_triple(d): - """ - Internal!!! - - """ - return [] - -__expand_var_regexp__ = re.compile(r"\${[^{}]+}") -__expand_python_regexp__ = re.compile(r"\${@.+?}") - -def expand(s, d, varname = None): - """Variable expansion using the data store. - - Example: - Standard expansion: - >>> d = init() - >>> setVar('A', 'sshd', d) - >>> print expand('/usr/bin/${A}', d) - /usr/bin/sshd - - Python expansion: - >>> d = init() - >>> print expand('result: ${@37 * 72}', d) - result: 2664 - - Shell expansion: - >>> d = init() - >>> print expand('${TARGET_MOO}', d) - ${TARGET_MOO} - >>> setVar('TARGET_MOO', 'yupp', d) - >>> print expand('${TARGET_MOO}',d) - yupp - >>> setVar('SRC_URI', 'http://somebug.${TARGET_MOO}', d) - >>> delVar('TARGET_MOO', d) - >>> print expand('${SRC_URI}', d) - http://somebug.${TARGET_MOO} - """ - return d.expand(s, varname) - -def expandKeys(alterdata, readdata = None): - if readdata == None: - readdata = alterdata - - todolist = {} - for key in keys(alterdata): - if not '${' in key: - continue - - ekey = expand(key, readdata) - if key == ekey: - continue - todolist[key] = ekey - - # These two for loops are split for performance to maximise the - # usefulness of the expand cache - - for key in todolist: - ekey = todolist[key] - renameVar(key, ekey, alterdata) - -def expandData(alterdata, readdata = None): - """For each variable in alterdata, expand it, and update the var contents. - Replacements use data from readdata. - - Example: - >>> a=init() - >>> b=init() - >>> setVar("dlmsg", "dl_dir is ${DL_DIR}", a) - >>> setVar("DL_DIR", "/path/to/whatever", b) - >>> expandData(a, b) - >>> print getVar("dlmsg", a) - dl_dir is /path/to/whatever - """ - if readdata == None: - readdata = alterdata - - for key in keys(alterdata): - val = getVar(key, alterdata) - if type(val) is not types.StringType: - continue - expanded = expand(val, readdata) -# print "key is %s, val is %s, expanded is %s" % (key, val, expanded) - if val != expanded: - setVar(key, expanded, alterdata) - -import os - -def inheritFromOS(d): - """Inherit variables from the environment.""" -# fakeroot needs to be able to set these - non_inherit_vars = [ "LD_LIBRARY_PATH", "LD_PRELOAD" ] - for s in os.environ.keys(): - if not s in non_inherit_vars: - try: - setVar(s, os.environ[s], d) - setVarFlag(s, 'matchesenv', '1', d) - except TypeError: - pass - -import sys - -def emit_var(var, o=sys.__stdout__, d = init(), all=False): - """Emit a variable to be sourced by a shell.""" - if getVarFlag(var, "python", d): - return 0 - - export = getVarFlag(var, "export", d) - unexport = getVarFlag(var, "unexport", d) - func = getVarFlag(var, "func", d) - if not all and not export and not unexport and not func: - return 0 - - try: - if all: - oval = getVar(var, d, 0) - val = getVar(var, d, 1) - except KeyboardInterrupt: - raise - except: - excname = str(sys.exc_info()[0]) - if excname == "bb.build.FuncFailed": - raise - o.write('# expansion of %s threw %s\n' % (var, excname)) - return 0 - - if all: - o.write('# %s=%s\n' % (var, oval)) - - if type(val) is not types.StringType: - return 0 - - if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all: - return 0 - - varExpanded = expand(var, d) - - if unexport: - o.write('unset %s\n' % varExpanded) - return 1 - - if getVarFlag(var, 'matchesenv', d): - return 0 - - val.rstrip() - if not val: - return 0 - - if func: - # NOTE: should probably check for unbalanced {} within the var - o.write("%s() {\n%s\n}\n" % (varExpanded, val)) - return 1 - - if export: - o.write('export ') - - # if we're going to output this within doublequotes, - # to a shell, we need to escape the quotes in the var - alter = re.sub('"', '\\"', val.strip()) - o.write('%s="%s"\n' % (varExpanded, alter)) - return 1 - - -def emit_env(o=sys.__stdout__, d = init(), all=False): - """Emits all items in the data store in a format such that it can be sourced by a shell.""" - - env = keys(d) - - for e in env: - if getVarFlag(e, "func", d): - continue - emit_var(e, o, d, all) and o.write('\n') - - for e in env: - if not getVarFlag(e, "func", d): - continue - emit_var(e, o, d) and o.write('\n') - -def update_data(d): - """Modifies the environment vars according to local overrides and commands. - Examples: - Appending to a variable: - >>> d = init() - >>> setVar('TEST', 'this is a', d) - >>> setVar('TEST_append', ' test', d) - >>> setVar('TEST_append', ' of the emergency broadcast system.', d) - >>> update_data(d) - >>> print getVar('TEST', d) - this is a test of the emergency broadcast system. - - Prepending to a variable: - >>> setVar('TEST', 'virtual/libc', d) - >>> setVar('TEST_prepend', 'virtual/tmake ', d) - >>> setVar('TEST_prepend', 'virtual/patcher ', d) - >>> update_data(d) - >>> print getVar('TEST', d) - virtual/patcher virtual/tmake virtual/libc - - Overrides: - >>> setVar('TEST_arm', 'target', d) - >>> setVar('TEST_ramses', 'machine', d) - >>> setVar('TEST_local', 'local', d) - >>> setVar('OVERRIDES', 'arm', d) - - >>> setVar('TEST', 'original', d) - >>> update_data(d) - >>> print getVar('TEST', d) - target - - >>> setVar('OVERRIDES', 'arm:ramses:local', d) - >>> setVar('TEST', 'original', d) - >>> update_data(d) - >>> print getVar('TEST', d) - local - - CopyMonster: - >>> e = d.createCopy() - >>> setVar('TEST_foo', 'foo', e) - >>> update_data(e) - >>> print getVar('TEST', e) - local - - >>> setVar('OVERRIDES', 'arm:ramses:local:foo', e) - >>> update_data(e) - >>> print getVar('TEST', e) - foo - - >>> f = d.createCopy() - >>> setVar('TEST_moo', 'something', f) - >>> setVar('OVERRIDES', 'moo:arm:ramses:local:foo', e) - >>> update_data(e) - >>> print getVar('TEST', e) - foo - - - >>> h = init() - >>> setVar('SRC_URI', 'file://append.foo;patch=1 ', h) - >>> g = h.createCopy() - >>> setVar('SRC_URI_append_arm', 'file://other.foo;patch=1', g) - >>> setVar('OVERRIDES', 'arm:moo', g) - >>> update_data(g) - >>> print getVar('SRC_URI', g) - file://append.foo;patch=1 file://other.foo;patch=1 - - """ - bb.msg.debug(2, bb.msg.domain.Data, "update_data()") - - # now ask the cookie monster for help - #print "Cookie Monster" - #print "Append/Prepend %s" % d._special_values - #print "Overrides %s" % d._seen_overrides - - overrides = (getVar('OVERRIDES', d, 1) or "").split(':') or [] - - # - # Well let us see what breaks here. We used to iterate - # over each variable and apply the override and then - # do the line expanding. - # If we have bad luck - which we will have - the keys - # where in some order that is so important for this - # method which we don't have anymore. - # Anyway we will fix that and write test cases this - # time. - - # - # First we apply all overrides - # Then we will handle _append and _prepend - # - - for o in overrides: - # calculate '_'+override - l = len(o)+1 - - # see if one should even try - if not d._seen_overrides.has_key(o): - continue - - vars = d._seen_overrides[o] - for var in vars: - name = var[:-l] - try: - d[name] = d[var] - except: - bb.msg.note(1, bb.msg.domain.Data, "Untracked delVar") - - # now on to the appends and prepends - if d._special_values.has_key('_append'): - appends = d._special_values['_append'] or [] - for append in appends: - for (a, o) in getVarFlag(append, '_append', d) or []: - # maybe the OVERRIDE was not yet added so keep the append - if (o and o in overrides) or not o: - delVarFlag(append, '_append', d) - if o and not o in overrides: - continue - - sval = getVar(append,d) or "" - sval+=a - setVar(append, sval, d) - - - if d._special_values.has_key('_prepend'): - prepends = d._special_values['_prepend'] or [] - - for prepend in prepends: - for (a, o) in getVarFlag(prepend, '_prepend', d) or []: - # maybe the OVERRIDE was not yet added so keep the prepend - if (o and o in overrides) or not o: - delVarFlag(prepend, '_prepend', d) - if o and not o in overrides: - continue - - sval = a + (getVar(prepend,d) or "") - setVar(prepend, sval, d) - - -def inherits_class(klass, d): - val = getVar('__inherit_cache', d) or [] - if os.path.join('classes', '%s.bbclass' % klass) in val: - return True - return False - -def _test(): - """Start a doctest run on this module""" - import doctest - from bb import data - doctest.testmod(data) - -if __name__ == "__main__": - _test() diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py deleted file mode 100644 index e879343f5d..0000000000 --- a/bitbake/lib/bb/data_smart.py +++ /dev/null @@ -1,292 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake Smart Dictionary Implementation - -Functions for interacting with the data structure used by the -BitBake build tools. - -""" - -# Copyright (C) 2003, 2004 Chris Larson -# Copyright (C) 2004, 2005 Seb Frankengul -# Copyright (C) 2005, 2006 Holger Hans Peter Freyther -# Copyright (C) 2005 Uli Luckas -# Copyright (C) 2005 ROAD GmbH -# -# 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. -# -# 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. -# Based on functions from the base bb module, Copyright 2003 Holger Schurig - -import copy, os, re, sys, time, types -import bb -from bb import utils, methodpool -from COW import COWDictBase -from sets import Set -from new import classobj - - -__setvar_keyword__ = ["_append","_prepend"] -__setvar_regexp__ = re.compile('(?P<base>.*?)(?P<keyword>_append|_prepend)(_(?P<add>.*))?') -__expand_var_regexp__ = re.compile(r"\${[^{}]+}") -__expand_python_regexp__ = re.compile(r"\${@.+?}") - - -class DataSmart: - def __init__(self, special = COWDictBase.copy(), seen = COWDictBase.copy() ): - self.dict = {} - - # cookie monster tribute - self._special_values = special - self._seen_overrides = seen - - self.expand_cache = {} - - def expand(self,s, varname): - def var_sub(match): - key = match.group()[2:-1] - if varname and key: - if varname == key: - raise Exception("variable %s references itself!" % varname) - var = self.getVar(key, 1) - if var is not None: - return var - else: - return match.group() - - def python_sub(match): - import bb - code = match.group()[3:-1] - locals()['d'] = self - s = eval(code) - if type(s) == types.IntType: s = str(s) - return s - - if type(s) is not types.StringType: # sanity check - return s - - if varname and varname in self.expand_cache: - return self.expand_cache[varname] - - while s.find('${') != -1: - olds = s - try: - s = __expand_var_regexp__.sub(var_sub, s) - s = __expand_python_regexp__.sub(python_sub, s) - if s == olds: break - if type(s) is not types.StringType: # sanity check - bb.msg.error(bb.msg.domain.Data, 'expansion of %s returned non-string %s' % (olds, s)) - except KeyboardInterrupt: - raise - except: - bb.msg.note(1, bb.msg.domain.Data, "%s:%s while evaluating:\n%s" % (sys.exc_info()[0], sys.exc_info()[1], s)) - raise - - if varname: - self.expand_cache[varname] = s - - return s - - def initVar(self, var): - self.expand_cache = {} - if not var in self.dict: - self.dict[var] = {} - - def _findVar(self,var): - _dest = self.dict - - while (_dest and var not in _dest): - if not "_data" in _dest: - _dest = None - break - _dest = _dest["_data"] - - if _dest and var in _dest: - return _dest[var] - return None - - def _makeShadowCopy(self, var): - if var in self.dict: - return - - local_var = self._findVar(var) - - if local_var: - self.dict[var] = copy.copy(local_var) - else: - self.initVar(var) - - def setVar(self,var,value): - self.expand_cache = {} - match = __setvar_regexp__.match(var) - if match and match.group("keyword") in __setvar_keyword__: - base = match.group('base') - keyword = match.group("keyword") - override = match.group('add') - l = self.getVarFlag(base, keyword) or [] - l.append([value, override]) - self.setVarFlag(base, keyword, l) - - # todo make sure keyword is not __doc__ or __module__ - # pay the cookie monster - try: - self._special_values[keyword].add( base ) - except: - self._special_values[keyword] = Set() - self._special_values[keyword].add( base ) - - return - - if not var in self.dict: - self._makeShadowCopy(var) - if self.getVarFlag(var, 'matchesenv'): - self.delVarFlag(var, 'matchesenv') - self.setVarFlag(var, 'export', 1) - - # more cookies for the cookie monster - if '_' in var: - override = var[var.rfind('_')+1:] - if not self._seen_overrides.has_key(override): - self._seen_overrides[override] = Set() - self._seen_overrides[override].add( var ) - - # setting var - self.dict[var]["content"] = value - - def getVar(self,var,exp): - value = self.getVarFlag(var,"content") - - if exp and value: - return self.expand(value,var) - return value - - def renameVar(self, key, newkey): - """ - Rename the variable key to newkey - """ - val = self.getVar(key, 0) - if val is None: - return - - self.setVar(newkey, val) - - for i in ('_append', '_prepend'): - dest = self.getVarFlag(newkey, i) or [] - src = self.getVarFlag(key, i) or [] - dest.extend(src) - self.setVarFlag(newkey, i, dest) - - if self._special_values.has_key(i) and key in self._special_values[i]: - self._special_values[i].remove(key) - self._special_values[i].add(newkey) - - self.delVar(key) - - def delVar(self,var): - self.expand_cache = {} - self.dict[var] = {} - - def setVarFlag(self,var,flag,flagvalue): - if not var in self.dict: - self._makeShadowCopy(var) - self.dict[var][flag] = flagvalue - - def getVarFlag(self,var,flag): - local_var = self._findVar(var) - if local_var: - if flag in local_var: - return copy.copy(local_var[flag]) - return None - - def delVarFlag(self,var,flag): - local_var = self._findVar(var) - if not local_var: - return - if not var in self.dict: - self._makeShadowCopy(var) - - if var in self.dict and flag in self.dict[var]: - del self.dict[var][flag] - - def setVarFlags(self,var,flags): - if not var in self.dict: - self._makeShadowCopy(var) - - for i in flags.keys(): - if i == "content": - continue - self.dict[var][i] = flags[i] - - def getVarFlags(self,var): - local_var = self._findVar(var) - flags = {} - - if local_var: - for i in self.dict[var].keys(): - if i == "content": - continue - flags[i] = self.dict[var][i] - - if len(flags) == 0: - return None - return flags - - - def delVarFlags(self,var): - if not var in self.dict: - self._makeShadowCopy(var) - - if var in self.dict: - content = None - - # try to save the content - if "content" in self.dict[var]: - content = self.dict[var]["content"] - self.dict[var] = {} - self.dict[var]["content"] = content - else: - del self.dict[var] - - - def createCopy(self): - """ - Create a copy of self by setting _data to self - """ - # we really want this to be a DataSmart... - data = DataSmart(seen=self._seen_overrides.copy(), special=self._special_values.copy()) - data.dict["_data"] = self.dict - - return data - - # Dictionary Methods - def keys(self): - def _keys(d, mykey): - if "_data" in d: - _keys(d["_data"],mykey) - - for key in d.keys(): - if key != "_data": - mykey[key] = None - keytab = {} - _keys(self.dict,keytab) - return keytab.keys() - - def __getitem__(self,item): - #print "Warning deprecated" - return self.getVar(item, False) - - def __setitem__(self,var,data): - #print "Warning deprecated" - self.setVar(var,data) - - diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py deleted file mode 100644 index 7148a2b7d6..0000000000 --- a/bitbake/lib/bb/event.py +++ /dev/null @@ -1,266 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'Event' implementation - -Classes and functions for manipulating 'events' in the -BitBake build tools. -""" - -# Copyright (C) 2003, 2004 Chris Larson -# -# 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. -# -# 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 os, re -import bb.utils - -class Event: - """Base class for events""" - type = "Event" - - def __init__(self, d): - self._data = d - - def getData(self): - return self._data - - def setData(self, data): - self._data = data - - data = property(getData, setData, None, "data property") - -NotHandled = 0 -Handled = 1 - -Registered = 10 -AlreadyRegistered = 14 - -# Internal -_handlers = [] -_handlers_dict = {} - -def tmpHandler(event): - """Default handler for code events""" - return NotHandled - -def defaultTmpHandler(): - tmp = "def tmpHandler(e):\n\t\"\"\"heh\"\"\"\n\treturn NotHandled" - comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event.defaultTmpHandler") - return comp - -def fire(event): - """Fire off an Event""" - for h in _handlers: - if type(h).__name__ == "code": - exec(h) - if tmpHandler(event) == Handled: - return Handled - else: - if h(event) == Handled: - return Handled - return NotHandled - -def register(name, handler): - """Register an Event handler""" - - # already registered - if name in _handlers_dict: - return AlreadyRegistered - - if handler is not None: -# handle string containing python code - if type(handler).__name__ == "str": - _registerCode(handler) - else: - _handlers.append(handler) - - _handlers_dict[name] = 1 - return Registered - -def _registerCode(handlerStr): - """Register a 'code' Event. - Deprecated interface; call register instead. - - Expects to be passed python code as a string, which will - be passed in turn to compile() and then exec(). Note that - the code will be within a function, so should have had - appropriate tabbing put in place.""" - tmp = "def tmpHandler(e):\n%s" % handlerStr - comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event._registerCode") -# prevent duplicate registration - _handlers.append(comp) - -def remove(name, handler): - """Remove an Event handler""" - - _handlers_dict.pop(name) - if type(handler).__name__ == "str": - return _removeCode(handler) - else: - _handlers.remove(handler) - -def _removeCode(handlerStr): - """Remove a 'code' Event handler - Deprecated interface; call remove instead.""" - tmp = "def tmpHandler(e):\n%s" % handlerStr - comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event._removeCode") - _handlers.remove(comp) - -def getName(e): - """Returns the name of a class or class instance""" - if getattr(e, "__name__", None) == None: - return e.__class__.__name__ - else: - return e.__name__ - -class ConfigParsed(Event): - """Configuration Parsing Complete""" - -class PkgBase(Event): - """Base class for package events""" - - def __init__(self, t, d): - self._pkg = t - Event.__init__(self, d) - - def getPkg(self): - return self._pkg - - def setPkg(self, pkg): - self._pkg = pkg - - pkg = property(getPkg, setPkg, None, "pkg property") - - -class BuildBase(Event): - """Base class for bbmake run events""" - - def __init__(self, n, p, c, failures = 0): - self._name = n - self._pkgs = p - Event.__init__(self, c) - self._failures = failures - - def getPkgs(self): - return self._pkgs - - def setPkgs(self, pkgs): - self._pkgs = pkgs - - def getName(self): - return self._name - - def setName(self, name): - self._name = name - - def getCfg(self): - return self.data - - def setCfg(self, cfg): - self.data = cfg - - def getFailures(self): - """ - Return the number of failed packages - """ - return self._failures - - pkgs = property(getPkgs, setPkgs, None, "pkgs property") - name = property(getName, setName, None, "name property") - cfg = property(getCfg, setCfg, None, "cfg property") - - -class DepBase(PkgBase): - """Base class for dependency events""" - - def __init__(self, t, data, d): - self._dep = d - PkgBase.__init__(self, t, data) - - def getDep(self): - return self._dep - - def setDep(self, dep): - self._dep = dep - - dep = property(getDep, setDep, None, "dep property") - - -class PkgStarted(PkgBase): - """Package build started""" - - -class PkgFailed(PkgBase): - """Package build failed""" - - -class PkgSucceeded(PkgBase): - """Package build completed""" - - -class BuildStarted(BuildBase): - """bbmake build run started""" - - -class BuildCompleted(BuildBase): - """bbmake build run completed""" - - -class UnsatisfiedDep(DepBase): - """Unsatisfied Dependency""" - - -class RecursiveDep(DepBase): - """Recursive Dependency""" - -class NoProvider(Event): - """No Provider for an Event""" - - def __init__(self, item, data,runtime=False): - Event.__init__(self, data) - self._item = item - self._runtime = runtime - - def getItem(self): - return self._item - - def isRuntime(self): - return self._runtime - -class MultipleProviders(Event): - """Multiple Providers""" - - def __init__(self, item, candidates, data, runtime = False): - Event.__init__(self, data) - self._item = item - self._candidates = candidates - self._is_runtime = runtime - - def isRuntime(self): - """ - Is this a runtime issue? - """ - return self._is_runtime - - def getItem(self): - """ - The name for the to be build item - """ - return self._item - - def getCandidates(self): - """ - Get the possible Candidates for a PROVIDER. - """ - return self._candidates diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py deleted file mode 100644 index eed7095819..0000000000 --- a/bitbake/lib/bb/fetch/__init__.py +++ /dev/null @@ -1,475 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'Fetch' implementations - -Classes for obtaining upstream sources for the -BitBake build tools. -""" - -# Copyright (C) 2003, 2004 Chris Larson -# -# 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. -# -# 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. -# -# Based on functions from the base bb module, Copyright 2003 Holger Schurig - -import os, re, fcntl -import bb -from bb import data -from bb import persist_data - -try: - import cPickle as pickle -except ImportError: - import pickle - -class FetchError(Exception): - """Exception raised when a download fails""" - -class NoMethodError(Exception): - """Exception raised when there is no method to obtain a supplied url or set of urls""" - -class MissingParameterError(Exception): - """Exception raised when a fetch method is missing a critical parameter in the url""" - -class ParameterError(Exception): - """Exception raised when a url cannot be proccessed due to invalid parameters.""" - -class MD5SumError(Exception): - """Exception raised when a MD5SUM of a file does not match the expected one""" - -def uri_replace(uri, uri_find, uri_replace, d): -# bb.msg.note(1, bb.msg.domain.Fetcher, "uri_replace: operating on %s" % uri) - if not uri or not uri_find or not uri_replace: - bb.msg.debug(1, bb.msg.domain.Fetcher, "uri_replace: passed an undefined value, not replacing") - uri_decoded = list(bb.decodeurl(uri)) - uri_find_decoded = list(bb.decodeurl(uri_find)) - uri_replace_decoded = list(bb.decodeurl(uri_replace)) - result_decoded = ['','','','','',{}] - for i in uri_find_decoded: - loc = uri_find_decoded.index(i) - result_decoded[loc] = uri_decoded[loc] - import types - if type(i) == types.StringType: - import re - if (re.match(i, uri_decoded[loc])): - result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc]) - if uri_find_decoded.index(i) == 2: - if d: - localfn = bb.fetch.localpath(uri, d) - if localfn: - result_decoded[loc] = os.path.dirname(result_decoded[loc]) + "/" + os.path.basename(bb.fetch.localpath(uri, d)) -# bb.msg.note(1, bb.msg.domain.Fetcher, "uri_replace: matching %s against %s and replacing with %s" % (i, uri_decoded[loc], uri_replace_decoded[loc])) - else: -# bb.msg.note(1, bb.msg.domain.Fetcher, "uri_replace: no match") - return uri -# else: -# for j in i.keys(): -# FIXME: apply replacements against options - return bb.encodeurl(result_decoded) - -methods = [] -urldata_cache = {} - -def fetcher_init(d): - """ - Called to initilize the fetchers once the configuration data is known - Calls before this must not hit the cache. - """ - pd = persist_data.PersistData(d) - # When to drop SCM head revisions controled by user policy - srcrev_policy = bb.data.getVar('BB_SRCREV_POLICY', d, 1) or "clear" - if srcrev_policy == "cache": - bb.msg.debug(1, bb.msg.domain.Fetcher, "Keeping SRCREV cache due to cache policy of: %s" % srcrev_policy) - elif srcrev_policy == "clear": - bb.msg.debug(1, bb.msg.domain.Fetcher, "Clearing SRCREV cache due to cache policy of: %s" % srcrev_policy) - pd.delDomain("BB_URI_HEADREVS") - else: - bb.msg.fatal(bb.msg.domain.Fetcher, "Invalid SRCREV cache policy of: %s" % srcrev_policy) - # Make sure our domains exist - pd.addDomain("BB_URI_HEADREVS") - pd.addDomain("BB_URI_LOCALCOUNT") - -# Function call order is usually: -# 1. init -# 2. go -# 3. localpaths -# localpath can be called at any time - -def init(urls, d, setup = True): - urldata = {} - fn = bb.data.getVar('FILE', d, 1) - if fn in urldata_cache: - urldata = urldata_cache[fn] - - for url in urls: - if url not in urldata: - urldata[url] = FetchData(url, d) - - if setup: - for url in urldata: - if not urldata[url].setup: - urldata[url].setup_localpath(d) - - urldata_cache[fn] = urldata - return urldata - -def go(d): - """ - Fetch all urls - init must have previously been called - """ - urldata = init([], d, True) - - for u in urldata: - ud = urldata[u] - m = ud.method - if ud.localfile: - if not m.forcefetch(u, ud, d) and os.path.exists(ud.md5): - # File already present along with md5 stamp file - # Touch md5 file to show activity - os.utime(ud.md5, None) - continue - lf = open(ud.lockfile, "a+") - fcntl.flock(lf.fileno(), fcntl.LOCK_EX) - if not m.forcefetch(u, ud, d) and os.path.exists(ud.md5): - # If someone else fetched this before we got the lock, - # notice and don't try again - os.utime(ud.md5, None) - fcntl.flock(lf.fileno(), fcntl.LOCK_UN) - lf.close - continue - m.go(u, ud, d) - if ud.localfile: - if not m.forcefetch(u, ud, d): - Fetch.write_md5sum(u, ud, d) - fcntl.flock(lf.fileno(), fcntl.LOCK_UN) - lf.close - -def localpaths(d): - """ - Return a list of the local filenames, assuming successful fetch - """ - local = [] - urldata = init([], d, True) - - for u in urldata: - ud = urldata[u] - local.append(ud.localpath) - - return local - -def get_srcrev(d): - """ - Return the version string for the current package - (usually to be used as PV) - Most packages usually only have one SCM so we just pass on the call. - In the multi SCM case, we build a value based on SRCREV_FORMAT which must - have been set. - """ - scms = [] - # Only call setup_localpath on URIs which suppports_srcrev() - urldata = init(bb.data.getVar('SRC_URI', d, 1).split(), d, False) - for u in urldata: - ud = urldata[u] - if ud.method.suppports_srcrev(): - if not ud.setup: - ud.setup_localpath(d) - scms.append(u) - - if len(scms) == 0: - bb.msg.error(bb.msg.domain.Fetcher, "SRCREV was used yet no valid SCM was found in SRC_URI") - raise ParameterError - - if len(scms) == 1: - return urldata[scms[0]].method.sortable_revision(scms[0], urldata[scms[0]], d) - - # - # Mutiple SCMs are in SRC_URI so we resort to SRCREV_FORMAT - # - format = bb.data.getVar('SRCREV_FORMAT', d, 1) - if not format: - bb.msg.error(bb.msg.domain.Fetcher, "The SRCREV_FORMAT variable must be set when multiple SCMs are used.") - raise ParameterError - - for scm in scms: - if 'name' in urldata[scm].parm: - name = urldata[scm].parm["name"] - rev = urldata[scm].method.sortable_revision(scm, urldata[scm], d) - format = format.replace(name, rev) - - return format - -def localpath(url, d, cache = True): - """ - Called from the parser with cache=False since the cache isn't ready - at this point. Also called from classed in OE e.g. patch.bbclass - """ - ud = init([url], d) - if ud[url].method: - return ud[url].localpath - return url - -def runfetchcmd(cmd, d, quiet = False): - """ - Run cmd returning the command output - Raise an error if interrupted or cmd fails - Optionally echo command output to stdout - """ - bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % cmd) - - # Need to export PATH as binary could be in metadata paths - # rather than host provided - pathcmd = 'export PATH=%s; %s' % (data.expand('${PATH}', d), cmd) - - stdout_handle = os.popen(pathcmd, "r") - output = "" - - while 1: - line = stdout_handle.readline() - if not line: - break - if not quiet: - print line, - output += line - - status = stdout_handle.close() or 0 - signal = status >> 8 - exitstatus = status & 0xff - - if signal: - raise FetchError("Fetch command %s failed with signal %s, output:\n%s" % (pathcmd, signal, output)) - elif status != 0: - raise FetchError("Fetch command %s failed with exit code %s, output:\n%s" % (pathcmd, status, output)) - - return output - -class FetchData(object): - """ - A class which represents the fetcher state for a given URI. - """ - def __init__(self, url, d): - self.localfile = "" - (self.type, self.host, self.path, self.user, self.pswd, self.parm) = bb.decodeurl(data.expand(url, d)) - self.date = Fetch.getSRCDate(self, d) - self.url = url - self.setup = False - for m in methods: - if m.supports(url, self, d): - self.method = m - break - - def setup_localpath(self, d): - self.setup = True - if "localpath" in self.parm: - self.localpath = self.parm["localpath"] - else: - self.localpath = self.method.localpath(self.url, self, d) - self.md5 = self.localpath + '.md5' - self.lockfile = self.localpath + '.lock' - # if user sets localpath for file, use it instead. - - -class Fetch(object): - """Base class for 'fetch'ing data""" - - def __init__(self, urls = []): - self.urls = [] - - def supports(self, url, urldata, d): - """ - Check to see if this fetch class supports a given url. - """ - return 0 - - def localpath(self, url, urldata, d): - """ - Return the local filename of a given url assuming a successful fetch. - Can also setup variables in urldata for use in go (saving code duplication - and duplicate code execution) - """ - return url - - def setUrls(self, urls): - self.__urls = urls - - def getUrls(self): - return self.__urls - - urls = property(getUrls, setUrls, None, "Urls property") - - def forcefetch(self, url, urldata, d): - """ - Force a fetch, even if localpath exists? - """ - return False - - def suppports_srcrev(self): - """ - The fetcher supports auto source revisions (SRCREV) - """ - return False - - def go(self, url, urldata, d): - """ - Fetch urls - Assumes localpath was called first - """ - raise NoMethodError("Missing implementation for url") - - def getSRCDate(urldata, d): - """ - Return the SRC Date for the component - - d the bb.data module - """ - if "srcdate" in urldata.parm: - return urldata.parm['srcdate'] - - pn = data.getVar("PN", d, 1) - - if pn: - return data.getVar("SRCDATE_%s" % pn, d, 1) or data.getVar("CVSDATE_%s" % pn, d, 1) or data.getVar("SRCDATE", d, 1) or data.getVar("CVSDATE", d, 1) or data.getVar("DATE", d, 1) - - return data.getVar("SRCDATE", d, 1) or data.getVar("CVSDATE", d, 1) or data.getVar("DATE", d, 1) - getSRCDate = staticmethod(getSRCDate) - - def try_mirror(d, tarfn): - """ - Try to use a mirrored version of the sources. We do this - to avoid massive loads on foreign cvs and svn servers. - This method will be used by the different fetcher - implementations. - - d Is a bb.data instance - tarfn is the name of the tarball - """ - tarpath = os.path.join(data.getVar("DL_DIR", d, 1), tarfn) - if os.access(tarpath, os.R_OK): - bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists, skipping checkout." % tarfn) - return True - - pn = data.getVar('PN', d, True) - src_tarball_stash = None - if pn: - src_tarball_stash = (data.getVar('SRC_TARBALL_STASH_%s' % pn, d, True) or data.getVar('CVS_TARBALL_STASH_%s' % pn, d, True) or data.getVar('SRC_TARBALL_STASH', d, True) or data.getVar('CVS_TARBALL_STASH', d, True) or "").split() - - for stash in src_tarball_stash: - fetchcmd = data.getVar("FETCHCOMMAND_mirror", d, True) or data.getVar("FETCHCOMMAND_wget", d, True) - uri = stash + tarfn - bb.msg.note(1, bb.msg.domain.Fetcher, "fetch " + uri) - fetchcmd = fetchcmd.replace("${URI}", uri) - ret = os.system(fetchcmd) - if ret == 0: - bb.msg.note(1, bb.msg.domain.Fetcher, "Fetched %s from tarball stash, skipping checkout" % tarfn) - return True - return False - try_mirror = staticmethod(try_mirror) - - def verify_md5sum(ud, got_sum): - """ - Verify the md5sum we wanted with the one we got - """ - wanted_sum = None - if 'md5sum' in ud.parm: - wanted_sum = ud.parm['md5sum'] - if not wanted_sum: - return True - - return wanted_sum == got_sum - verify_md5sum = staticmethod(verify_md5sum) - - def write_md5sum(url, ud, d): - if bb.which(data.getVar('PATH', d), 'md5sum'): - try: - md5pipe = os.popen('md5sum ' + ud.localpath) - md5data = (md5pipe.readline().split() or [ "" ])[0] - md5pipe.close() - except OSError: - md5data = "" - - # verify the md5sum - if not Fetch.verify_md5sum(ud, md5data): - raise MD5SumError(url) - - md5out = file(ud.md5, 'w') - md5out.write(md5data) - md5out.close() - write_md5sum = staticmethod(write_md5sum) - - def latest_revision(self, url, ud, d): - """ - Look in the cache for the latest revision, if not present ask the SCM. - """ - if not hasattr(self, "_latest_revision"): - raise ParameterError - - pd = persist_data.PersistData(d) - key = self._revision_key(url, ud, d) - rev = pd.getValue("BB_URI_HEADREVS", key) - if rev != None: - return str(rev) - - rev = self._latest_revision(url, ud, d) - pd.setValue("BB_URI_HEADREVS", key, rev) - return rev - - def sortable_revision(self, url, ud, d): - """ - - """ - if hasattr(self, "_sortable_revision"): - return self._sortable_revision(url, ud, d) - - pd = persist_data.PersistData(d) - key = self._revision_key(url, ud, d) - latest_rev = self.latest_revision(url, ud, d) - last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev") - count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count") - - if last_rev == latest_rev: - return str(count + "+" + latest_rev) - - if count is None: - count = "0" - else: - count = str(int(count) + 1) - - pd.setValue("BB_URI_LOCALCOUNT", key + "_rev", latest_rev) - pd.setValue("BB_URI_LOCALCOUNT", key + "_count", count) - - return str(count + "+" + latest_rev) - - -import cvs -import git -import local -import svn -import wget -import svk -import ssh -import perforce -import bzr -import hg - -methods.append(local.Local()) -methods.append(wget.Wget()) -methods.append(svn.Svn()) -methods.append(git.Git()) -methods.append(cvs.Cvs()) -methods.append(svk.Svk()) -methods.append(ssh.SSH()) -methods.append(perforce.Perforce()) -methods.append(bzr.Bzr()) -methods.append(hg.Hg()) diff --git a/bitbake/lib/bb/fetch/bzr.py b/bitbake/lib/bb/fetch/bzr.py deleted file mode 100644 index c66d17fdd2..0000000000 --- a/bitbake/lib/bb/fetch/bzr.py +++ /dev/null @@ -1,155 +0,0 @@ -""" -BitBake 'Fetch' implementation for bzr. - -""" - -# Copyright (C) 2007 Ross Burton -# Copyright (C) 2007 Richard Purdie -# -# Classes for obtaining upstream sources for the -# BitBake build tools. -# Copyright (C) 2003, 2004 Chris Larson -# -# 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. -# -# 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 os -import sys -import bb -from bb import data -from bb.fetch import Fetch -from bb.fetch import FetchError -from bb.fetch import MissingParameterError -from bb.fetch import runfetchcmd - -class Bzr(Fetch): - def supports(self, url, ud, d): - return ud.type in ['bzr'] - - def localpath (self, url, ud, d): - - # Create paths to bzr checkouts - relpath = ud.path - if relpath.startswith('/'): - # Remove leading slash as os.path.join can't cope - relpath = relpath[1:] - ud.pkgdir = os.path.join(data.expand('${BZRDIR}', d), ud.host, relpath) - - if 'rev' in ud.parm: - ud.revision = ud.parm['rev'] - else: - # ***Nasty hack*** - rev = data.getVar("SRCREV", d, 0) - if rev and "get_srcrev" in rev: - ud.revision = self.latest_revision(url, ud, d) - elif rev: - ud.revision = rev - else: - ud.revision = "" - - - ud.localfile = data.expand('bzr_%s_%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.revision), d) - - return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) - - def _buildbzrcommand(self, ud, d, command): - """ - Build up an bzr commandline based on ud - command is "fetch", "update", "revno" - """ - - basecmd = data.expand('${FETCHCMD_bzr}', d) - - proto = "http" - if "proto" in ud.parm: - proto = ud.parm["proto"] - - bzrroot = ud.host + ud.path - - options = [] - - if command is "revno": - bzrcmd = "%s revno %s %s://%s" % (basecmd, " ".join(options), proto, bzrroot) - else: - if ud.revision: - options.append("-r %s" % ud.revision) - - if command is "fetch": - bzrcmd = "%s co %s %s://%s" % (basecmd, " ".join(options), proto, bzrroot) - elif command is "update": - bzrcmd = "%s pull %s --overwrite" % (basecmd, " ".join(options)) - else: - raise FetchError("Invalid bzr command %s" % command) - - return bzrcmd - - def go(self, loc, ud, d): - """Fetch url""" - - # try to use the tarball stash - if Fetch.try_mirror(d, ud.localfile): - bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping bzr checkout." % ud.localpath) - return - - if os.access(os.path.join(ud.pkgdir, os.path.basename(ud.pkgdir), '.bzr'), os.R_OK): - bzrcmd = self._buildbzrcommand(ud, d, "update") - bb.msg.debug(1, bb.msg.domain.Fetcher, "BZR Update %s" % loc) - os.chdir(os.path.join (ud.pkgdir, os.path.basename(ud.path))) - runfetchcmd(bzrcmd, d) - else: - os.system("rm -rf %s" % os.path.join(ud.pkgdir, os.path.basename(ud.pkgdir))) - bzrcmd = self._buildbzrcommand(ud, d, "fetch") - bb.msg.debug(1, bb.msg.domain.Fetcher, "BZR Checkout %s" % loc) - bb.mkdirhier(ud.pkgdir) - os.chdir(ud.pkgdir) - bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % bzrcmd) - runfetchcmd(bzrcmd, d) - - os.chdir(ud.pkgdir) - # tar them up to a defined filename - try: - runfetchcmd("tar -czf %s %s" % (ud.localpath, os.path.basename(ud.pkgdir)), d) - except: - t, v, tb = sys.exc_info() - try: - os.unlink(ud.localpath) - except OSError: - pass - raise t, v, tb - - def suppports_srcrev(self): - return True - - def _revision_key(self, url, ud, d): - """ - Return a unique key for the url - """ - return "bzr:" + ud.pkgdir - - def _latest_revision(self, url, ud, d): - """ - Return the latest upstream revision number - """ - bb.msg.debug(2, bb.msg.domain.Fetcher, "BZR fetcher hitting network for %s" % url) - - output = runfetchcmd(self._buildbzrcommand(ud, d, "revno"), d, True) - - return output.strip() - - def _sortable_revision(self, url, ud, d): - """ - Return a sortable revision number which in our case is the revision number - (use the cached version to avoid network access) - """ - - return self.latest_revision(url, ud, d) diff --git a/bitbake/lib/bb/fetch/cvs.py b/bitbake/lib/bb/fetch/cvs.py deleted file mode 100644 index bd3317166c..0000000000 --- a/bitbake/lib/bb/fetch/cvs.py +++ /dev/null @@ -1,156 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'Fetch' implementations - -Classes for obtaining upstream sources for the -BitBake build tools. - -""" - -# Copyright (C) 2003, 2004 Chris Larson -# -# 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. -# -# 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. -# -#Based on functions from the base bb module, Copyright 2003 Holger Schurig -# - -import os, re -import bb -from bb import data -from bb.fetch import Fetch -from bb.fetch import FetchError -from bb.fetch import MissingParameterError - -class Cvs(Fetch): - """ - Class to fetch a module or modules from cvs repositories - """ - def supports(self, url, ud, d): - """ - Check to see if a given url can be fetched with cvs. - """ - return ud.type in ['cvs', 'pserver'] - - def localpath(self, url, ud, d): - if not "module" in ud.parm: - raise MissingParameterError("cvs method needs a 'module' parameter") - ud.module = ud.parm["module"] - - ud.tag = "" - if 'tag' in ud.parm: - ud.tag = ud.parm['tag'] - - # Override the default date in certain cases - if 'date' in ud.parm: - ud.date = ud.parm['date'] - elif ud.tag: - ud.date = "" - - ud.localfile = data.expand('%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.tag, ud.date), d) - - return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) - - def forcefetch(self, url, ud, d): - if (ud.date == "now"): - return True - return False - - def go(self, loc, ud, d): - - # try to use the tarball stash - if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile): - bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping cvs checkout." % ud.localpath) - return - - method = "pserver" - if "method" in ud.parm: - method = ud.parm["method"] - - localdir = ud.module - if "localdir" in ud.parm: - localdir = ud.parm["localdir"] - - cvs_port = "" - if "port" in ud.parm: - cvs_port = ud.parm["port"] - - cvs_rsh = None - if method == "ext": - if "rsh" in ud.parm: - cvs_rsh = ud.parm["rsh"] - - if method == "dir": - cvsroot = ud.path - else: - cvsroot = ":" + method + ":" + ud.user - if ud.pswd: - cvsroot += ":" + ud.pswd - cvsroot += "@" + ud.host + ":" + cvs_port + ud.path - - options = [] - if ud.date: - options.append("-D %s" % ud.date) - if ud.tag: - options.append("-r %s" % ud.tag) - - localdata = data.createCopy(d) - data.setVar('OVERRIDES', "cvs:%s" % data.getVar('OVERRIDES', localdata), localdata) - data.update_data(localdata) - - data.setVar('CVSROOT', cvsroot, localdata) - data.setVar('CVSCOOPTS', " ".join(options), localdata) - data.setVar('CVSMODULE', ud.module, localdata) - cvscmd = data.getVar('FETCHCOMMAND', localdata, 1) - cvsupdatecmd = data.getVar('UPDATECOMMAND', localdata, 1) - - if cvs_rsh: - cvscmd = "CVS_RSH=\"%s\" %s" % (cvs_rsh, cvscmd) - cvsupdatecmd = "CVS_RSH=\"%s\" %s" % (cvs_rsh, cvsupdatecmd) - - # create module directory - bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: checking for module directory") - pkg = data.expand('${PN}', d) - pkgdir = os.path.join(data.expand('${CVSDIR}', localdata), pkg) - moddir = os.path.join(pkgdir,localdir) - if os.access(os.path.join(moddir,'CVS'), os.R_OK): - bb.msg.note(1, bb.msg.domain.Fetcher, "Update " + loc) - # update sources there - os.chdir(moddir) - myret = os.system(cvsupdatecmd) - else: - bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc) - # check out sources there - bb.mkdirhier(pkgdir) - os.chdir(pkgdir) - bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % cvscmd) - myret = os.system(cvscmd) - - if myret != 0 or not os.access(moddir, os.R_OK): - try: - os.rmdir(moddir) - except OSError: - pass - raise FetchError(ud.module) - - os.chdir(moddir) - os.chdir('..') - # tar them up to a defined filename - myret = os.system("tar -czf %s %s" % (ud.localpath, os.path.basename(moddir))) - if myret != 0: - try: - os.unlink(ud.localpath) - except OSError: - pass - raise FetchError(ud.module) diff --git a/bitbake/lib/bb/fetch/git.py b/bitbake/lib/bb/fetch/git.py deleted file mode 100644 index 7d55ee9138..0000000000 --- a/bitbake/lib/bb/fetch/git.py +++ /dev/null @@ -1,131 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'Fetch' git implementation - -""" - -#Copyright (C) 2005 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. -# -# 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 os, re -import bb -from bb import data -from bb.fetch import Fetch -from bb.fetch import FetchError -from bb.fetch import runfetchcmd - -def prunedir(topdir): - # Delete everything reachable from the directory named in 'topdir'. - # CAUTION: This is dangerous! - for root, dirs, files in os.walk(topdir, topdown=False): - for name in files: - os.remove(os.path.join(root, name)) - for name in dirs: - os.rmdir(os.path.join(root, name)) - -class Git(Fetch): - """Class to fetch a module or modules from git repositories""" - def supports(self, url, ud, d): - """ - Check to see if a given url can be fetched with git. - """ - return ud.type in ['git'] - - def localpath(self, url, ud, d): - - ud.proto = "rsync" - if 'protocol' in ud.parm: - ud.proto = ud.parm['protocol'] - - tag = data.getVar("SRCREV", d, 0) - if 'tag' in ud.parm: - ud.tag = ud.parm['tag'] - elif tag and "get_srcrev" not in tag and len(tag) == 40: - ud.tag = tag - else: - ud.tag = self.latest_revision(url, ud, d) - - ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.tag), d) - - return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) - - def go(self, loc, ud, d): - """Fetch url""" - - if Fetch.try_mirror(d, ud.localfile): - bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists (or was stashed). Skipping git checkout." % ud.localpath) - return - - gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.')) - - repofilename = 'git_%s.tar.gz' % (gitsrcname) - repofile = os.path.join(data.getVar("DL_DIR", d, 1), repofilename) - repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) - - coname = '%s' % (ud.tag) - codir = os.path.join(repodir, coname) - - if not os.path.exists(repodir): - if Fetch.try_mirror(d, repofilename): - bb.mkdirhier(repodir) - os.chdir(repodir) - runfetchcmd("tar -xzf %s" % (repofile), d) - else: - runfetchcmd("git clone -n %s://%s%s %s" % (ud.proto, ud.host, ud.path, repodir), d) - - os.chdir(repodir) - # Remove all but the .git directory - runfetchcmd("rm * -Rf", d) - runfetchcmd("git pull %s://%s%s" % (ud.proto, ud.host, ud.path), d) - runfetchcmd("git pull --tags %s://%s%s" % (ud.proto, ud.host, ud.path), d) - runfetchcmd("git prune-packed", d) - runfetchcmd("git pack-redundant --all | xargs -r rm", d) - # old method of downloading tags - #runfetchcmd("rsync -a --verbose --stats --progress rsync://%s%s/ %s" % (ud.host, ud.path, os.path.join(repodir, ".git", "")), d) - - os.chdir(repodir) - bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git repository") - runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ), d) - - if os.path.exists(codir): - prunedir(codir) - - bb.mkdirhier(codir) - os.chdir(repodir) - runfetchcmd("git read-tree %s" % (ud.tag), d) - runfetchcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")), d) - - os.chdir(codir) - bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout") - runfetchcmd("tar -czf %s %s" % (ud.localpath, os.path.join(".", "*") ), d) - - os.chdir(repodir) - prunedir(codir) - - def suppports_srcrev(self): - return True - - def _revision_key(self, url, ud, d): - """ - Return a unique key for the url - """ - return "git:" + ud.host + ud.path.replace('/', '.') - - def _latest_revision(self, url, ud, d): - - output = runfetchcmd("git ls-remote %s://%s%s" % (ud.proto, ud.host, ud.path), d, True) - return output.split()[0] - diff --git a/bitbake/lib/bb/fetch/hg.py b/bitbake/lib/bb/fetch/hg.py deleted file mode 100644 index 8e8073e56d..0000000000 --- a/bitbake/lib/bb/fetch/hg.py +++ /dev/null @@ -1,150 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'Fetch' implementation for mercurial DRCS (hg). - -""" - -# Copyright (C) 2003, 2004 Chris Larson -# Copyright (C) 2004 Marcin Juszkiewicz -# Copyright (C) 2007 Robert Schuster -# -# 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. -# -# 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. -# -# Based on functions from the base bb module, Copyright 2003 Holger Schurig - -import os, re -import sys -import bb -from bb import data -from bb.fetch import Fetch -from bb.fetch import FetchError -from bb.fetch import MissingParameterError -from bb.fetch import runfetchcmd - -class Hg(Fetch): - """Class to fetch a from mercurial repositories""" - def supports(self, url, ud, d): - """ - Check to see if a given url can be fetched with mercurial. - """ - return ud.type in ['hg'] - - def localpath(self, url, ud, d): - if not "module" in ud.parm: - raise MissingParameterError("hg method needs a 'module' parameter") - - ud.module = ud.parm["module"] - - # Create paths to mercurial checkouts - relpath = ud.path - if relpath.startswith('/'): - # Remove leading slash as os.path.join can't cope - relpath = relpath[1:] - ud.pkgdir = os.path.join(data.expand('${HGDIR}', d), ud.host, relpath) - ud.moddir = os.path.join(ud.pkgdir, ud.module) - - if 'rev' in ud.parm: - ud.revision = ud.parm['rev'] - else: - # - rev = data.getVar("SRCREV", d, 0) - if rev and "get_srcrev" in rev: - ud.revision = self.latest_revision(url, ud, d) - elif rev: - ud.revision = rev - else: - ud.revision = "" - - ud.localfile = data.expand('%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision), d) - - return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) - - def _buildhgcommand(self, ud, d, command): - """ - Build up an hg commandline based on ud - command is "fetch", "update", "info" - """ - - basecmd = data.expand('${FETCHCMD_hg}', d) - - proto = "http" - if "proto" in ud.parm: - proto = ud.parm["proto"] - - host = ud.host - if proto == "file": - host = "/" - ud.host = "localhost" - - hgroot = host + ud.path - - if command is "info": - return "%s identify -i %s://%s/%s" % (basecmd, proto, hgroot, ud.module) - - options = []; - if ud.revision: - options.append("-r %s" % ud.revision) - - if command is "fetch": - cmd = "%s clone %s %s://%s/%s %s" % (basecmd, " ".join(options), proto, hgroot, ud.module, ud.module) - elif command is "pull": - cmd = "%s pull %s" % (basecmd, " ".join(options)) - elif command is "update": - cmd = "%s update -C %s" % (basecmd, " ".join(options)) - else: - raise FetchError("Invalid hg command %s" % command) - - return cmd - - def go(self, loc, ud, d): - """Fetch url""" - - # try to use the tarball stash - if Fetch.try_mirror(d, ud.localfile): - bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping hg checkout." % ud.localpath) - return - - bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: checking for module directory '" + ud.moddir + "'") - - if os.access(os.path.join(ud.moddir, '.hg'), os.R_OK): - updatecmd = self._buildhgcommand(ud, d, "pull") - bb.msg.note(1, bb.msg.domain.Fetcher, "Update " + loc) - # update sources there - os.chdir(ud.moddir) - bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % updatecmd) - runfetchcmd(updatecmd, d) - - updatecmd = self._buildhgcommand(ud, d, "update") - bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % updatecmd) - runfetchcmd(updatecmd, d) - else: - fetchcmd = self._buildhgcommand(ud, d, "fetch") - bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc) - # check out sources there - bb.mkdirhier(ud.pkgdir) - os.chdir(ud.pkgdir) - bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % fetchcmd) - runfetchcmd(fetchcmd, d) - - os.chdir(ud.pkgdir) - try: - runfetchcmd("tar -czf %s %s" % (ud.localpath, ud.module), d) - except: - t, v, tb = sys.exc_info() - try: - os.unlink(ud.localpath) - except OSError: - pass - raise t, v, tb diff --git a/bitbake/lib/bb/fetch/local.py b/bitbake/lib/bb/fetch/local.py deleted file mode 100644 index 5e480a208e..0000000000 --- a/bitbake/lib/bb/fetch/local.py +++ /dev/null @@ -1,61 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'Fetch' implementations - -Classes for obtaining upstream sources for the -BitBake build tools. - -""" - -# Copyright (C) 2003, 2004 Chris Larson -# -# 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. -# -# 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. -# -# Based on functions from the base bb module, Copyright 2003 Holger Schurig - -import os, re -import bb -from bb import data -from bb.fetch import Fetch - -class Local(Fetch): - def supports(self, url, urldata, d): - """ - Check to see if a given url can be fetched with cvs. - """ - return urldata.type in ['file','patch'] - - def localpath(self, url, urldata, d): - """ - Return the local filename of a given url assuming a successful fetch. - """ - path = url.split("://")[1] - path = path.split(";")[0] - newpath = path - if path[0] != "/": - filespath = data.getVar('FILESPATH', d, 1) - if filespath: - newpath = bb.which(filespath, path) - if not newpath: - filesdir = data.getVar('FILESDIR', d, 1) - if filesdir: - newpath = os.path.join(filesdir, path) - # We don't set localfile as for this fetcher the file is already local! - return newpath - - def go(self, url, urldata, d): - """Fetch urls (no-op for Local method)""" - # no need to fetch local files, we'll deal with them in place. - return 1 diff --git a/bitbake/lib/bb/fetch/perforce.py b/bitbake/lib/bb/fetch/perforce.py deleted file mode 100644 index 97b618228b..0000000000 --- a/bitbake/lib/bb/fetch/perforce.py +++ /dev/null @@ -1,213 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'Fetch' implementations - -Classes for obtaining upstream sources for the -BitBake build tools. - -""" - -# Copyright (C) 2003, 2004 Chris Larson -# -# 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. -# -# 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. -# -# Based on functions from the base bb module, Copyright 2003 Holger Schurig - -import os, re -import bb -from bb import data -from bb.fetch import Fetch -from bb.fetch import FetchError -from bb.fetch import MissingParameterError - -class Perforce(Fetch): - def supports(self, url, ud, d): - return ud.type in ['p4'] - - def doparse(url,d): - parm=[] - path = url.split("://")[1] - delim = path.find("@"); - if delim != -1: - (user,pswd,host,port) = path.split('@')[0].split(":") - path = path.split('@')[1] - else: - (host,port) = data.getVar('P4PORT', d).split(':') - user = "" - pswd = "" - - if path.find(";") != -1: - keys=[] - values=[] - plist = path.split(';') - for item in plist: - if item.count('='): - (key,value) = item.split('=') - keys.append(key) - values.append(value) - - parm = dict(zip(keys,values)) - path = "//" + path.split(';')[0] - host += ":%s" % (port) - parm["cset"] = Perforce.getcset(d, path, host, user, pswd, parm) - - return host,path,user,pswd,parm - doparse = staticmethod(doparse) - - def getcset(d, depot,host,user,pswd,parm): - if "cset" in parm: - return parm["cset"]; - if user: - data.setVar('P4USER', user, d) - if pswd: - data.setVar('P4PASSWD', pswd, d) - if host: - data.setVar('P4PORT', host, d) - - p4date = data.getVar("P4DATE", d, 1) - if "revision" in parm: - depot += "#%s" % (parm["revision"]) - elif "label" in parm: - depot += "@%s" % (parm["label"]) - elif p4date: - depot += "@%s" % (p4date) - - p4cmd = data.getVar('FETCHCOMMAND_p4', d, 1) - bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s changes -m 1 %s" % (p4cmd, depot)) - p4file = os.popen("%s changes -m 1 %s" % (p4cmd,depot)) - cset = p4file.readline().strip() - bb.msg.debug(1, bb.msg.domain.Fetcher, "READ %s" % (cset)) - if not cset: - return -1 - - return cset.split(' ')[1] - getcset = staticmethod(getcset) - - def localpath(self, url, ud, d): - - (host,path,user,pswd,parm) = Perforce.doparse(url,d) - - # If a label is specified, we use that as our filename - - if "label" in parm: - ud.localfile = "%s.tar.gz" % (parm["label"]) - return os.path.join(data.getVar("DL_DIR", d, 1), ud.localfile) - - base = path - which = path.find('/...') - if which != -1: - base = path[:which] - - if base[0] == "/": - base = base[1:] - - cset = Perforce.getcset(d, path, host, user, pswd, parm) - - ud.localfile = data.expand('%s+%s+%s.tar.gz' % (host,base.replace('/', '.'), cset), d) - - return os.path.join(data.getVar("DL_DIR", d, 1), ud.localfile) - - def go(self, loc, ud, d): - """ - Fetch urls - """ - - # try to use the tarball stash - if Fetch.try_mirror(d, ud.localfile): - bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping perforce checkout." % ud.localpath) - return - - (host,depot,user,pswd,parm) = Perforce.doparse(loc, d) - - if depot.find('/...') != -1: - path = depot[:depot.find('/...')] - else: - path = depot - - if "module" in parm: - module = parm["module"] - else: - module = os.path.basename(path) - - localdata = data.createCopy(d) - data.setVar('OVERRIDES', "p4:%s" % data.getVar('OVERRIDES', localdata), localdata) - data.update_data(localdata) - - # Get the p4 command - if user: - data.setVar('P4USER', user, localdata) - - if pswd: - data.setVar('P4PASSWD', pswd, localdata) - - if host: - data.setVar('P4PORT', host, localdata) - - p4cmd = data.getVar('FETCHCOMMAND', localdata, 1) - - # create temp directory - bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: creating temporary directory") - bb.mkdirhier(data.expand('${WORKDIR}', localdata)) - data.setVar('TMPBASE', data.expand('${WORKDIR}/oep4.XXXXXX', localdata), localdata) - tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false") - tmpfile = tmppipe.readline().strip() - if not tmpfile: - bb.error("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.") - raise FetchError(module) - - if "label" in parm: - depot = "%s@%s" % (depot,parm["label"]) - else: - cset = Perforce.getcset(d, depot, host, user, pswd, parm) - depot = "%s@%s" % (depot,cset) - - os.chdir(tmpfile) - bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc) - bb.msg.note(1, bb.msg.domain.Fetcher, "%s files %s" % (p4cmd, depot)) - p4file = os.popen("%s files %s" % (p4cmd, depot)) - - if not p4file: - bb.error("Fetch: unable to get the P4 files from %s" % (depot)) - raise FetchError(module) - - count = 0 - - for file in p4file: - list = file.split() - - if list[2] == "delete": - continue - - dest = list[0][len(path)+1:] - where = dest.find("#") - - os.system("%s print -o %s/%s %s" % (p4cmd, module,dest[:where],list[0])) - count = count + 1 - - if count == 0: - bb.error("Fetch: No files gathered from the P4 fetch") - raise FetchError(module) - - myret = os.system("tar -czf %s %s" % (ud.localpath, module)) - if myret != 0: - try: - os.unlink(ud.localpath) - except OSError: - pass - raise FetchError(module) - # cleanup - os.system('rm -rf %s' % tmpfile) - - diff --git a/bitbake/lib/bb/fetch/ssh.py b/bitbake/lib/bb/fetch/ssh.py deleted file mode 100644 index 81a9892dcc..0000000000 --- a/bitbake/lib/bb/fetch/ssh.py +++ /dev/null @@ -1,120 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -''' -BitBake 'Fetch' implementations - -This implementation is for Secure Shell (SSH), and attempts to comply with the -IETF secsh internet draft: - http://tools.ietf.org/wg/secsh/draft-ietf-secsh-scp-sftp-ssh-uri/ - - Currently does not support the sftp parameters, as this uses scp - Also does not support the 'fingerprint' connection parameter. - -''' - -# Copyright (C) 2006 OpenedHand Ltd. -# -# -# Based in part on svk.py: -# Copyright (C) 2006 Holger Hans Peter Freyther -# Based on svn.py: -# Copyright (C) 2003, 2004 Chris Larson -# Based on functions from the base bb module: -# Copyright 2003 Holger Schurig -# -# -# 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. -# -# 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 re, os -import bb -from bb import data -from bb.fetch import Fetch -from bb.fetch import FetchError -from bb.fetch import MissingParameterError - - -__pattern__ = re.compile(r''' - \s* # Skip leading whitespace - ssh:// # scheme - ( # Optional username/password block - (?P<user>\S+) # username - (:(?P<pass>\S+))? # colon followed by the password (optional) - )? - (?P<cparam>(;[^;]+)*)? # connection parameters block (optional) - @ - (?P<host>\S+?) # non-greedy match of the host - (:(?P<port>[0-9]+))? # colon followed by the port (optional) - / - (?P<path>[^;]+) # path on the remote system, may be absolute or relative, - # and may include the use of '~' to reference the remote home - # directory - (?P<sparam>(;[^;]+)*)? # parameters block (optional) - $ -''', re.VERBOSE) - -class SSH(Fetch): - '''Class to fetch a module or modules via Secure Shell''' - - def supports(self, url, urldata, d): - return __pattern__.match(url) != None - - def localpath(self, url, urldata, d): - m = __pattern__.match(url) - path = m.group('path') - host = m.group('host') - lpath = os.path.join(data.getVar('DL_DIR', d, True), host, os.path.basename(path)) - return lpath - - def go(self, url, urldata, d): - dldir = data.getVar('DL_DIR', d, 1) - - m = __pattern__.match(url) - path = m.group('path') - host = m.group('host') - port = m.group('port') - user = m.group('user') - password = m.group('pass') - - ldir = os.path.join(dldir, host) - lpath = os.path.join(ldir, os.path.basename(path)) - - if not os.path.exists(ldir): - os.makedirs(ldir) - - if port: - port = '-P %s' % port - else: - port = '' - - if user: - fr = user - if password: - fr += ':%s' % password - fr += '@%s' % host - else: - fr = host - fr += ':%s' % path - - - import commands - cmd = 'scp -B -r %s %s %s/' % ( - port, - commands.mkarg(fr), - commands.mkarg(ldir) - ) - - (exitstatus, output) = commands.getstatusoutput(cmd) - if exitstatus != 0: - print output - raise FetchError('Unable to fetch %s' % url) diff --git a/bitbake/lib/bb/fetch/svk.py b/bitbake/lib/bb/fetch/svk.py deleted file mode 100644 index d863ccb6e0..0000000000 --- a/bitbake/lib/bb/fetch/svk.py +++ /dev/null @@ -1,109 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'Fetch' implementations - -This implementation is for svk. It is based on the svn implementation - -""" - -# Copyright (C) 2006 Holger Hans Peter Freyther -# Copyright (C) 2003, 2004 Chris Larson -# -# 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. -# -# 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. -# -# Based on functions from the base bb module, Copyright 2003 Holger Schurig - -import os, re -import bb -from bb import data -from bb.fetch import Fetch -from bb.fetch import FetchError -from bb.fetch import MissingParameterError - -class Svk(Fetch): - """Class to fetch a module or modules from svk repositories""" - def supports(self, url, ud, d): - """ - Check to see if a given url can be fetched with cvs. - """ - return ud.type in ['svk'] - - def localpath(self, url, ud, d): - if not "module" in ud.parm: - raise MissingParameterError("svk method needs a 'module' parameter") - else: - ud.module = ud.parm["module"] - - ud.revision = "" - if 'rev' in ud.parm: - ud.revision = ud.parm['rev'] - - ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d) - - return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) - - def forcefetch(self, url, ud, d): - if (ud.date == "now"): - return True - return False - - def go(self, loc, ud, d): - """Fetch urls""" - - if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile): - return - - svkroot = ud.host + ud.path - - svkcmd = "svk co -r {%s} %s/%s" % (date, svkroot, ud.module) - - if ud.revision: - svkcmd = "svk co -r %s/%s" % (ud.revision, svkroot, ud.module) - - # create temp directory - localdata = data.createCopy(d) - data.update_data(localdata) - bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: creating temporary directory") - bb.mkdirhier(data.expand('${WORKDIR}', localdata)) - data.setVar('TMPBASE', data.expand('${WORKDIR}/oesvk.XXXXXX', localdata), localdata) - tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false") - tmpfile = tmppipe.readline().strip() - if not tmpfile: - bb.msg.error(bb.msg.domain.Fetcher, "Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.") - raise FetchError(ud.module) - - # check out sources there - os.chdir(tmpfile) - bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc) - bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svkcmd) - myret = os.system(svkcmd) - if myret != 0: - try: - os.rmdir(tmpfile) - except OSError: - pass - raise FetchError(ud.module) - - os.chdir(os.path.join(tmpfile, os.path.dirname(ud.module))) - # tar them up to a defined filename - myret = os.system("tar -czf %s %s" % (ud.localpath, os.path.basename(ud.module))) - if myret != 0: - try: - os.unlink(ud.localpath) - except OSError: - pass - raise FetchError(ud.module) - # cleanup - os.system('rm -rf %s' % tmpfile) diff --git a/bitbake/lib/bb/fetch/svn.py b/bitbake/lib/bb/fetch/svn.py deleted file mode 100644 index 95b21fe20c..0000000000 --- a/bitbake/lib/bb/fetch/svn.py +++ /dev/null @@ -1,206 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'Fetch' implementation for svn. - -""" - -# Copyright (C) 2003, 2004 Chris Larson -# Copyright (C) 2004 Marcin Juszkiewicz -# -# 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. -# -# 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. -# -# Based on functions from the base bb module, Copyright 2003 Holger Schurig - -import os, re -import sys -import bb -from bb import data -from bb.fetch import Fetch -from bb.fetch import FetchError -from bb.fetch import MissingParameterError -from bb.fetch import runfetchcmd - -class Svn(Fetch): - """Class to fetch a module or modules from svn repositories""" - def supports(self, url, ud, d): - """ - Check to see if a given url can be fetched with svn. - """ - return ud.type in ['svn'] - - def localpath(self, url, ud, d): - if not "module" in ud.parm: - raise MissingParameterError("svn method needs a 'module' parameter") - - ud.module = ud.parm["module"] - - # Create paths to svn checkouts - relpath = ud.path - if relpath.startswith('/'): - # Remove leading slash as os.path.join can't cope - relpath = relpath[1:] - ud.pkgdir = os.path.join(data.expand('${SVNDIR}', d), ud.host, relpath) - ud.moddir = os.path.join(ud.pkgdir, ud.module) - - if 'rev' in ud.parm: - ud.date = "" - ud.revision = ud.parm['rev'] - elif 'date' in ud.date: - ud.date = ud.parm['date'] - ud.revision = "" - else: - # - # ***Nasty hacks*** - # If DATE in unexpanded PV, use ud.date (which is set from SRCDATE) - # Will warn people to switch to SRCREV here - # - # How can we tell when a user has overriden SRCDATE? - # check for "get_srcdate" in unexpanded SRCREV - ugly - # - pv = data.getVar("PV", d, 0) - if "DATE" in pv: - ud.revision = "" - else: - rev = data.getVar("SRCREV", d, 0) - if rev and "get_srcrev" in rev: - ud.revision = self.latest_revision(url, ud, d) - ud.date = "" - elif rev: - ud.revision = rev - ud.date = "" - else: - ud.revision = "" - - ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d) - - return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) - - def _buildsvncommand(self, ud, d, command): - """ - Build up an svn commandline based on ud - command is "fetch", "update", "info" - """ - - basecmd = data.expand('${FETCHCMD_svn}', d) - - proto = "svn" - if "proto" in ud.parm: - proto = ud.parm["proto"] - - svn_rsh = None - if proto == "svn+ssh" and "rsh" in ud.parm: - svn_rsh = ud.parm["rsh"] - - svnroot = ud.host + ud.path - - # either use the revision, or SRCDATE in braces, - options = [] - - if ud.user: - options.append("--username %s" % ud.user) - - if ud.pswd: - options.append("--password %s" % ud.pswd) - - if command is "info": - svncmd = "%s info %s %s://%s/%s/" % (basecmd, " ".join(options), proto, svnroot, ud.module) - else: - if ud.revision: - options.append("-r %s" % ud.revision) - elif ud.date: - options.append("-r {%s}" % ud.date) - - if command is "fetch": - svncmd = "%s co %s %s://%s/%s %s" % (basecmd, " ".join(options), proto, svnroot, ud.module, ud.module) - elif command is "update": - svncmd = "%s update %s" % (basecmd, " ".join(options)) - else: - raise FetchError("Invalid svn command %s" % command) - - if svn_rsh: - svncmd = "svn_RSH=\"%s\" %s" % (svn_rsh, svncmd) - - return svncmd - - def go(self, loc, ud, d): - """Fetch url""" - - # try to use the tarball stash - if Fetch.try_mirror(d, ud.localfile): - bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping svn checkout." % ud.localpath) - return - - bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: checking for module directory '" + ud.moddir + "'") - - if os.access(os.path.join(ud.moddir, '.svn'), os.R_OK): - svnupdatecmd = self._buildsvncommand(ud, d, "update") - bb.msg.note(1, bb.msg.domain.Fetcher, "Update " + loc) - # update sources there - os.chdir(ud.moddir) - bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svnupdatecmd) - runfetchcmd(svnupdatecmd, d) - else: - svnfetchcmd = self._buildsvncommand(ud, d, "fetch") - bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc) - # check out sources there - bb.mkdirhier(ud.pkgdir) - os.chdir(ud.pkgdir) - bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svnfetchcmd) - runfetchcmd(svnfetchcmd, d) - - os.chdir(ud.pkgdir) - # tar them up to a defined filename - try: - runfetchcmd("tar -czf %s %s" % (ud.localpath, ud.module), d) - except: - t, v, tb = sys.exc_info() - try: - os.unlink(ud.localpath) - except OSError: - pass - raise t, v, tb - - def suppports_srcrev(self): - return True - - def _revision_key(self, url, ud, d): - """ - Return a unique key for the url - """ - return "svn:" + ud.moddir - - def _latest_revision(self, url, ud, d): - """ - Return the latest upstream revision number - """ - bb.msg.debug(2, bb.msg.domain.Fetcher, "SVN fetcher hitting network for %s" % url) - - output = runfetchcmd("LANG=C LC_ALL=C " + self._buildsvncommand(ud, d, "info"), d, True) - - revision = None - for line in output.splitlines(): - if "Last Changed Rev" in line: - revision = line.split(":")[1].strip() - - return revision - - def _sortable_revision(self, url, ud, d): - """ - Return a sortable revision number which in our case is the revision number - (use the cached version to avoid network access) - """ - - return self.latest_revision(url, ud, d) - diff --git a/bitbake/lib/bb/fetch/wget.py b/bitbake/lib/bb/fetch/wget.py deleted file mode 100644 index 2d590ad0b2..0000000000 --- a/bitbake/lib/bb/fetch/wget.py +++ /dev/null @@ -1,99 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'Fetch' implementations - -Classes for obtaining upstream sources for the -BitBake build tools. - -""" - -# Copyright (C) 2003, 2004 Chris Larson -# -# 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. -# -# 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. -# -# Based on functions from the base bb module, Copyright 2003 Holger Schurig - -import os, re -import bb -from bb import data -from bb.fetch import Fetch -from bb.fetch import FetchError -from bb.fetch import uri_replace - -class Wget(Fetch): - """Class to fetch urls via 'wget'""" - def supports(self, url, ud, d): - """ - Check to see if a given url can be fetched with cvs. - """ - return ud.type in ['http','https','ftp'] - - def localpath(self, url, ud, d): - - url = bb.encodeurl([ud.type, ud.host, ud.path, ud.user, ud.pswd, {}]) - ud.basename = os.path.basename(ud.path) - ud.localfile = data.expand(os.path.basename(url), d) - - return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) - - def go(self, uri, ud, d): - """Fetch urls""" - - def fetch_uri(uri, ud, d): - if os.path.exists(ud.localpath): - # file exists, but we didnt complete it.. trying again.. - fetchcmd = data.getVar("RESUMECOMMAND", d, 1) - else: - fetchcmd = data.getVar("FETCHCOMMAND", d, 1) - - bb.msg.note(1, bb.msg.domain.Fetcher, "fetch " + uri) - fetchcmd = fetchcmd.replace("${URI}", uri) - fetchcmd = fetchcmd.replace("${FILE}", ud.basename) - bb.msg.debug(2, bb.msg.domain.Fetcher, "executing " + fetchcmd) - ret = os.system(fetchcmd) - if ret != 0: - return False - - # check if sourceforge did send us to the mirror page - if not os.path.exists(ud.localpath): - os.system("rm %s*" % ud.localpath) # FIXME shell quote it - bb.msg.debug(2, bb.msg.domain.Fetcher, "sourceforge.net send us to the mirror on %s" % ud.basename) - return False - - return True - - localdata = data.createCopy(d) - data.setVar('OVERRIDES', "wget:" + data.getVar('OVERRIDES', localdata), localdata) - data.update_data(localdata) - - premirrors = [ i.split() for i in (data.getVar('PREMIRRORS', localdata, 1) or "").split('\n') if i ] - for (find, replace) in premirrors: - newuri = uri_replace(uri, find, replace, d) - if newuri != uri: - if fetch_uri(newuri, ud, localdata): - return - - if fetch_uri(uri, ud, localdata): - return - - # try mirrors - mirrors = [ i.split() for i in (data.getVar('MIRRORS', localdata, 1) or "").split('\n') if i ] - for (find, replace) in mirrors: - newuri = uri_replace(uri, find, replace, d) - if newuri != uri: - if fetch_uri(newuri, ud, localdata): - return - - raise FetchError(uri) diff --git a/bitbake/lib/bb/manifest.py b/bitbake/lib/bb/manifest.py deleted file mode 100644 index 4e4b7d98ec..0000000000 --- a/bitbake/lib/bb/manifest.py +++ /dev/null @@ -1,144 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -# -# Copyright (C) 2003, 2004 Chris Larson -# -# 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. -# -# 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 os, sys -import bb, bb.data - -def getfields(line): - fields = {} - fieldmap = ( "pkg", "src", "dest", "type", "mode", "uid", "gid", "major", "minor", "start", "inc", "count" ) - for f in xrange(len(fieldmap)): - fields[fieldmap[f]] = None - - if not line: - return None - - splitline = line.split() - if not len(splitline): - return None - - try: - for f in xrange(len(fieldmap)): - if splitline[f] == '-': - continue - fields[fieldmap[f]] = splitline[f] - except IndexError: - pass - return fields - -def parse (mfile, d): - manifest = [] - while 1: - line = mfile.readline() - if not line: - break - if line.startswith("#"): - continue - fields = getfields(line) - if not fields: - continue - manifest.append(fields) - return manifest - -def emit (func, manifest, d): -#str = "%s () {\n" % func - str = "" - for line in manifest: - emittedline = emit_line(func, line, d) - if not emittedline: - continue - str += emittedline + "\n" -# str += "}\n" - return str - -def mangle (func, line, d): - import copy - newline = copy.copy(line) - src = bb.data.expand(newline["src"], d) - - if src: - if not os.path.isabs(src): - src = "${WORKDIR}/" + src - - dest = newline["dest"] - if not dest: - return - - if dest.startswith("/"): - dest = dest[1:] - - if func is "do_install": - dest = "${D}/" + dest - - elif func is "do_populate": - dest = "${WORKDIR}/install/" + newline["pkg"] + "/" + dest - - elif func is "do_stage": - varmap = {} - varmap["${bindir}"] = "${STAGING_DIR}/${HOST_SYS}/bin" - varmap["${libdir}"] = "${STAGING_DIR}/${HOST_SYS}/lib" - varmap["${includedir}"] = "${STAGING_DIR}/${HOST_SYS}/include" - varmap["${datadir}"] = "${STAGING_DATADIR}" - - matched = 0 - for key in varmap.keys(): - if dest.startswith(key): - dest = varmap[key] + "/" + dest[len(key):] - matched = 1 - if not matched: - newline = None - return - else: - newline = None - return - - newline["src"] = src - newline["dest"] = dest - return newline - -def emit_line (func, line, d): - import copy - newline = copy.deepcopy(line) - newline = mangle(func, newline, d) - if not newline: - return None - - str = "" - type = newline["type"] - mode = newline["mode"] - src = newline["src"] - dest = newline["dest"] - if type is "d": - str = "install -d " - if mode: - str += "-m %s " % mode - str += dest - elif type is "f": - if not src: - return None - if dest.endswith("/"): - str = "install -d " - str += dest + "\n" - str += "install " - else: - str = "install -D " - if mode: - str += "-m %s " % mode - str += src + " " + dest - del newline - return str diff --git a/bitbake/lib/bb/methodpool.py b/bitbake/lib/bb/methodpool.py deleted file mode 100644 index f43c4a0580..0000000000 --- a/bitbake/lib/bb/methodpool.py +++ /dev/null @@ -1,84 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -# -# -# Copyright (C) 2006 Holger Hans Peter Freyther -# -# 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. -# -# 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. - - -""" - What is a method pool? - - BitBake has a global method scope where .bb, .inc and .bbclass - files can install methods. These methods are parsed from strings. - To avoid recompiling and executing these string we introduce - a method pool to do this task. - - This pool will be used to compile and execute the functions. It - will be smart enough to -""" - -from bb.utils import better_compile, better_exec -from bb import error - -# A dict of modules we have handled -# it is the number of .bbclasses + x in size -_parsed_methods = { } -_parsed_fns = { } - -def insert_method(modulename, code, fn): - """ - Add code of a module should be added. The methods - will be simply added, no checking will be done - """ - comp = better_compile(code, "<bb>", fn ) - better_exec(comp, __builtins__, code, fn) - - # now some instrumentation - code = comp.co_names - for name in code: - if name in ['None', 'False']: - continue - elif name in _parsed_fns and not _parsed_fns[name] == modulename: - error( "Error Method already seen: %s in' %s' now in '%s'" % (name, _parsed_fns[name], modulename)) - else: - _parsed_fns[name] = modulename - -def check_insert_method(modulename, code, fn): - """ - Add the code if it wasnt added before. The module - name will be used for that - - Variables: - @modulename a short name e.g. base.bbclass - @code The actual python code - @fn The filename from the outer file - """ - if not modulename in _parsed_methods: - return insert_method(modulename, code, fn) - _parsed_methods[modulename] = 1 - -def parsed_module(modulename): - """ - Inform me file xyz was parsed - """ - return modulename in _parsed_methods - - -def get_parsed_dict(): - """ - shortcut - """ - return _parsed_methods diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py deleted file mode 100644 index a1b31e5d60..0000000000 --- a/bitbake/lib/bb/msg.py +++ /dev/null @@ -1,129 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'msg' implementation - -Message handling infrastructure for bitbake - -""" - -# Copyright (C) 2006 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. -# -# 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 sys, os, re, bb -from bb import utils, event - -debug_level = {} - -verbose = False - -domain = bb.utils.Enum( - 'Build', - 'Cache', - 'Collection', - 'Data', - 'Depends', - 'Fetcher', - 'Parsing', - 'PersistData', - 'Provider', - 'RunQueue', - 'TaskData', - 'Util') - - -class MsgBase(bb.event.Event): - """Base class for messages""" - - def __init__(self, msg, d ): - self._message = msg - event.Event.__init__(self, d) - -class MsgDebug(MsgBase): - """Debug Message""" - -class MsgNote(MsgBase): - """Note Message""" - -class MsgWarn(MsgBase): - """Warning Message""" - -class MsgError(MsgBase): - """Error Message""" - -class MsgFatal(MsgBase): - """Fatal Message""" - -class MsgPlain(MsgBase): - """General output""" - -# -# Message control functions -# - -def set_debug_level(level): - bb.msg.debug_level = {} - for domain in bb.msg.domain: - bb.msg.debug_level[domain] = level - bb.msg.debug_level['default'] = level - -def set_verbose(level): - bb.msg.verbose = level - -def set_debug_domains(domains): - for domain in domains: - found = False - for ddomain in bb.msg.domain: - if domain == str(ddomain): - bb.msg.debug_level[ddomain] = bb.msg.debug_level[ddomain] + 1 - found = True - if not found: - bb.msg.warn(None, "Logging domain %s is not valid, ignoring" % domain) - -# -# Message handling functions -# - -def debug(level, domain, msg, fn = None): - bb.event.fire(MsgDebug(msg, None)) - if not domain: - domain = 'default' - if debug_level[domain] >= level: - print 'DEBUG: ' + msg - -def note(level, domain, msg, fn = None): - bb.event.fire(MsgNote(msg, None)) - if not domain: - domain = 'default' - if level == 1 or verbose or debug_level[domain] >= 1: - print 'NOTE: ' + msg - -def warn(domain, msg, fn = None): - bb.event.fire(MsgWarn(msg, None)) - print 'WARNING: ' + msg - -def error(domain, msg, fn = None): - bb.event.fire(MsgError(msg, None)) - print 'ERROR: ' + msg - -def fatal(domain, msg, fn = None): - bb.event.fire(MsgFatal(msg, None)) - print 'ERROR: ' + msg - sys.exit(1) - -def plain(msg, fn = None): - bb.event.fire(MsgPlain(msg, None)) - print msg - diff --git a/bitbake/lib/bb/parse/__init__.py b/bitbake/lib/bb/parse/__init__.py deleted file mode 100644 index 3c9ba8e6da..0000000000 --- a/bitbake/lib/bb/parse/__init__.py +++ /dev/null @@ -1,80 +0,0 @@ -""" -BitBake Parsers - -File parsers for the BitBake build tools. - -""" - - -# Copyright (C) 2003, 2004 Chris Larson -# Copyright (C) 2003, 2004 Phil Blundell -# -# 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. -# -# 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. -# -# Based on functions from the base bb module, Copyright 2003 Holger Schurig - -__all__ = [ 'ParseError', 'SkipPackage', 'cached_mtime', 'mark_dependency', - 'supports', 'handle', 'init' ] -handlers = [] - -import bb, os - -class ParseError(Exception): - """Exception raised when parsing fails""" - -class SkipPackage(Exception): - """Exception raised to skip this package""" - -__mtime_cache = {} -def cached_mtime(f): - if not __mtime_cache.has_key(f): - __mtime_cache[f] = os.stat(f)[8] - return __mtime_cache[f] - -def cached_mtime_noerror(f): - if not __mtime_cache.has_key(f): - try: - __mtime_cache[f] = os.stat(f)[8] - except OSError: - return 0 - return __mtime_cache[f] - -def mark_dependency(d, f): - if f.startswith('./'): - f = "%s/%s" % (os.getcwd(), f[2:]) - deps = bb.data.getVar('__depends', d) or [] - deps.append( (f, cached_mtime(f)) ) - bb.data.setVar('__depends', deps, d) - -def supports(fn, data): - """Returns true if we have a handler for this file, false otherwise""" - for h in handlers: - if h['supports'](fn, data): - return 1 - return 0 - -def handle(fn, data, include = 0): - """Call the handler that is appropriate for this file""" - for h in handlers: - if h['supports'](fn, data): - return h['handle'](fn, data, include) - raise ParseError("%s is not a BitBake file" % fn) - -def init(fn, data): - for h in handlers: - if h['supports'](fn): - return h['init'](data) - - -from parse_py import __version__, ConfHandler, BBHandler diff --git a/bitbake/lib/bb/parse/parse_c/BBHandler.py b/bitbake/lib/bb/parse/parse_c/BBHandler.py deleted file mode 100644 index b430e1f4e5..0000000000 --- a/bitbake/lib/bb/parse/parse_c/BBHandler.py +++ /dev/null @@ -1,188 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -"""class for handling .bb files (using a C++ parser) - - Reads a .bb file and obtains its metadata (using a C++ parser) - - Copyright (C) 2006 Tim Robert Ansell - Copyright (C) 2006 Holger Hans Peter Freyther - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT - SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR - THE USE OR OTHER DEALINGS IN THE SOFTWARE. -""" - -import os, sys - -# The Module we will use here -import bb - -from bitbakec import parsefile - -# -# This is the Python Part of the Native Parser Implementation. -# We will only parse .bbclass, .inc and .bb files but no -# configuration files. -# supports, init and handle are the public methods used by -# parser module -# -# The rest of the methods are internal implementation details. - -def _init(fn, d): - """ - Initialize the data implementation with values of - the environment and data from the file. - """ - pass - -# -# public -# -def supports(fn, data): - return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" or fn[-5:] == ".conf" - -def init(fn, data): - if not bb.data.getVar('TOPDIR', data): - bb.data.setVar('TOPDIR', os.getcwd(), data) - if not bb.data.getVar('BBPATH', data): - bb.data.setVar('BBPATH', os.path.join(sys.prefix, 'share', 'bitbake'), data) - -def handle_inherit(d): - """ - Handle inheriting of classes. This will load all default classes. - It could be faster, it could detect infinite loops but this is todo - Also this delayed loading of bb.parse could impose a penalty - """ - from bb.parse import handle - - files = (data.getVar('INHERIT', d, True) or "").split() - if not "base" in i: - files[0:0] = ["base"] - - __inherit_cache = data.getVar('__inherit_cache', d) or [] - for f in files: - file = data.expand(f, d) - if file[0] != "/" and file[-8:] != ".bbclass": - file = os.path.join('classes', '%s.bbclass' % file) - - if not file in __inherit_cache: - debug(2, "BB %s:%d: inheriting %s" % (fn, lineno, file)) - __inherit_cache.append( file ) - - try: - handle(file, d, True) - except IOError: - print "Failed to inherit %s" % file - data.setVar('__inherit_cache', __inherit_cache, d) - - -def handle(fn, d, include): - from bb import data, parse - - (root, ext) = os.path.splitext(os.path.basename(fn)) - base_name = "%s%s" % (root,ext) - - # initialize with some data - init(fn,d) - - # check if we include or are the beginning - oldfile = None - if include: - oldfile = d.getVar('FILE', False) - is_conf = False - elif ext == ".conf": - is_conf = True - data.inheritFromOS(d) - - # find the file - if not os.path.isabs(fn): - abs_fn = bb.which(d.getVar('BBPATH', True), fn) - else: - abs_fn = fn - - # check if the file exists - if not os.path.exists(abs_fn): - raise IOError("file '%(fn)s' not found" % locals() ) - - # now we know the file is around mark it as dep - if include: - parse.mark_dependency(d, abs_fn) - - # manipulate the bbpath - if ext != ".bbclass" and ext != ".conf": - old_bb_path = data.getVar('BBPATH', d) - data.setVar('BBPATH', os.path.dirname(abs_fn) + (":%s" %old_bb_path) , d) - - # handle INHERITS and base inherit - if ext != ".bbclass" and ext != ".conf": - data.setVar('FILE', fn, d) - handle_interit(d) - - # now parse this file - by defering it to C++ - parsefile(abs_fn, d, is_conf) - - # Finish it up - if include == 0: - data.expandKeys(d) - data.update_data(d) - #### !!! XXX Finish it up by executing the anonfunc - - - # restore the original FILE - if oldfile: - d.setVar('FILE', oldfile) - - # restore bbpath - if ext != ".bbclass" and ext != ".conf": - data.setVar('BBPATH', old_bb_path, d ) - - - return d - - -# Needed for BitBake files... -__pkgsplit_cache__={} -def vars_from_file(mypkg, d): - if not mypkg: - return (None, None, None) - if mypkg in __pkgsplit_cache__: - return __pkgsplit_cache__[mypkg] - - myfile = os.path.splitext(os.path.basename(mypkg)) - parts = myfile[0].split('_') - __pkgsplit_cache__[mypkg] = parts - exp = 3 - len(parts) - tmplist = [] - while exp != 0: - exp -= 1 - tmplist.append(None) - parts.extend(tmplist) - return parts - - - - -# Inform bitbake that we are a parser -# We need to define all three -from bb.parse import handlers -handlers.append( {'supports' : supports, 'handle': handle, 'init' : init}) -del handlers diff --git a/bitbake/lib/bb/parse/parse_c/Makefile b/bitbake/lib/bb/parse/parse_c/Makefile deleted file mode 100644 index 77daccb72d..0000000000 --- a/bitbake/lib/bb/parse/parse_c/Makefile +++ /dev/null @@ -1,36 +0,0 @@ - -buil: bitbakec.so - echo "Done" - -bitbakescanner.cc: bitbakescanner.l - flex -t bitbakescanner.l > bitbakescanner.cc - -bitbakeparser.cc: bitbakeparser.y python_output.h - lemon bitbakeparser.y - mv bitbakeparser.c bitbakeparser.cc - -bitbakec.c: bitbakec.pyx - pyrexc bitbakec.pyx - -bitbakec-processed.c: bitbakec.c - cat bitbakec.c | sed -e"s/__pyx_f_8bitbakec_//" > bitbakec-processed.c - -bitbakec.o: bitbakec-processed.c - gcc -c bitbakec-processed.c -o bitbakec.o -fPIC -I/usr/include/python2.4 - -bitbakeparser.o: bitbakeparser.cc - g++ -c bitbakeparser.cc -fPIC -I/usr/include/python2.4 - -bitbakescanner.o: bitbakescanner.cc - g++ -c bitbakescanner.cc -fPIC -I/usr/include/python2.4 - -bitbakec.so: bitbakec.o bitbakeparser.o bitbakescanner.o - g++ -shared -fPIC bitbakeparser.o bitbakescanner.o bitbakec.o -o bitbakec.so - -clean: - rm -f *.out - rm -f *.cc - rm -f bitbakec.c - rm -f bitbakec-processed.c - rm -f *.o - rm -f *.so diff --git a/bitbake/lib/bb/parse/parse_c/README.build b/bitbake/lib/bb/parse/parse_c/README.build deleted file mode 100644 index eb6ad8c862..0000000000 --- a/bitbake/lib/bb/parse/parse_c/README.build +++ /dev/null @@ -1,12 +0,0 @@ -To ease portability (lemon, flex, etc) we keep the -result of flex and lemon in the source code. We agree -to not manually change the scanner and parser. - - - -How we create the files: - flex -t bitbakescanner.l > bitbakescanner.cc - lemon bitbakeparser.y - mv bitbakeparser.c bitbakeparser.cc - -Now manually create two files diff --git a/bitbake/lib/bb/parse/parse_c/__init__.py b/bitbake/lib/bb/parse/parse_c/__init__.py deleted file mode 100644 index bbb318e51f..0000000000 --- a/bitbake/lib/bb/parse/parse_c/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -# -# Copyright (C) 2006 Holger Hans Peter Freyther -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -# THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__version__ = '0.1' -__all__ = [ 'BBHandler' ] - -import BBHandler diff --git a/bitbake/lib/bb/parse/parse_c/bitbakec.pyx b/bitbake/lib/bb/parse/parse_c/bitbakec.pyx deleted file mode 100644 index c666e9b6b1..0000000000 --- a/bitbake/lib/bb/parse/parse_c/bitbakec.pyx +++ /dev/null @@ -1,253 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- - -cdef extern from "stdio.h": - ctypedef int FILE - FILE *fopen(char*, char*) - int fclose(FILE *fp) - -cdef extern from "string.h": - int strlen(char*) - -cdef extern from "lexerc.h": - ctypedef struct lex_t: - void* parser - void* scanner - char* name - FILE* file - int config - void* data - - int lineError - int errorParse - - cdef extern int parse(FILE*, char*, object, int) - -def parsefile(object file, object data, object config): - #print "parsefile: 1", file, data - - # Open the file - cdef FILE* f - - f = fopen(file, "r") - #print "parsefile: 2 opening file" - if (f == NULL): - raise IOError("No such file %s." % file) - - #print "parsefile: 3 parse" - parse(f, file, data, config) - - # Close the file - fclose(f) - - -cdef public void e_assign(lex_t* container, char* key, char* what): - #print "e_assign", key, what - if what == NULL: - print "FUTURE Warning empty string: use \"\"" - what = "" - - d = <object>container.data - d.setVar(key, what) - -cdef public void e_export(lex_t* c, char* what): - #print "e_export", what - #exp: - # bb.data.setVarFlag(key, "export", 1, data) - d = <object>c.data - d.setVarFlag(what, "export", 1) - -cdef public void e_immediate(lex_t* c, char* key, char* what): - #print "e_immediate", key, what - #colon: - # val = bb.data.expand(groupd["value"], data) - d = <object>c.data - d.setVar(key, d.expand(what,d)) - -cdef public void e_cond(lex_t* c, char* key, char* what): - #print "e_cond", key, what - #ques: - # val = bb.data.getVar(key, data) - # if val == None: - # val = groupd["value"] - if what == NULL: - print "FUTURE warning: Use \"\" for", key - what = "" - - d = <object>c.data - d.setVar(key, (d.getVar(key,False) or what)) - -cdef public void e_prepend(lex_t* c, char* key, char* what): - #print "e_prepend", key, what - #prepend: - # val = "%s %s" % (groupd["value"], (bb.data.getVar(key, data) or "")) - d = <object>c.data - d.setVar(key, what + " " + (d.getVar(key,0) or "")) - -cdef public void e_append(lex_t* c, char* key, char* what): - #print "e_append", key, what - #append: - # val = "%s %s" % ((bb.data.getVar(key, data) or ""), groupd["value"]) - d = <object>c.data - d.setVar(key, (d.getVar(key,0) or "") + " " + what) - -cdef public void e_precat(lex_t* c, char* key, char* what): - #print "e_precat", key, what - #predot: - # val = "%s%s" % (groupd["value"], (bb.data.getVar(key, data) or "")) - d = <object>c.data - d.setVar(key, what + (d.getVar(key,0) or "")) - -cdef public void e_postcat(lex_t* c, char* key, char* what): - #print "e_postcat", key, what - #postdot: - # val = "%s%s" % ((bb.data.getVar(key, data) or ""), groupd["value"]) - d = <object>c.data - d.setVar(key, (d.getVar(key,0) or "") + what) - -cdef public int e_addtask(lex_t* c, char* name, char* before, char* after) except -1: - #print "e_addtask", name - # func = m.group("func") - # before = m.group("before") - # after = m.group("after") - # if func is None: - # return - # var = "do_" + func - # - # data.setVarFlag(var, "task", 1, d) - # - # if after is not None: - # # set up deps for function - # data.setVarFlag(var, "deps", after.split(), d) - # if before is not None: - # # set up things that depend on this func - # data.setVarFlag(var, "postdeps", before.split(), d) - # return - - if c.config == 1: - from bb.parse import ParseError - raise ParseError("No tasks allowed in config files") - return -1 - - d = <object>c.data - do = "do_%s" % name - d.setVarFlag(do, "task", 1) - - if before != NULL and strlen(before) > 0: - #print "Before", before - d.setVarFlag(do, "postdeps", ("%s" % before).split()) - if after != NULL and strlen(after) > 0: - #print "After", after - d.setVarFlag(do, "deps", ("%s" % after).split()) - - return 0 - -cdef public int e_addhandler(lex_t* c, char* h) except -1: - #print "e_addhandler", h - # data.setVarFlag(h, "handler", 1, d) - if c.config == 1: - from bb.parse import ParseError - raise ParseError("No handlers allowed in config files") - return -1 - - d = <object>c.data - d.setVarFlag(h, "handler", 1) - return 0 - -cdef public int e_export_func(lex_t* c, char* function) except -1: - #print "e_export_func", function - if c.config == 1: - from bb.parse import ParseError - raise ParseError("No functions allowed in config files") - return -1 - - return 0 - -cdef public int e_inherit(lex_t* c, char* file) except -1: - #print "e_inherit", file - - if c.config == 1: - from bb.parse import ParseError - raise ParseError("No inherits allowed in config files") - return -1 - - return 0 - -cdef public void e_include(lex_t* c, char* file): - from bb.parse import handle - d = <object>c.data - - try: - handle(d.expand(file,d), d, True) - except IOError: - print "Could not include file", file - - -cdef public int e_require(lex_t* c, char* file) except -1: - #print "e_require", file - from bb.parse import handle - d = <object>c.data - - try: - handle(d.expand(file,d), d, True) - except IOError: - print "ParseError", file - from bb.parse import ParseError - raise ParseError("Could not include required file %s" % file) - return -1 - - return 0 - -cdef public int e_proc(lex_t* c, char* key, char* what) except -1: - #print "e_proc", key, what - if c.config == 1: - from bb.parse import ParseError - raise ParseError("No inherits allowed in config files") - return -1 - - return 0 - -cdef public int e_proc_python(lex_t* c, char* key, char* what) except -1: - #print "e_proc_python" - if c.config == 1: - from bb.parse import ParseError - raise ParseError("No pythin allowed in config files") - return -1 - - if key != NULL: - pass - #print "Key", key - if what != NULL: - pass - #print "What", what - - return 0 - -cdef public int e_proc_fakeroot(lex_t* c, char* key, char* what) except -1: - #print "e_fakeroot", key, what - - if c.config == 1: - from bb.parse import ParseError - raise ParseError("No fakeroot allowed in config files") - return -1 - - return 0 - -cdef public int e_def(lex_t* c, char* a, char* b, char* d) except -1: - #print "e_def", a, b, d - - if c.config == 1: - from bb.parse import ParseError - raise ParseError("No defs allowed in config files") - return -1 - - return 0 - -cdef public int e_parse_error(lex_t* c) except -1: - print "e_parse_error", c.name, "line:", lineError, "parse:", errorParse - - - from bb.parse import ParseError - raise ParseError("There was an parse error, sorry unable to give more information at the current time. File: %s Line: %d" % (c.name,lineError) ) - return -1 - diff --git a/bitbake/lib/bb/parse/parse_c/bitbakeparser.cc b/bitbake/lib/bb/parse/parse_c/bitbakeparser.cc deleted file mode 100644 index 9d9793f8df..0000000000 --- a/bitbake/lib/bb/parse/parse_c/bitbakeparser.cc +++ /dev/null @@ -1,1157 +0,0 @@ -/* Driver template for the LEMON parser generator. -** The author disclaims copyright to this source code. -*/ -/* First off, code is include which follows the "include" declaration -** in the input file. */ -#include <stdio.h> -#line 43 "bitbakeparser.y" - -#include "token.h" -#include "lexer.h" -#include "python_output.h" -#line 14 "bitbakeparser.c" -/* Next is all token values, in a form suitable for use by makeheaders. -** This section will be null unless lemon is run with the -m switch. -*/ -/* -** These constants (all generated automatically by the parser generator) -** specify the various kinds of tokens (terminals) that the parser -** understands. -** -** Each symbol here is a terminal symbol in the grammar. -*/ -/* Make sure the INTERFACE macro is defined. -*/ -#ifndef INTERFACE -# define INTERFACE 1 -#endif -/* The next thing included is series of defines which control -** various aspects of the generated parser. -** YYCODETYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 terminals -** and nonterminals. "int" is used otherwise. -** YYNOCODE is a number of type YYCODETYPE which corresponds -** to no legal terminal or nonterminal number. This -** number is used to fill in empty slots of the hash -** table. -** YYFALLBACK If defined, this indicates that one or more tokens -** have fall-back values which should be used if the -** original value of the token will not parse. -** YYACTIONTYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 rules and -** states combined. "int" is used otherwise. -** bbparseTOKENTYPE is the data type used for minor tokens given -** directly to the parser from the tokenizer. -** YYMINORTYPE is the data type used for all minor tokens. -** This is typically a union of many types, one of -** which is bbparseTOKENTYPE. The entry in the union -** for base tokens is called "yy0". -** YYSTACKDEPTH is the maximum depth of the parser's stack. -** bbparseARG_SDECL A static variable declaration for the %extra_argument -** bbparseARG_PDECL A parameter declaration for the %extra_argument -** bbparseARG_STORE Code to store %extra_argument into yypParser -** bbparseARG_FETCH Code to extract %extra_argument from yypParser -** YYNSTATE the combined number of states. -** YYNRULE the number of rules in the grammar -** YYERRORSYMBOL is the code number of the error symbol. If not -** defined, then do no error processing. -*/ -#define YYCODETYPE unsigned char -#define YYNOCODE 44 -#define YYACTIONTYPE unsigned char -#define bbparseTOKENTYPE token_t -typedef union { - bbparseTOKENTYPE yy0; - int yy87; -} YYMINORTYPE; -#define YYSTACKDEPTH 100 -#define bbparseARG_SDECL lex_t* lex; -#define bbparseARG_PDECL ,lex_t* lex -#define bbparseARG_FETCH lex_t* lex = yypParser->lex -#define bbparseARG_STORE yypParser->lex = lex -#define YYNSTATE 82 -#define YYNRULE 45 -#define YYERRORSYMBOL 30 -#define YYERRSYMDT yy87 -#define YY_NO_ACTION (YYNSTATE+YYNRULE+2) -#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) -#define YY_ERROR_ACTION (YYNSTATE+YYNRULE) - -/* Next are that tables used to determine what action to take based on the -** current state and lookahead token. These tables are used to implement -** functions that take a state number and lookahead value and return an -** action integer. -** -** Suppose the action integer is N. Then the action is determined as -** follows -** -** 0 <= N < YYNSTATE Shift N. That is, push the lookahead -** token onto the stack and goto state N. -** -** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. -** -** N == YYNSTATE+YYNRULE A syntax error has occurred. -** -** N == YYNSTATE+YYNRULE+1 The parser accepts its input. -** -** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused -** slots in the yy_action[] table. -** -** The action table is constructed as a single large table named yy_action[]. -** Given state S and lookahead X, the action is computed as -** -** yy_action[ yy_shift_ofst[S] + X ] -** -** If the index value yy_shift_ofst[S]+X is out of range or if the value -** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] -** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table -** and that yy_default[S] should be used instead. -** -** The formula above is for computing the action when the lookahead is -** a terminal symbol. If the lookahead is a non-terminal (as occurs after -** a reduce action) then the yy_reduce_ofst[] array is used in place of -** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of -** YY_SHIFT_USE_DFLT. -** -** The following are the tables generated in this section: -** -** yy_action[] A single table containing all actions. -** yy_lookahead[] A table containing the lookahead for each entry in -** yy_action. Used to detect hash collisions. -** yy_shift_ofst[] For each state, the offset into yy_action for -** shifting terminals. -** yy_reduce_ofst[] For each state, the offset into yy_action for -** shifting non-terminals after a reduce. -** yy_default[] Default action for each state. -*/ -static const YYACTIONTYPE yy_action[] = { - /* 0 */ 82, 3, 7, 8, 38, 22, 39, 24, 26, 32, - /* 10 */ 34, 28, 30, 2, 21, 40, 53, 70, 55, 44, - /* 20 */ 60, 65, 67, 128, 1, 36, 69, 77, 42, 46, - /* 30 */ 11, 66, 13, 15, 17, 19, 64, 62, 9, 7, - /* 40 */ 74, 38, 45, 81, 59, 57, 38, 38, 73, 76, - /* 50 */ 5, 68, 52, 50, 14, 31, 47, 71, 48, 10, - /* 60 */ 72, 33, 23, 49, 6, 41, 51, 78, 75, 16, - /* 70 */ 4, 54, 35, 25, 18, 80, 79, 56, 27, 37, - /* 80 */ 58, 12, 61, 29, 43, 63, 20, -}; -static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 0, 1, 2, 3, 23, 4, 25, 6, 7, 8, - /* 10 */ 9, 10, 11, 33, 34, 15, 16, 1, 18, 14, - /* 20 */ 20, 21, 22, 31, 32, 24, 26, 27, 13, 14, - /* 30 */ 4, 19, 6, 7, 8, 9, 39, 40, 1, 2, - /* 40 */ 24, 23, 12, 25, 37, 38, 23, 23, 25, 25, - /* 50 */ 42, 19, 35, 36, 5, 5, 12, 24, 13, 34, - /* 60 */ 41, 5, 5, 12, 28, 12, 35, 1, 41, 5, - /* 70 */ 29, 1, 5, 5, 5, 41, 24, 17, 5, 41, - /* 80 */ 37, 5, 19, 5, 12, 39, 5, -}; -#define YY_SHIFT_USE_DFLT (-20) -static const signed char yy_shift_ofst[] = { - /* 0 */ -20, 0, -20, 41, -20, 36, -20, -20, 37, -20, - /* 10 */ 26, 76, -20, 49, -20, 64, -20, 69, -20, 81, - /* 20 */ -20, 1, 57, -20, 68, -20, 73, -20, 78, -20, - /* 30 */ 50, -20, 56, -20, 67, -20, -20, -19, -20, -20, - /* 40 */ 53, 15, 72, 5, 30, -20, 44, 45, 51, -20, - /* 50 */ 53, -20, -20, 70, -20, 60, -20, 60, -20, -20, - /* 60 */ 63, -20, 63, -20, -20, 12, -20, 32, -20, 16, - /* 70 */ 33, -20, 23, -20, -20, 24, -20, 66, 52, -20, - /* 80 */ 18, -20, -}; -#define YY_REDUCE_USE_DFLT (-21) -static const signed char yy_reduce_ofst[] = { - /* 0 */ -8, -20, -21, -21, 8, -21, -21, -21, 25, -21, - /* 10 */ -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - /* 20 */ -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, - /* 30 */ -21, -21, -21, -21, -21, -21, 38, -21, -21, -21, - /* 40 */ 17, -21, -21, -21, -21, -21, -21, -21, -21, -21, - /* 50 */ 31, -21, -21, -21, -21, 7, -21, 43, -21, -21, - /* 60 */ -3, -21, 46, -21, -21, -21, -21, -21, -21, -21, - /* 70 */ -21, 19, -21, -21, 27, -21, -21, -21, -21, 34, - /* 80 */ -21, -21, -}; -static const YYACTIONTYPE yy_default[] = { - /* 0 */ 84, 127, 83, 85, 125, 126, 124, 86, 127, 85, - /* 10 */ 127, 127, 87, 127, 88, 127, 89, 127, 90, 127, - /* 20 */ 91, 127, 127, 92, 127, 93, 127, 94, 127, 95, - /* 30 */ 127, 96, 127, 97, 127, 98, 119, 127, 118, 120, - /* 40 */ 127, 101, 127, 102, 127, 99, 127, 103, 127, 100, - /* 50 */ 106, 104, 105, 127, 107, 127, 108, 111, 109, 110, - /* 60 */ 127, 112, 115, 113, 114, 127, 116, 127, 117, 127, - /* 70 */ 127, 119, 127, 121, 119, 127, 122, 127, 127, 119, - /* 80 */ 127, 123, -}; -#define YY_SZ_ACTTAB (sizeof(yy_action)/sizeof(yy_action[0])) - -/* The next table maps tokens into fallback tokens. If a construct -** like the following: -** -** %fallback ID X Y Z. -** -** appears in the grammer, then ID becomes a fallback token for X, Y, -** and Z. Whenever one of the tokens X, Y, or Z is input to the parser -** but it does not parse, the type of the token is changed to ID and -** the parse is retried before an error is thrown. -*/ -#ifdef YYFALLBACK -static const YYCODETYPE yyFallback[] = { -}; -#endif /* YYFALLBACK */ - -/* The following structure represents a single element of the -** parser's stack. Information stored includes: -** -** + The state number for the parser at this level of the stack. -** -** + The value of the token stored at this level of the stack. -** (In other words, the "major" token.) -** -** + The semantic value stored at this level of the stack. This is -** the information used by the action routines in the grammar. -** It is sometimes called the "minor" token. -*/ -struct yyStackEntry { - int stateno; /* The state-number */ - int major; /* The major token value. This is the code - ** number for the token at this stack level */ - YYMINORTYPE minor; /* The user-supplied minor token value. This - ** is the value of the token */ -}; -typedef struct yyStackEntry yyStackEntry; - -/* The state of the parser is completely contained in an instance of -** the following structure */ -struct yyParser { - int yyidx; /* Index of top element in stack */ - int yyerrcnt; /* Shifts left before out of the error */ - bbparseARG_SDECL /* A place to hold %extra_argument */ - yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ -}; -typedef struct yyParser yyParser; - -#ifndef NDEBUG -#include <stdio.h> -static FILE *yyTraceFILE = 0; -static char *yyTracePrompt = 0; -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* -** Turn parser tracing on by giving a stream to which to write the trace -** and a prompt to preface each trace message. Tracing is turned off -** by making either argument NULL -** -** Inputs: -** <ul> -** <li> A FILE* to which trace output should be written. -** If NULL, then tracing is turned off. -** <li> A prefix string written at the beginning of every -** line of trace output. If NULL, then tracing is -** turned off. -** </ul> -** -** Outputs: -** None. -*/ -void bbparseTrace(FILE *TraceFILE, char *zTracePrompt){ - yyTraceFILE = TraceFILE; - yyTracePrompt = zTracePrompt; - if( yyTraceFILE==0 ) yyTracePrompt = 0; - else if( yyTracePrompt==0 ) yyTraceFILE = 0; -} -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* For tracing shifts, the names of all terminals and nonterminals -** are required. The following table supplies these names */ -static const char *const yyTokenName[] = { - "$", "SYMBOL", "VARIABLE", "EXPORT", - "OP_ASSIGN", "STRING", "OP_PREDOT", "OP_POSTDOT", - "OP_IMMEDIATE", "OP_COND", "OP_PREPEND", "OP_APPEND", - "TSYMBOL", "BEFORE", "AFTER", "ADDTASK", - "ADDHANDLER", "FSYMBOL", "EXPORT_FUNC", "ISYMBOL", - "INHERIT", "INCLUDE", "REQUIRE", "PROC_BODY", - "PROC_OPEN", "PROC_CLOSE", "PYTHON", "FAKEROOT", - "DEF_BODY", "DEF_ARGS", "error", "program", - "statements", "statement", "variable", "task", - "tasks", "func", "funcs", "inherit", - "inherits", "proc_body", "def_body", -}; -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* For tracing reduce actions, the names of all rules are required. -*/ -static const char *const yyRuleName[] = { - /* 0 */ "program ::= statements", - /* 1 */ "statements ::= statements statement", - /* 2 */ "statements ::=", - /* 3 */ "variable ::= SYMBOL", - /* 4 */ "variable ::= VARIABLE", - /* 5 */ "statement ::= EXPORT variable OP_ASSIGN STRING", - /* 6 */ "statement ::= EXPORT variable OP_PREDOT STRING", - /* 7 */ "statement ::= EXPORT variable OP_POSTDOT STRING", - /* 8 */ "statement ::= EXPORT variable OP_IMMEDIATE STRING", - /* 9 */ "statement ::= EXPORT variable OP_COND STRING", - /* 10 */ "statement ::= variable OP_ASSIGN STRING", - /* 11 */ "statement ::= variable OP_PREDOT STRING", - /* 12 */ "statement ::= variable OP_POSTDOT STRING", - /* 13 */ "statement ::= variable OP_PREPEND STRING", - /* 14 */ "statement ::= variable OP_APPEND STRING", - /* 15 */ "statement ::= variable OP_IMMEDIATE STRING", - /* 16 */ "statement ::= variable OP_COND STRING", - /* 17 */ "task ::= TSYMBOL BEFORE TSYMBOL AFTER TSYMBOL", - /* 18 */ "task ::= TSYMBOL AFTER TSYMBOL BEFORE TSYMBOL", - /* 19 */ "task ::= TSYMBOL", - /* 20 */ "task ::= TSYMBOL BEFORE TSYMBOL", - /* 21 */ "task ::= TSYMBOL AFTER TSYMBOL", - /* 22 */ "tasks ::= tasks task", - /* 23 */ "tasks ::= task", - /* 24 */ "statement ::= ADDTASK tasks", - /* 25 */ "statement ::= ADDHANDLER SYMBOL", - /* 26 */ "func ::= FSYMBOL", - /* 27 */ "funcs ::= funcs func", - /* 28 */ "funcs ::= func", - /* 29 */ "statement ::= EXPORT_FUNC funcs", - /* 30 */ "inherit ::= ISYMBOL", - /* 31 */ "inherits ::= inherits inherit", - /* 32 */ "inherits ::= inherit", - /* 33 */ "statement ::= INHERIT inherits", - /* 34 */ "statement ::= INCLUDE ISYMBOL", - /* 35 */ "statement ::= REQUIRE ISYMBOL", - /* 36 */ "proc_body ::= proc_body PROC_BODY", - /* 37 */ "proc_body ::=", - /* 38 */ "statement ::= variable PROC_OPEN proc_body PROC_CLOSE", - /* 39 */ "statement ::= PYTHON SYMBOL PROC_OPEN proc_body PROC_CLOSE", - /* 40 */ "statement ::= PYTHON PROC_OPEN proc_body PROC_CLOSE", - /* 41 */ "statement ::= FAKEROOT SYMBOL PROC_OPEN proc_body PROC_CLOSE", - /* 42 */ "def_body ::= def_body DEF_BODY", - /* 43 */ "def_body ::=", - /* 44 */ "statement ::= SYMBOL DEF_ARGS def_body", -}; -#endif /* NDEBUG */ - -/* -** This function returns the symbolic name associated with a token -** value. -*/ -const char *bbparseTokenName(int tokenType){ -#ifndef NDEBUG - if( tokenType>0 && tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){ - return yyTokenName[tokenType]; - }else{ - return "Unknown"; - } -#else - return ""; -#endif -} - -/* -** This function allocates a new parser. -** The only argument is a pointer to a function which works like -** malloc. -** -** Inputs: -** A pointer to the function used to allocate memory. -** -** Outputs: -** A pointer to a parser. This pointer is used in subsequent calls -** to bbparse and bbparseFree. -*/ -void *bbparseAlloc(void *(*mallocProc)(size_t)){ - yyParser *pParser; - pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); - if( pParser ){ - pParser->yyidx = -1; - } - return pParser; -} - -/* The following function deletes the value associated with a -** symbol. The symbol can be either a terminal or nonterminal. -** "yymajor" is the symbol code, and "yypminor" is a pointer to -** the value. -*/ -static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){ - switch( yymajor ){ - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. - */ - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - case 19: - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - case 28: - case 29: -#line 50 "bitbakeparser.y" -{ (yypminor->yy0).release_this (); } -#line 423 "bitbakeparser.c" - break; - default: break; /* If no destructor action specified: do nothing */ - } -} - -/* -** Pop the parser's stack once. -** -** If there is a destructor routine associated with the token which -** is popped from the stack, then call it. -** -** Return the major token number for the symbol popped. -*/ -static int yy_pop_parser_stack(yyParser *pParser){ - YYCODETYPE yymajor; - yyStackEntry *yytos = &pParser->yystack[pParser->yyidx]; - - if( pParser->yyidx<0 ) return 0; -#ifndef NDEBUG - if( yyTraceFILE && pParser->yyidx>=0 ){ - fprintf(yyTraceFILE,"%sPopping %s\n", - yyTracePrompt, - yyTokenName[yytos->major]); - } -#endif - yymajor = yytos->major; - yy_destructor( yymajor, &yytos->minor); - pParser->yyidx--; - return yymajor; -} - -/* -** Deallocate and destroy a parser. Destructors are all called for -** all stack elements before shutting the parser down. -** -** Inputs: -** <ul> -** <li> A pointer to the parser. This should be a pointer -** obtained from bbparseAlloc. -** <li> A pointer to a function used to reclaim memory obtained -** from malloc. -** </ul> -*/ -void bbparseFree( - void *p, /* The parser to be deleted */ - void (*freeProc)(void*) /* Function used to reclaim memory */ -){ - yyParser *pParser = (yyParser*)p; - if( pParser==0 ) return; - while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); - (*freeProc)((void*)pParser); -} - -/* -** Find the appropriate action for a parser given the terminal -** look-ahead token iLookAhead. -** -** If the look-ahead token is YYNOCODE, then check to see if the action is -** independent of the look-ahead. If it is, return the action, otherwise -** return YY_NO_ACTION. -*/ -static int yy_find_shift_action( - yyParser *pParser, /* The parser */ - int iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->yystack[pParser->yyidx].stateno; - - /* if( pParser->yyidx<0 ) return YY_NO_ACTION; */ - i = yy_shift_ofst[stateno]; - if( i==YY_SHIFT_USE_DFLT ){ - return yy_default[stateno]; - } - if( iLookAhead==YYNOCODE ){ - return YY_NO_ACTION; - } - i += iLookAhead; - if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ -#ifdef YYFALLBACK - int iFallback; /* Fallback token */ - if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) - && (iFallback = yyFallback[iLookAhead])!=0 ){ -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); - } -#endif - return yy_find_shift_action(pParser, iFallback); - } -#endif - return yy_default[stateno]; - }else{ - return yy_action[i]; - } -} - -/* -** Find the appropriate action for a parser given the non-terminal -** look-ahead token iLookAhead. -** -** If the look-ahead token is YYNOCODE, then check to see if the action is -** independent of the look-ahead. If it is, return the action, otherwise -** return YY_NO_ACTION. -*/ -static int yy_find_reduce_action( - int stateno, /* Current state number */ - int iLookAhead /* The look-ahead token */ -){ - int i; - /* int stateno = pParser->yystack[pParser->yyidx].stateno; */ - - i = yy_reduce_ofst[stateno]; - if( i==YY_REDUCE_USE_DFLT ){ - return yy_default[stateno]; - } - if( iLookAhead==YYNOCODE ){ - return YY_NO_ACTION; - } - i += iLookAhead; - if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ - return yy_default[stateno]; - }else{ - return yy_action[i]; - } -} - -/* -** Perform a shift action. -*/ -static void yy_shift( - yyParser *yypParser, /* The parser to be shifted */ - int yyNewState, /* The new state to shift in */ - int yyMajor, /* The major token to shift in */ - YYMINORTYPE *yypMinor /* Pointer ot the minor token to shift in */ -){ - yyStackEntry *yytos; - yypParser->yyidx++; - if( yypParser->yyidx>=YYSTACKDEPTH ){ - bbparseARG_FETCH; - yypParser->yyidx--; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will execute if the parser - ** stack every overflows */ - bbparseARG_STORE; /* Suppress warning about unused %extra_argument var */ - return; - } - yytos = &yypParser->yystack[yypParser->yyidx]; - yytos->stateno = yyNewState; - yytos->major = yyMajor; - yytos->minor = *yypMinor; -#ifndef NDEBUG - if( yyTraceFILE && yypParser->yyidx>0 ){ - int i; - fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); - fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); - for(i=1; i<=yypParser->yyidx; i++) - fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); - fprintf(yyTraceFILE,"\n"); - } -#endif -} - -/* The following table contains information about every rule that -** is used during the reduce. -*/ -static const struct { - YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - unsigned char nrhs; /* Number of right-hand side symbols in the rule */ -} yyRuleInfo[] = { - { 31, 1 }, - { 32, 2 }, - { 32, 0 }, - { 34, 1 }, - { 34, 1 }, - { 33, 4 }, - { 33, 4 }, - { 33, 4 }, - { 33, 4 }, - { 33, 4 }, - { 33, 3 }, - { 33, 3 }, - { 33, 3 }, - { 33, 3 }, - { 33, 3 }, - { 33, 3 }, - { 33, 3 }, - { 35, 5 }, - { 35, 5 }, - { 35, 1 }, - { 35, 3 }, - { 35, 3 }, - { 36, 2 }, - { 36, 1 }, - { 33, 2 }, - { 33, 2 }, - { 37, 1 }, - { 38, 2 }, - { 38, 1 }, - { 33, 2 }, - { 39, 1 }, - { 40, 2 }, - { 40, 1 }, - { 33, 2 }, - { 33, 2 }, - { 33, 2 }, - { 41, 2 }, - { 41, 0 }, - { 33, 4 }, - { 33, 5 }, - { 33, 4 }, - { 33, 5 }, - { 42, 2 }, - { 42, 0 }, - { 33, 3 }, -}; - -static void yy_accept(yyParser*); /* Forward Declaration */ - -/* -** Perform a reduce action and the shift that must immediately -** follow the reduce. -*/ -static void yy_reduce( - yyParser *yypParser, /* The parser */ - int yyruleno /* Number of the rule by which to reduce */ -){ - int yygoto; /* The next state */ - int yyact; /* The next action */ - YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ - yyStackEntry *yymsp; /* The top of the parser's stack */ - int yysize; /* Amount to pop the stack */ - bbparseARG_FETCH; - yymsp = &yypParser->yystack[yypParser->yyidx]; -#ifndef NDEBUG - if( yyTraceFILE && yyruleno>=0 - && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){ - fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, - yyRuleName[yyruleno]); - } -#endif /* NDEBUG */ - -#ifndef NDEBUG - /* Silence complaints from purify about yygotominor being uninitialized - ** in some cases when it is copied into the stack after the following - ** switch. yygotominor is uninitialized when a rule reduces that does - ** not set the value of its left-hand side nonterminal. Leaving the - ** value of the nonterminal uninitialized is utterly harmless as long - ** as the value is never used. So really the only thing this code - ** accomplishes is to quieten purify. - */ - memset(&yygotominor, 0, sizeof(yygotominor)); -#endif - - switch( yyruleno ){ - /* Beginning here are the reduction cases. A typical example - ** follows: - ** case 0: - ** #line <lineno> <grammarfile> - ** { ... } // User supplied code - ** #line <lineno> <thisfile> - ** break; - */ - case 3: -#line 60 "bitbakeparser.y" -{ yygotominor.yy0.assignString( (char*)yymsp[0].minor.yy0.string() ); - yymsp[0].minor.yy0.assignString( 0 ); - yymsp[0].minor.yy0.release_this(); } -#line 697 "bitbakeparser.c" - break; - case 4: -#line 64 "bitbakeparser.y" -{ - yygotominor.yy0.assignString( (char*)yymsp[0].minor.yy0.string() ); - yymsp[0].minor.yy0.assignString( 0 ); - yymsp[0].minor.yy0.release_this(); } -#line 705 "bitbakeparser.c" - break; - case 5: -#line 70 "bitbakeparser.y" -{ e_assign( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() ); - e_export( lex, yymsp[-2].minor.yy0.string() ); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(3,&yymsp[-3].minor); - yy_destructor(4,&yymsp[-1].minor); -} -#line 714 "bitbakeparser.c" - break; - case 6: -#line 74 "bitbakeparser.y" -{ e_precat( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() ); - e_export( lex, yymsp[-2].minor.yy0.string() ); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(3,&yymsp[-3].minor); - yy_destructor(6,&yymsp[-1].minor); -} -#line 723 "bitbakeparser.c" - break; - case 7: -#line 78 "bitbakeparser.y" -{ e_postcat( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() ); - e_export( lex, yymsp[-2].minor.yy0.string() ); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(3,&yymsp[-3].minor); - yy_destructor(7,&yymsp[-1].minor); -} -#line 732 "bitbakeparser.c" - break; - case 8: -#line 82 "bitbakeparser.y" -{ e_immediate ( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() ); - e_export( lex, yymsp[-2].minor.yy0.string() ); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(3,&yymsp[-3].minor); - yy_destructor(8,&yymsp[-1].minor); -} -#line 741 "bitbakeparser.c" - break; - case 9: -#line 86 "bitbakeparser.y" -{ e_cond( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() ); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(3,&yymsp[-3].minor); - yy_destructor(9,&yymsp[-1].minor); -} -#line 749 "bitbakeparser.c" - break; - case 10: -#line 90 "bitbakeparser.y" -{ e_assign( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() ); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(4,&yymsp[-1].minor); -} -#line 756 "bitbakeparser.c" - break; - case 11: -#line 93 "bitbakeparser.y" -{ e_precat( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() ); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(6,&yymsp[-1].minor); -} -#line 763 "bitbakeparser.c" - break; - case 12: -#line 96 "bitbakeparser.y" -{ e_postcat( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() ); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(7,&yymsp[-1].minor); -} -#line 770 "bitbakeparser.c" - break; - case 13: -#line 99 "bitbakeparser.y" -{ e_prepend( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() ); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(10,&yymsp[-1].minor); -} -#line 777 "bitbakeparser.c" - break; - case 14: -#line 102 "bitbakeparser.y" -{ e_append( lex, yymsp[-2].minor.yy0.string() , yymsp[0].minor.yy0.string() ); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(11,&yymsp[-1].minor); -} -#line 784 "bitbakeparser.c" - break; - case 15: -#line 105 "bitbakeparser.y" -{ e_immediate( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() ); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(8,&yymsp[-1].minor); -} -#line 791 "bitbakeparser.c" - break; - case 16: -#line 108 "bitbakeparser.y" -{ e_cond( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() ); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(9,&yymsp[-1].minor); -} -#line 798 "bitbakeparser.c" - break; - case 17: -#line 112 "bitbakeparser.y" -{ e_addtask( lex, yymsp[-4].minor.yy0.string(), yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() ); - yymsp[-4].minor.yy0.release_this(); yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(13,&yymsp[-3].minor); - yy_destructor(14,&yymsp[-1].minor); -} -#line 806 "bitbakeparser.c" - break; - case 18: -#line 115 "bitbakeparser.y" -{ e_addtask( lex, yymsp[-4].minor.yy0.string(), yymsp[0].minor.yy0.string(), yymsp[-2].minor.yy0.string()); - yymsp[-4].minor.yy0.release_this(); yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(14,&yymsp[-3].minor); - yy_destructor(13,&yymsp[-1].minor); -} -#line 814 "bitbakeparser.c" - break; - case 19: -#line 118 "bitbakeparser.y" -{ e_addtask( lex, yymsp[0].minor.yy0.string(), NULL, NULL); - yymsp[0].minor.yy0.release_this();} -#line 820 "bitbakeparser.c" - break; - case 20: -#line 121 "bitbakeparser.y" -{ e_addtask( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string(), NULL); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(13,&yymsp[-1].minor); -} -#line 827 "bitbakeparser.c" - break; - case 21: -#line 124 "bitbakeparser.y" -{ e_addtask( lex, yymsp[-2].minor.yy0.string(), NULL, yymsp[0].minor.yy0.string()); - yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(14,&yymsp[-1].minor); -} -#line 834 "bitbakeparser.c" - break; - case 25: -#line 131 "bitbakeparser.y" -{ e_addhandler( lex, yymsp[0].minor.yy0.string()); yymsp[0].minor.yy0.release_this (); yy_destructor(16,&yymsp[-1].minor); -} -#line 840 "bitbakeparser.c" - break; - case 26: -#line 133 "bitbakeparser.y" -{ e_export_func( lex, yymsp[0].minor.yy0.string()); yymsp[0].minor.yy0.release_this(); } -#line 845 "bitbakeparser.c" - break; - case 30: -#line 138 "bitbakeparser.y" -{ e_inherit( lex, yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this (); } -#line 850 "bitbakeparser.c" - break; - case 34: -#line 144 "bitbakeparser.y" -{ e_include( lex, yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this(); yy_destructor(21,&yymsp[-1].minor); -} -#line 856 "bitbakeparser.c" - break; - case 35: -#line 147 "bitbakeparser.y" -{ e_require( lex, yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this(); yy_destructor(22,&yymsp[-1].minor); -} -#line 862 "bitbakeparser.c" - break; - case 36: -#line 150 "bitbakeparser.y" -{ /* concatenate body lines */ - yygotominor.yy0.assignString( token_t::concatString(yymsp[-1].minor.yy0.string(), yymsp[0].minor.yy0.string()) ); - yymsp[-1].minor.yy0.release_this (); - yymsp[0].minor.yy0.release_this (); - } -#line 871 "bitbakeparser.c" - break; - case 37: -#line 155 "bitbakeparser.y" -{ yygotominor.yy0.assignString(0); } -#line 876 "bitbakeparser.c" - break; - case 38: -#line 157 "bitbakeparser.y" -{ e_proc( lex, yymsp[-3].minor.yy0.string(), yymsp[-1].minor.yy0.string() ); - yymsp[-3].minor.yy0.release_this(); yymsp[-1].minor.yy0.release_this(); yy_destructor(24,&yymsp[-2].minor); - yy_destructor(25,&yymsp[0].minor); -} -#line 884 "bitbakeparser.c" - break; - case 39: -#line 160 "bitbakeparser.y" -{ e_proc_python ( lex, yymsp[-3].minor.yy0.string(), yymsp[-1].minor.yy0.string() ); - yymsp[-3].minor.yy0.release_this(); yymsp[-1].minor.yy0.release_this(); yy_destructor(26,&yymsp[-4].minor); - yy_destructor(24,&yymsp[-2].minor); - yy_destructor(25,&yymsp[0].minor); -} -#line 893 "bitbakeparser.c" - break; - case 40: -#line 163 "bitbakeparser.y" -{ e_proc_python( lex, NULL, yymsp[-1].minor.yy0.string()); - yymsp[-1].minor.yy0.release_this (); yy_destructor(26,&yymsp[-3].minor); - yy_destructor(24,&yymsp[-2].minor); - yy_destructor(25,&yymsp[0].minor); -} -#line 902 "bitbakeparser.c" - break; - case 41: -#line 167 "bitbakeparser.y" -{ e_proc_fakeroot( lex, yymsp[-3].minor.yy0.string(), yymsp[-1].minor.yy0.string() ); - yymsp[-3].minor.yy0.release_this (); yymsp[-1].minor.yy0.release_this (); yy_destructor(27,&yymsp[-4].minor); - yy_destructor(24,&yymsp[-2].minor); - yy_destructor(25,&yymsp[0].minor); -} -#line 911 "bitbakeparser.c" - break; - case 42: -#line 171 "bitbakeparser.y" -{ /* concatenate body lines */ - yygotominor.yy0.assignString( token_t::concatString(yymsp[-1].minor.yy0.string(), yymsp[0].minor.yy0.string()) ); - yymsp[-1].minor.yy0.release_this (); yymsp[0].minor.yy0.release_this (); - } -#line 919 "bitbakeparser.c" - break; - case 43: -#line 175 "bitbakeparser.y" -{ yygotominor.yy0.assignString( 0 ); } -#line 924 "bitbakeparser.c" - break; - case 44: -#line 177 "bitbakeparser.y" -{ e_def( lex, yymsp[-2].minor.yy0.string(), yymsp[-1].minor.yy0.string(), yymsp[0].minor.yy0.string()); - yymsp[-2].minor.yy0.release_this(); yymsp[-1].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); } -#line 930 "bitbakeparser.c" - break; - }; - yygoto = yyRuleInfo[yyruleno].lhs; - yysize = yyRuleInfo[yyruleno].nrhs; - yypParser->yyidx -= yysize; - yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto); - if( yyact < YYNSTATE ){ -#ifdef NDEBUG - /* If we are not debugging and the reduce action popped at least - ** one element off the stack, then we can push the new element back - ** onto the stack here, and skip the stack overflow test in yy_shift(). - ** That gives a significant speed improvement. */ - if( yysize ){ - yypParser->yyidx++; - yymsp -= yysize-1; - yymsp->stateno = yyact; - yymsp->major = yygoto; - yymsp->minor = yygotominor; - }else -#endif - { - yy_shift(yypParser,yyact,yygoto,&yygotominor); - } - }else if( yyact == YYNSTATE + YYNRULE + 1 ){ - yy_accept(yypParser); - } -} - -/* -** The following code executes when the parse fails -*/ -static void yy_parse_failed( - yyParser *yypParser /* The parser */ -){ - bbparseARG_FETCH; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser fails */ - bbparseARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* -** The following code executes when a syntax error first occurs. -*/ -static void yy_syntax_error( - yyParser *yypParser, /* The parser */ - int yymajor, /* The major type of the error token */ - YYMINORTYPE yyminor /* The minor type of the error token */ -){ - bbparseARG_FETCH; -#define TOKEN (yyminor.yy0) -#line 52 "bitbakeparser.y" - e_parse_error( lex ); -#line 990 "bitbakeparser.c" - bbparseARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* -** The following is executed when the parser accepts -*/ -static void yy_accept( - yyParser *yypParser /* The parser */ -){ - bbparseARG_FETCH; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - bbparseARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* The main parser program. -** The first argument is a pointer to a structure obtained from -** "bbparseAlloc" which describes the current state of the parser. -** The second argument is the major token number. The third is -** the minor token. The fourth optional argument is whatever the -** user wants (and specified in the grammar) and is available for -** use by the action routines. -** -** Inputs: -** <ul> -** <li> A pointer to the parser (an opaque structure.) -** <li> The major token number. -** <li> The minor token number. -** <li> An option argument of a grammar-specified type. -** </ul> -** -** Outputs: -** None. -*/ -void bbparse( - void *yyp, /* The parser */ - int yymajor, /* The major token code number */ - bbparseTOKENTYPE yyminor /* The value for the token */ - bbparseARG_PDECL /* Optional %extra_argument parameter */ -){ - YYMINORTYPE yyminorunion; - int yyact; /* The parser action. */ - int yyendofinput; /* True if we are at the end of input */ - int yyerrorhit = 0; /* True if yymajor has invoked an error */ - yyParser *yypParser; /* The parser */ - - /* (re)initialize the parser, if necessary */ - yypParser = (yyParser*)yyp; - if( yypParser->yyidx<0 ){ - if( yymajor==0 ) return; - yypParser->yyidx = 0; - yypParser->yyerrcnt = -1; - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; - } - yyminorunion.yy0 = yyminor; - yyendofinput = (yymajor==0); - bbparseARG_STORE; - -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); - } -#endif - - do{ - yyact = yy_find_shift_action(yypParser,yymajor); - if( yyact<YYNSTATE ){ - yy_shift(yypParser,yyact,yymajor,&yyminorunion); - yypParser->yyerrcnt--; - if( yyendofinput && yypParser->yyidx>=0 ){ - yymajor = 0; - }else{ - yymajor = YYNOCODE; - } - }else if( yyact < YYNSTATE + YYNRULE ){ - yy_reduce(yypParser,yyact-YYNSTATE); - }else if( yyact == YY_ERROR_ACTION ){ - int yymx; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); - } -#endif -#ifdef YYERRORSYMBOL - /* A syntax error has occurred. - ** The response to an error depends upon whether or not the - ** grammar defines an error token "ERROR". - ** - ** This is what we do if the grammar does define ERROR: - ** - ** * Call the %syntax_error function. - ** - ** * Begin popping the stack until we enter a state where - ** it is legal to shift the error symbol, then shift - ** the error symbol. - ** - ** * Set the error count to three. - ** - ** * Begin accepting and shifting new tokens. No new error - ** processing will occur until three tokens have been - ** shifted successfully. - ** - */ - if( yypParser->yyerrcnt<0 ){ - yy_syntax_error(yypParser,yymajor,yyminorunion); - } - yymx = yypParser->yystack[yypParser->yyidx].major; - if( yymx==YYERRORSYMBOL || yyerrorhit ){ -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sDiscard input token %s\n", - yyTracePrompt,yyTokenName[yymajor]); - } -#endif - yy_destructor(yymajor,&yyminorunion); - yymajor = YYNOCODE; - }else{ - while( - yypParser->yyidx >= 0 && - yymx != YYERRORSYMBOL && - (yyact = yy_find_shift_action(yypParser,YYERRORSYMBOL)) >= YYNSTATE - ){ - yy_pop_parser_stack(yypParser); - } - if( yypParser->yyidx < 0 || yymajor==0 ){ - yy_destructor(yymajor,&yyminorunion); - yy_parse_failed(yypParser); - yymajor = YYNOCODE; - }else if( yymx!=YYERRORSYMBOL ){ - YYMINORTYPE u2; - u2.YYERRSYMDT = 0; - yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); - } - } - yypParser->yyerrcnt = 3; - yyerrorhit = 1; -#else /* YYERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if( yypParser->yyerrcnt<=0 ){ - yy_syntax_error(yypParser,yymajor,yyminorunion); - } - yypParser->yyerrcnt = 3; - yy_destructor(yymajor,&yyminorunion); - if( yyendofinput ){ - yy_parse_failed(yypParser); - } - yymajor = YYNOCODE; -#endif - }else{ - yy_accept(yypParser); - yymajor = YYNOCODE; - } - }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); - return; -} diff --git a/bitbake/lib/bb/parse/parse_c/bitbakeparser.h b/bitbake/lib/bb/parse/parse_c/bitbakeparser.h deleted file mode 100644 index a2c9aa367d..0000000000 --- a/bitbake/lib/bb/parse/parse_c/bitbakeparser.h +++ /dev/null @@ -1,29 +0,0 @@ -#define T_SYMBOL 1 -#define T_VARIABLE 2 -#define T_EXPORT 3 -#define T_OP_ASSIGN 4 -#define T_STRING 5 -#define T_OP_PREDOT 6 -#define T_OP_POSTDOT 7 -#define T_OP_IMMEDIATE 8 -#define T_OP_COND 9 -#define T_OP_PREPEND 10 -#define T_OP_APPEND 11 -#define T_TSYMBOL 12 -#define T_BEFORE 13 -#define T_AFTER 14 -#define T_ADDTASK 15 -#define T_ADDHANDLER 16 -#define T_FSYMBOL 17 -#define T_EXPORT_FUNC 18 -#define T_ISYMBOL 19 -#define T_INHERIT 20 -#define T_INCLUDE 21 -#define T_REQUIRE 22 -#define T_PROC_BODY 23 -#define T_PROC_OPEN 24 -#define T_PROC_CLOSE 25 -#define T_PYTHON 26 -#define T_FAKEROOT 27 -#define T_DEF_BODY 28 -#define T_DEF_ARGS 29 diff --git a/bitbake/lib/bb/parse/parse_c/bitbakeparser.y b/bitbake/lib/bb/parse/parse_c/bitbakeparser.y deleted file mode 100644 index c18e53543b..0000000000 --- a/bitbake/lib/bb/parse/parse_c/bitbakeparser.y +++ /dev/null @@ -1,179 +0,0 @@ -/* bbp.lemon - - written by Marc Singer - 6 January 2005 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. - - DESCRIPTION - ----------- - - lemon parser specification file for a BitBake input file parser. - - Most of the interesting shenanigans are done in the lexer. The - BitBake grammar is not regular. In order to emit tokens that - the parser can properly interpret in LALR fashion, the lexer - manages the interpretation state. This is why there are ISYMBOLs, - SYMBOLS, and TSYMBOLS. - - This parser was developed by reading the limited available - documentation for BitBake and by analyzing the available BB files. - There is no assertion of correctness to be made about this parser. - -*/ - -%token_type {token_t} -%name bbparse -%token_prefix T_ -%extra_argument {lex_t* lex} - -%include { -#include "token.h" -#include "lexer.h" -#include "python_output.h" -} - - -%token_destructor { $$.release_this (); } - -%syntax_error { e_parse_error( lex ); } - -program ::= statements. - -statements ::= statements statement. -statements ::= . - -variable(r) ::= SYMBOL(s). - { r.assignString( (char*)s.string() ); - s.assignString( 0 ); - s.release_this(); } -variable(r) ::= VARIABLE(v). - { - r.assignString( (char*)v.string() ); - v.assignString( 0 ); - v.release_this(); } - -statement ::= EXPORT variable(s) OP_ASSIGN STRING(v). - { e_assign( lex, s.string(), v.string() ); - e_export( lex, s.string() ); - s.release_this(); v.release_this(); } -statement ::= EXPORT variable(s) OP_PREDOT STRING(v). - { e_precat( lex, s.string(), v.string() ); - e_export( lex, s.string() ); - s.release_this(); v.release_this(); } -statement ::= EXPORT variable(s) OP_POSTDOT STRING(v). - { e_postcat( lex, s.string(), v.string() ); - e_export( lex, s.string() ); - s.release_this(); v.release_this(); } -statement ::= EXPORT variable(s) OP_IMMEDIATE STRING(v). - { e_immediate ( lex, s.string(), v.string() ); - e_export( lex, s.string() ); - s.release_this(); v.release_this(); } -statement ::= EXPORT variable(s) OP_COND STRING(v). - { e_cond( lex, s.string(), v.string() ); - s.release_this(); v.release_this(); } - -statement ::= variable(s) OP_ASSIGN STRING(v). - { e_assign( lex, s.string(), v.string() ); - s.release_this(); v.release_this(); } -statement ::= variable(s) OP_PREDOT STRING(v). - { e_precat( lex, s.string(), v.string() ); - s.release_this(); v.release_this(); } -statement ::= variable(s) OP_POSTDOT STRING(v). - { e_postcat( lex, s.string(), v.string() ); - s.release_this(); v.release_this(); } -statement ::= variable(s) OP_PREPEND STRING(v). - { e_prepend( lex, s.string(), v.string() ); - s.release_this(); v.release_this(); } -statement ::= variable(s) OP_APPEND STRING(v). - { e_append( lex, s.string() , v.string() ); - s.release_this(); v.release_this(); } -statement ::= variable(s) OP_IMMEDIATE STRING(v). - { e_immediate( lex, s.string(), v.string() ); - s.release_this(); v.release_this(); } -statement ::= variable(s) OP_COND STRING(v). - { e_cond( lex, s.string(), v.string() ); - s.release_this(); v.release_this(); } - -task ::= TSYMBOL(t) BEFORE TSYMBOL(b) AFTER TSYMBOL(a). - { e_addtask( lex, t.string(), b.string(), a.string() ); - t.release_this(); b.release_this(); a.release_this(); } -task ::= TSYMBOL(t) AFTER TSYMBOL(a) BEFORE TSYMBOL(b). - { e_addtask( lex, t.string(), b.string(), a.string()); - t.release_this(); a.release_this(); b.release_this(); } -task ::= TSYMBOL(t). - { e_addtask( lex, t.string(), NULL, NULL); - t.release_this();} -task ::= TSYMBOL(t) BEFORE TSYMBOL(b). - { e_addtask( lex, t.string(), b.string(), NULL); - t.release_this(); b.release_this(); } -task ::= TSYMBOL(t) AFTER TSYMBOL(a). - { e_addtask( lex, t.string(), NULL, a.string()); - t.release_this(); a.release_this(); } -tasks ::= tasks task. -tasks ::= task. -statement ::= ADDTASK tasks. - -statement ::= ADDHANDLER SYMBOL(s). - { e_addhandler( lex, s.string()); s.release_this (); } - -func ::= FSYMBOL(f). { e_export_func( lex, f.string()); f.release_this(); } -funcs ::= funcs func. -funcs ::= func. -statement ::= EXPORT_FUNC funcs. - -inherit ::= ISYMBOL(i). { e_inherit( lex, i.string() ); i.release_this (); } -inherits ::= inherits inherit. -inherits ::= inherit. -statement ::= INHERIT inherits. - -statement ::= INCLUDE ISYMBOL(i). - { e_include( lex, i.string() ); i.release_this(); } - -statement ::= REQUIRE ISYMBOL(i). - { e_require( lex, i.string() ); i.release_this(); } - -proc_body(r) ::= proc_body(l) PROC_BODY(b). - { /* concatenate body lines */ - r.assignString( token_t::concatString(l.string(), b.string()) ); - l.release_this (); - b.release_this (); - } -proc_body(b) ::= . { b.assignString(0); } -statement ::= variable(p) PROC_OPEN proc_body(b) PROC_CLOSE. - { e_proc( lex, p.string(), b.string() ); - p.release_this(); b.release_this(); } -statement ::= PYTHON SYMBOL(p) PROC_OPEN proc_body(b) PROC_CLOSE. - { e_proc_python ( lex, p.string(), b.string() ); - p.release_this(); b.release_this(); } -statement ::= PYTHON PROC_OPEN proc_body(b) PROC_CLOSE. - { e_proc_python( lex, NULL, b.string()); - b.release_this (); } - -statement ::= FAKEROOT SYMBOL(p) PROC_OPEN proc_body(b) PROC_CLOSE. - { e_proc_fakeroot( lex, p.string(), b.string() ); - p.release_this (); b.release_this (); } - -def_body(r) ::= def_body(l) DEF_BODY(b). - { /* concatenate body lines */ - r.assignString( token_t::concatString(l.string(), b.string()) ); - l.release_this (); b.release_this (); - } -def_body(b) ::= . { b.assignString( 0 ); } -statement ::= SYMBOL(p) DEF_ARGS(a) def_body(b). - { e_def( lex, p.string(), a.string(), b.string()); - p.release_this(); a.release_this(); b.release_this(); } - diff --git a/bitbake/lib/bb/parse/parse_c/bitbakescanner.cc b/bitbake/lib/bb/parse/parse_c/bitbakescanner.cc deleted file mode 100644 index acc13f7c34..0000000000 --- a/bitbake/lib/bb/parse/parse_c/bitbakescanner.cc +++ /dev/null @@ -1,3209 +0,0 @@ - -#line 3 "<stdout>" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 33 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <stdlib.h> - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ - -#if __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include <inttypes.h> -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -int yylex_init (yyscan_t* scanner); - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ,yyscanner ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires - * access to the local variable yy_act. Since yyless() is a macro, it would break - * existing scanners that call yyless() from OUTSIDE yylex. - * One obvious solution it to make yy_act a global. I tried that, and saw - * a 5% performance hit in a non-yylineno scanner, because yy_act is - * normally declared as a register variable-- so it is not worth it. - */ - #define YY_LESS_LINENO(n) \ - do { \ - int yyl;\ - for ( yyl = n; yyl < yyleng; ++yyl )\ - if ( yytext[yyl] == '\n' )\ - --yylineno;\ - }while(0) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef unsigned int yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void yypop_buffer_state (yyscan_t yyscanner ); - -static void yyensure_buffer_stack (yyscan_t yyscanner ); -static void yy_load_buffer_state (yyscan_t yyscanner ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); - -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) - -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); - -void *yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void yyfree (void * ,yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define yywrap(n) 1 -#define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); -static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 47 -#define YY_END_OF_BUFFER 48 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[813] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 26, 26, 0, 0, - 0, 0, 48, 46, 45, 45, 46, 46, 46, 46, - 46, 46, 4, 46, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 28, 28, 28, 28, 28, 28, 46, - 45, 30, 45, 46, 46, 46, 46, 29, 4, 46, - 46, 46, 46, 46, 46, 33, 33, 32, 33, 33, - 33, 33, 33, 33, 4, 33, 33, 33, 33, 33, - 33, 43, 38, 38, 38, 38, 38, 38, 46, 40, - 40, 40, 40, 40, 40, 40, 44, 39, 39, 39, - - 39, 39, 39, 46, 41, 41, 41, 41, 41, 41, - 41, 26, 26, 26, 26, 26, 26, 26, 26, 4, - 26, 26, 26, 26, 26, 26, 25, 11, 45, 12, - 11, 46, 11, 46, 11, 11, 11, 11, 4, 11, - 11, 11, 11, 11, 11, 11, 42, 37, 37, 37, - 37, 37, 37, 37, 0, 34, 36, 0, 0, 1, - 5, 3, 2, 6, 7, 0, 35, 0, 35, 35, - 35, 35, 35, 35, 35, 35, 28, 28, 28, 28, - 28, 28, 0, 29, 0, 30, 0, 29, 0, 0, - 1, 5, 2, 6, 7, 0, 0, 0, 0, 0, - - 0, 0, 31, 0, 0, 0, 0, 0, 38, 38, - 38, 38, 38, 38, 0, 0, 40, 40, 40, 40, - 40, 40, 39, 39, 39, 39, 39, 39, 0, 0, - 41, 41, 41, 41, 41, 41, 26, 26, 26, 26, - 26, 26, 1, 5, 3, 2, 6, 7, 26, 26, - 26, 26, 26, 25, 25, 11, 0, 11, 0, 12, - 0, 9, 0, 11, 0, 11, 0, 10, 0, 0, - 11, 1, 5, 3, 2, 6, 7, 11, 8, 11, - 11, 11, 11, 37, 37, 37, 37, 37, 37, 37, - 37, 36, 0, 24, 0, 0, 36, 35, 35, 27, - - 35, 35, 35, 35, 35, 35, 28, 28, 27, 28, - 28, 28, 0, 24, 0, 0, 27, 0, 0, 0, - 0, 0, 27, 0, 0, 0, 38, 38, 27, 38, - 38, 38, 0, 0, 40, 40, 27, 40, 40, 40, - 39, 39, 27, 39, 39, 39, 0, 0, 41, 41, - 27, 41, 41, 41, 26, 24, 26, 26, 26, 26, - 26, 26, 34, 0, 11, 11, 8, 11, 11, 11, - 11, 11, 37, 37, 37, 37, 27, 37, 37, 37, - 24, 24, 0, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 28, 28, 28, 28, 28, 28, 24, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 38, 38, 38, 38, 38, 38, 0, 40, 0, - 40, 40, 40, 40, 40, 40, 39, 39, 39, 39, - 39, 39, 0, 41, 0, 41, 41, 41, 41, 41, - 41, 24, 24, 26, 26, 26, 26, 26, 26, 24, - 11, 11, 11, 11, 11, 11, 37, 37, 37, 37, - 37, 37, 37, 37, 0, 36, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 28, 28, 28, 28, 28, - 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 38, 38, 38, 38, 38, 38, 0, - - 40, 40, 40, 40, 40, 40, 40, 39, 39, 39, - 39, 39, 39, 0, 41, 41, 41, 41, 41, 41, - 41, 26, 26, 26, 26, 26, 26, 11, 11, 11, - 11, 11, 11, 37, 37, 37, 20, 37, 37, 37, - 37, 35, 35, 35, 21, 35, 35, 35, 23, 35, - 28, 28, 28, 28, 28, 28, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 38, 38, - 38, 38, 38, 38, 40, 40, 40, 40, 40, 40, - 39, 39, 39, 39, 39, 39, 41, 41, 41, 41, - 41, 41, 26, 26, 26, 26, 26, 26, 11, 11, - - 11, 11, 11, 11, 37, 37, 37, 19, 37, 37, - 37, 35, 35, 16, 35, 13, 15, 14, 28, 28, - 16, 13, 15, 14, 0, 0, 16, 13, 15, 14, - 0, 0, 16, 13, 15, 14, 38, 38, 16, 13, - 15, 14, 40, 40, 16, 13, 15, 14, 39, 39, - 16, 13, 15, 14, 41, 41, 16, 13, 15, 14, - 26, 26, 16, 13, 15, 14, 11, 11, 11, 11, - 11, 11, 37, 37, 16, 13, 15, 14, 35, 35, - 22, 28, 28, 0, 0, 0, 0, 38, 38, 40, - 40, 39, 39, 41, 41, 26, 26, 11, 11, 37, - - 37, 35, 35, 28, 28, 0, 0, 0, 0, 38, - 38, 40, 40, 39, 39, 41, 41, 26, 26, 11, - 11, 37, 37, 35, 17, 28, 17, 0, 17, 0, - 17, 38, 17, 40, 17, 39, 17, 41, 17, 26, - 17, 11, 11, 37, 17, 35, 28, 0, 0, 38, - 40, 39, 41, 26, 11, 37, 35, 28, 0, 0, - 38, 40, 39, 41, 26, 11, 37, 35, 28, 0, - 0, 38, 40, 39, 41, 26, 11, 37, 35, 28, - 0, 0, 38, 40, 39, 41, 26, 11, 37, 35, - 28, 0, 0, 38, 40, 39, 41, 26, 11, 37, - - 18, 18, 18, 18, 18, 18, 18, 18, 18, 11, - 18, 0 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 5, 6, 7, 1, 1, 8, 9, - 10, 1, 11, 12, 13, 14, 15, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 17, 1, 1, - 18, 1, 19, 1, 20, 20, 21, 20, 22, 23, - 20, 20, 24, 20, 20, 20, 20, 25, 26, 27, - 20, 28, 29, 30, 31, 20, 20, 32, 20, 20, - 33, 34, 35, 1, 36, 1, 37, 38, 39, 40, - - 41, 42, 20, 43, 44, 20, 45, 46, 20, 47, - 48, 49, 50, 51, 52, 53, 54, 20, 20, 55, - 56, 20, 57, 1, 58, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[59] = - { 0, - 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, - 5, 6, 5, 5, 5, 7, 1, 8, 1, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 10, 1, 11, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 1, 12 - } ; - -static yyconst flex_int16_t yy_base[847] = - { 0, - 0, 0, 58, 0, 115, 165, 215, 265, 316, 0, - 374, 0, 432, 0, 490, 0, 547, 604, 661, 711, - 762, 0, 2308, 2309, 2309, 2309, 2304, 0, 118, 2288, - 2287, 2286, 111, 2285, 116, 124, 120, 129, 131, 128, - 144, 139, 140, 0, 2270, 2261, 2259, 2252, 2257, 2280, - 137, 2309, 2279, 127, 183, 124, 171, 2277, 187, 179, - 126, 163, 158, 131, 173, 2309, 204, 2309, 2309, 2291, - 210, 2275, 2274, 2273, 197, 2272, 2257, 2248, 2246, 2239, - 2244, 2309, 0, 2252, 2243, 2241, 2234, 2239, 2222, 218, - 220, 221, 223, 224, 228, 236, 2309, 0, 2246, 2237, - - 2235, 2228, 2233, 2216, 233, 238, 240, 255, 263, 242, - 273, 2269, 2268, 2267, 2266, 283, 285, 289, 293, 287, - 294, 160, 210, 207, 147, 220, 297, 552, 560, 2265, - 565, 210, 569, 544, 580, 622, 627, 634, 623, 669, - 689, 819, 684, 702, 821, 823, 2309, 0, 2235, 266, - 2225, 2224, 2217, 2222, 2259, 2309, 548, 566, 581, 2309, - 2309, 2309, 2309, 2309, 2309, 2204, 568, 2225, 626, 610, - 640, 651, 699, 823, 678, 702, 0, 2232, 2218, 2215, - 550, 2206, 2238, 2309, 577, 2309, 261, 2251, 594, 830, - 2236, 2235, 2234, 2233, 2232, 575, 580, 634, 710, 599, - - 2245, 735, 2309, 2220, 2206, 2203, 703, 2194, 0, 2216, - 2202, 2199, 711, 2190, 0, 2182, 681, 827, 830, 831, - 826, 828, 0, 2211, 2197, 2194, 717, 2185, 0, 2177, - 740, 832, 834, 833, 853, 854, 2230, 2229, 2228, 2227, - 874, 840, 2226, 2225, 2224, 2223, 2222, 2221, 592, 254, - 651, 855, 833, 737, 2220, 877, 897, 898, 878, 2219, - 881, 883, 886, 905, 916, 920, 700, 859, 906, 925, - 936, 940, 941, 950, 955, 960, 964, 974, 2219, 975, - 983, 994, 995, 0, 2193, 2179, 2165, 2175, 2174, 718, - 2165, 883, 910, 934, 0, 2179, 2309, 979, 971, 940, - - 974, 954, 985, 999, 983, 1003, 2187, 968, 0, 2166, - 2170, 2156, 1017, 1036, 583, 1003, 2192, 996, 685, 917, - 2182, 998, 2309, 2161, 2165, 2151, 2178, 1001, 0, 2157, - 2161, 2147, 2142, 0, 1040, 1041, 946, 1042, 1045, 1043, - 2173, 1012, 0, 2152, 2156, 2142, 2137, 0, 1055, 1057, - 1060, 1061, 1062, 1064, 1074, 1087, 1067, 1069, 2191, 1080, - 1082, 687, 1090, 1094, 1103, 1112, 2191, 1111, 1125, 1127, - 1134, 1142, 2166, 1048, 2150, 2142, 0, 2143, 2147, 2133, - 1138, 2183, 2127, 1127, 1141, 1146, 1136, 1149, 1151, 1155, - 1156, 1158, 2156, 2146, 2145, 2127, 2129, 2135, 1164, 1087, - - 1006, 1135, 1132, 595, 912, 2150, 2140, 2139, 2121, 2123, - 2129, 2144, 2134, 2133, 2115, 2117, 2123, 2108, 1183, 2107, - 1185, 1190, 1191, 1192, 1200, 1204, 2136, 2126, 2125, 2107, - 2109, 2115, 2100, 1205, 2099, 1207, 1208, 1212, 1213, 1214, - 1222, 1168, 2153, 923, 1084, 1213, 1182, 1106, 1190, 1236, - 1250, 1251, 1252, 1266, 1267, 1271, 2127, 2117, 2116, 2101, - 2100, 2096, 2098, 2104, 2089, 1210, 1257, 1230, 1273, 1274, - 1275, 1276, 1284, 1286, 1288, 2116, 2098, 2092, 2103, 2098, - 2090, 1280, 1177, 1244, 1282, 1285, 1275, 2110, 2092, 2086, - 2097, 2092, 2084, 2104, 2086, 2080, 2091, 2086, 2078, 2070, - - 1296, 1306, 1323, 1324, 1325, 1327, 1328, 2097, 2079, 2073, - 2084, 2079, 2071, 2063, 1330, 1331, 1333, 1337, 1345, 1340, - 1346, 1347, 1309, 1259, 1351, 1354, 1356, 1370, 1385, 1394, - 1401, 1403, 1408, 2090, 2072, 2066, 0, 2076, 2076, 2071, - 2063, 1359, 1361, 1379, 1355, 1407, 1410, 1411, 1415, 1416, - 2077, 2072, 2066, 2069, 2056, 2067, 1398, 1343, 1408, 1404, - 643, 1409, 2071, 2066, 2060, 2063, 2050, 2061, 2065, 2060, - 2054, 2057, 2044, 2055, 1420, 1445, 1413, 1447, 1453, 1454, - 2059, 2053, 2047, 2049, 2032, 2043, 1455, 1459, 1460, 1461, - 1462, 1463, 1471, 1436, 1430, 1192, 1433, 1479, 1482, 1492, - - 1506, 1519, 1520, 1528, 2046, 2037, 2031, 0, 2033, 2016, - 2027, 1486, 1496, 1505, 1506, 1510, 1516, 1524, 2043, 2015, - 0, 0, 0, 0, 1281, 1517, 2043, 2041, 2036, 2034, - 2024, 1995, 2309, 2309, 2309, 2309, 2005, 1981, 0, 0, - 0, 0, 1538, 1528, 1530, 1534, 1537, 1540, 1981, 1957, - 0, 0, 0, 0, 1557, 1558, 1559, 1560, 1561, 1563, - 1568, 1547, 1988, 1959, 1955, 1948, 1580, 1581, 1582, 1590, - 1592, 1594, 1924, 1863, 0, 0, 0, 0, 1598, 1599, - 1600, 1875, 1859, 1350, 1584, 1803, 1792, 1801, 1790, 1603, - 1601, 1799, 1788, 1604, 1602, 1610, 1609, 1643, 1644, 1797, - - 1786, 1611, 1630, 1800, 1773, 1010, 1606, 1798, 1771, 1795, - 1768, 1640, 1646, 1793, 1766, 1648, 1649, 1614, 1379, 1667, - 1674, 1791, 1764, 1647, 1653, 1793, 0, 1352, 1796, 1791, - 2309, 1790, 0, 1677, 1652, 1789, 0, 1681, 1676, 1480, - 1805, 1685, 1702, 1786, 0, 1682, 1775, 1679, 1774, 1769, - 1696, 1768, 1698, 1688, 1715, 1765, 1706, 1765, 1472, 1763, - 1757, 1714, 1753, 1717, 1719, 1729, 1703, 1722, 1685, 1645, - 1604, 1546, 1726, 1466, 1733, 1635, 1752, 1403, 1739, 1349, - 1725, 1269, 1222, 1740, 1217, 1749, 1758, 1768, 1155, 1755, - 1148, 1481, 1096, 1001, 1761, 866, 1762, 1763, 1792, 834, - - 1768, 0, 742, 2309, 0, 1764, 0, 1778, 678, 1801, - 0, 2309, 1835, 1847, 1859, 1871, 1883, 550, 1892, 1898, - 1907, 1919, 1931, 1939, 1945, 1950, 1956, 1965, 1977, 1989, - 2001, 2013, 2025, 2033, 2039, 2043, 306, 304, 301, 2050, - 213, 2058, 136, 2066, 2074, 2082 - } ; - -static yyconst flex_int16_t yy_def[847] = - { 0, - 812, 1, 812, 3, 813, 813, 814, 814, 812, 9, - 812, 11, 812, 13, 812, 15, 815, 815, 816, 816, - 812, 21, 812, 812, 812, 812, 817, 818, 812, 812, - 812, 812, 812, 812, 819, 819, 819, 819, 819, 819, - 819, 819, 819, 820, 820, 820, 820, 820, 820, 821, - 821, 812, 821, 822, 821, 821, 821, 812, 821, 821, - 821, 821, 821, 821, 821, 812, 823, 812, 812, 817, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 824, 824, 824, 824, 824, 824, 812, 825, - 825, 825, 825, 825, 825, 825, 812, 826, 826, 826, - - 826, 826, 826, 812, 827, 827, 827, 827, 827, 827, - 827, 828, 828, 828, 829, 828, 828, 828, 828, 828, - 828, 828, 828, 828, 828, 828, 812, 830, 812, 812, - 830, 831, 832, 833, 830, 830, 830, 830, 830, 830, - 830, 830, 830, 830, 830, 830, 812, 834, 834, 834, - 834, 834, 834, 834, 817, 812, 835, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 819, 836, 819, 819, - 819, 819, 819, 819, 819, 819, 820, 820, 820, 820, - 820, 820, 821, 812, 821, 812, 822, 817, 821, 821, - 821, 821, 821, 821, 821, 821, 821, 821, 821, 821, - - 823, 823, 812, 812, 812, 812, 812, 812, 824, 824, - 824, 824, 824, 824, 837, 812, 825, 825, 825, 825, - 825, 825, 826, 826, 826, 826, 826, 826, 838, 812, - 827, 827, 827, 827, 827, 827, 828, 812, 829, 812, - 828, 828, 828, 828, 828, 828, 828, 828, 828, 828, - 828, 828, 828, 812, 812, 830, 830, 830, 812, 812, - 831, 831, 831, 832, 832, 832, 833, 833, 833, 830, - 830, 830, 830, 830, 830, 830, 830, 830, 812, 830, - 830, 830, 830, 834, 834, 834, 834, 834, 834, 834, - 834, 835, 812, 812, 839, 836, 812, 819, 819, 819, - - 819, 819, 819, 819, 819, 819, 820, 820, 820, 820, - 820, 820, 821, 821, 821, 821, 821, 821, 821, 821, - 812, 812, 812, 812, 812, 812, 824, 824, 824, 824, - 824, 824, 840, 841, 825, 825, 825, 825, 825, 825, - 826, 826, 826, 826, 826, 826, 842, 843, 827, 827, - 827, 827, 827, 827, 828, 828, 828, 828, 828, 828, - 828, 828, 830, 830, 830, 830, 812, 830, 830, 830, - 830, 830, 834, 834, 834, 834, 834, 834, 834, 834, - 812, 812, 844, 819, 819, 819, 819, 819, 819, 819, - 819, 819, 820, 820, 820, 820, 820, 820, 821, 821, - - 821, 821, 821, 821, 821, 812, 812, 812, 812, 812, - 812, 824, 824, 824, 824, 824, 824, 840, 825, 845, - 825, 825, 825, 825, 825, 825, 826, 826, 826, 826, - 826, 826, 842, 827, 846, 827, 827, 827, 827, 827, - 827, 828, 812, 828, 828, 828, 828, 828, 828, 830, - 830, 830, 830, 830, 830, 830, 834, 834, 834, 834, - 834, 834, 834, 834, 844, 835, 819, 819, 819, 819, - 819, 819, 819, 819, 819, 820, 820, 820, 820, 820, - 820, 821, 821, 821, 821, 821, 821, 812, 812, 812, - 812, 812, 812, 824, 824, 824, 824, 824, 824, 845, - - 825, 825, 825, 825, 825, 825, 825, 826, 826, 826, - 826, 826, 826, 846, 827, 827, 827, 827, 827, 827, - 827, 828, 828, 828, 828, 828, 828, 830, 830, 830, - 830, 830, 830, 834, 834, 834, 834, 834, 834, 834, - 834, 819, 819, 819, 819, 819, 819, 819, 819, 819, - 820, 820, 820, 820, 820, 820, 821, 821, 821, 821, - 821, 821, 812, 812, 812, 812, 812, 812, 824, 824, - 824, 824, 824, 824, 825, 825, 825, 825, 825, 825, - 826, 826, 826, 826, 826, 826, 827, 827, 827, 827, - 827, 827, 828, 828, 828, 828, 828, 828, 830, 830, - - 830, 830, 830, 830, 834, 834, 834, 834, 834, 834, - 834, 819, 819, 819, 819, 819, 819, 819, 820, 820, - 820, 820, 820, 820, 821, 821, 821, 821, 821, 821, - 812, 812, 812, 812, 812, 812, 824, 824, 824, 824, - 824, 824, 825, 825, 825, 825, 825, 825, 826, 826, - 826, 826, 826, 826, 827, 827, 827, 827, 827, 827, - 828, 828, 828, 828, 828, 828, 830, 830, 830, 830, - 830, 830, 834, 834, 834, 834, 834, 834, 819, 819, - 819, 820, 820, 821, 821, 812, 812, 824, 824, 825, - 825, 826, 826, 827, 827, 828, 828, 830, 830, 834, - - 834, 819, 819, 820, 820, 821, 821, 812, 812, 824, - 824, 825, 825, 826, 826, 827, 827, 828, 828, 830, - 830, 834, 834, 819, 819, 820, 820, 821, 821, 812, - 812, 824, 824, 825, 825, 826, 826, 827, 827, 828, - 828, 830, 830, 834, 834, 819, 820, 821, 812, 824, - 825, 826, 827, 828, 830, 834, 819, 820, 821, 812, - 824, 825, 826, 827, 828, 830, 834, 819, 820, 821, - 812, 824, 825, 826, 827, 828, 830, 834, 819, 820, - 821, 812, 824, 825, 826, 827, 828, 830, 834, 819, - 820, 821, 812, 824, 825, 826, 827, 828, 830, 834, - - 819, 820, 821, 812, 824, 825, 826, 827, 828, 830, - 834, 0, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812 - } ; - -static yyconst flex_int16_t yy_nxt[2368] = - { 0, - 24, 25, 26, 25, 24, 27, 28, 24, 29, 24, - 30, 24, 24, 31, 24, 24, 32, 33, 34, 35, - 35, 36, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 24, 24, 24, 35, 37, 35, 35, 38, - 39, 40, 35, 41, 35, 35, 35, 35, 42, 35, - 43, 35, 35, 35, 35, 35, 24, 24, 24, 25, - 26, 25, 24, 27, 24, 24, 29, 24, 30, 24, - 24, 31, 24, 24, 32, 33, 34, 44, 44, 45, - 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 24, 24, 24, 44, 46, 44, 44, 47, 44, 44, - - 44, 48, 44, 44, 44, 44, 44, 44, 49, 44, - 44, 44, 44, 44, 24, 24, 51, 52, 53, 158, - 54, 163, 166, 55, 164, 56, 166, 159, 57, 156, - 166, 58, 59, 60, 166, 166, 61, 166, 185, 186, - 184, 191, 184, 188, 435, 166, 166, 184, 168, 238, - 166, 62, 168, 184, 63, 169, 168, 196, 64, 170, - 168, 168, 238, 168, 173, 65, 51, 52, 53, 171, - 54, 168, 168, 55, 184, 56, 168, 199, 57, 184, - 176, 58, 59, 60, 189, 172, 61, 184, 192, 184, - 174, 249, 190, 252, 175, 184, 195, 193, 198, 184, - - 194, 62, 197, 184, 63, 202, 203, 163, 64, 238, - 164, 158, 238, 200, 262, 65, 67, 68, 69, 159, - 70, 420, 238, 71, 216, 72, 216, 216, 73, 216, - 216, 74, 75, 76, 216, 161, 77, 812, 812, 230, - 812, 812, 216, 263, 230, 812, 230, 251, 230, 250, - 161, 78, 218, 812, 79, 812, 238, 812, 80, 812, - 253, 230, 219, 156, 220, 81, 67, 68, 69, 230, - 70, 232, 812, 71, 221, 72, 222, 188, 73, 230, - 812, 74, 75, 76, 241, 238, 77, 238, 235, 238, - 812, 238, 242, 358, 233, 238, 238, 246, 254, 255, - - 247, 78, 243, 234, 79, 286, 244, 287, 80, 383, - 245, 248, 347, 236, 333, 81, 24, 25, 82, 25, - 24, 27, 24, 24, 29, 24, 30, 24, 24, 31, - 24, 24, 32, 33, 34, 83, 83, 84, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, 24, 24, - 24, 83, 85, 83, 83, 86, 83, 83, 83, 87, - 83, 83, 83, 83, 83, 83, 88, 83, 83, 83, - 83, 83, 24, 24, 24, 25, 26, 25, 24, 27, - 89, 24, 29, 24, 30, 24, 24, 90, 91, 24, - 32, 33, 34, 91, 91, 92, 91, 91, 91, 91, - - 91, 91, 91, 91, 91, 91, 24, 24, 24, 91, - 93, 91, 91, 94, 91, 91, 91, 95, 91, 91, - 91, 91, 91, 91, 96, 91, 91, 91, 91, 91, - 24, 24, 24, 25, 97, 25, 24, 27, 24, 24, - 29, 24, 30, 24, 24, 31, 24, 24, 32, 33, - 34, 98, 98, 99, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 24, 24, 24, 98, 100, 98, - 98, 101, 98, 98, 98, 102, 98, 98, 98, 98, - 98, 98, 103, 98, 98, 98, 98, 98, 24, 24, - 24, 25, 26, 25, 24, 27, 104, 24, 29, 24, - - 30, 24, 24, 105, 106, 24, 32, 33, 34, 106, - 106, 107, 106, 106, 106, 106, 106, 106, 106, 106, - 106, 106, 24, 24, 24, 106, 108, 106, 106, 109, - 106, 106, 106, 110, 106, 106, 106, 106, 106, 106, - 111, 106, 106, 106, 106, 106, 24, 24, 113, 114, - 113, 268, 115, 257, 166, 116, 257, 117, 157, 257, - 118, 259, 260, 119, 120, 121, 257, 158, 122, 257, - 265, 156, 257, 265, 166, 159, 265, 269, 185, 186, - 168, 270, 293, 123, 257, 258, 124, 257, 310, 271, - 125, 184, 311, 184, 238, 189, 184, 126, 258, 184, - - 168, 315, 266, 190, 127, 113, 114, 113, 400, 115, - 184, 184, 116, 258, 117, 184, 166, 118, 357, 316, - 119, 120, 121, 257, 257, 122, 257, 257, 257, 257, - 257, 257, 166, 275, 257, 257, 276, 294, 257, 272, - 123, 257, 168, 124, 273, 486, 166, 125, 320, 299, - 184, 274, 298, 238, 126, 258, 258, 166, 168, 184, - 258, 127, 129, 130, 131, 132, 133, 258, 134, 135, - 257, 136, 168, 257, 137, 317, 257, 138, 139, 140, - 238, 300, 141, 168, 166, 257, 277, 216, 257, 238, - 257, 257, 359, 257, 142, 629, 257, 143, 812, 301, - - 144, 184, 258, 257, 145, 166, 257, 268, 166, 257, - 168, 146, 129, 130, 131, 132, 133, 258, 134, 135, - 278, 136, 258, 280, 137, 404, 184, 138, 139, 140, - 305, 168, 141, 269, 168, 258, 202, 203, 254, 255, - 449, 324, 281, 302, 142, 325, 230, 143, 318, 330, - 144, 306, 319, 331, 145, 344, 378, 812, 184, 345, - 379, 146, 24, 25, 147, 25, 24, 27, 24, 24, - 29, 24, 30, 24, 24, 31, 24, 24, 32, 33, - 34, 148, 148, 149, 148, 148, 148, 148, 148, 148, - 148, 148, 148, 148, 24, 24, 24, 148, 150, 151, - - 148, 152, 148, 148, 148, 153, 148, 148, 148, 148, - 148, 148, 154, 148, 148, 148, 148, 148, 24, 24, - 257, 279, 257, 257, 257, 257, 257, 257, 257, 166, - 257, 313, 216, 216, 216, 238, 216, 216, 230, 230, - 230, 355, 238, 812, 812, 812, 184, 812, 812, 812, - 812, 812, 258, 335, 258, 168, 258, 238, 349, 230, - 230, 303, 811, 283, 338, 304, 268, 282, 339, 336, - 812, 812, 337, 350, 351, 241, 238, 340, 257, 259, - 260, 257, 362, 242, 257, 262, 314, 262, 261, 166, - 262, 352, 269, 360, 807, 353, 356, 361, 257, 257, - - 257, 257, 257, 354, 257, 257, 265, 156, 267, 265, - 258, 293, 265, 268, 263, 168, 263, 265, 156, 263, - 265, 265, 363, 265, 265, 238, 270, 265, 184, 257, - 258, 258, 257, 184, 271, 381, 382, 364, 266, 269, - 257, 257, 257, 257, 257, 257, 166, 257, 257, 266, - 522, 257, 216, 266, 257, 487, 257, 257, 258, 257, - 166, 257, 257, 812, 257, 257, 294, 257, 257, 258, - 405, 257, 168, 258, 258, 257, 257, 166, 257, 257, - 166, 257, 257, 258, 257, 166, 168, 257, 258, 166, - 257, 166, 365, 258, 388, 257, 257, 258, 257, 257, - - 366, 257, 257, 168, 384, 166, 168, 258, 258, 166, - 394, 168, 184, 385, 368, 168, 258, 168, 313, 184, - 395, 387, 184, 386, 369, 391, 184, 258, 258, 805, - 389, 168, 370, 184, 728, 168, 371, 399, 382, 390, - 407, 403, 483, 413, 372, 401, 216, 216, 216, 216, - 408, 216, 184, 414, 428, 402, 392, 812, 812, 812, - 812, 230, 812, 230, 429, 421, 230, 230, 230, 238, - 230, 238, 812, 314, 812, 355, 238, 812, 812, 812, - 436, 812, 238, 422, 238, 425, 238, 424, 442, 443, - 458, 257, 444, 423, 257, 364, 426, 257, 257, 437, - - 459, 257, 440, 184, 450, 382, 439, 257, 238, 438, - 257, 445, 257, 257, 482, 257, 257, 441, 257, 257, - 523, 446, 448, 258, 804, 447, 257, 258, 257, 257, - 356, 257, 257, 166, 257, 257, 258, 451, 257, 381, - 382, 257, 166, 257, 258, 258, 257, 166, 184, 257, - 365, 184, 166, 452, 467, 166, 526, 166, 258, 168, - 258, 166, 166, 453, 166, 399, 382, 258, 168, 442, - 443, 484, 454, 168, 455, 258, 802, 468, 168, 800, - 184, 168, 469, 168, 238, 485, 470, 168, 168, 216, - 168, 216, 238, 184, 238, 456, 216, 216, 216, 471, - - 812, 475, 812, 474, 472, 473, 216, 812, 812, 812, - 216, 230, 502, 230, 230, 238, 166, 812, 230, 230, - 230, 812, 812, 558, 812, 812, 503, 504, 230, 812, - 812, 812, 664, 527, 516, 525, 166, 450, 382, 812, - 257, 796, 168, 257, 517, 505, 794, 507, 518, 524, - 506, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 184, 238, 168, 166, 520, 521, 519, 257, 257, 258, - 257, 257, 257, 257, 257, 257, 543, 528, 257, 166, - 166, 166, 166, 258, 258, 258, 542, 529, 530, 168, - 166, 184, 166, 793, 166, 559, 184, 184, 184, 258, - - 258, 184, 216, 684, 258, 168, 168, 168, 168, 557, - 595, 238, 216, 812, 533, 547, 168, 532, 168, 531, - 168, 560, 546, 812, 544, 562, 545, 548, 561, 216, - 216, 216, 549, 216, 216, 575, 230, 230, 550, 230, - 812, 812, 812, 230, 812, 812, 230, 812, 812, 238, - 812, 230, 230, 238, 812, 594, 238, 812, 238, 184, - 587, 166, 812, 812, 578, 166, 184, 166, 184, 576, - 579, 257, 748, 791, 257, 577, 593, 257, 580, 588, - 706, 238, 626, 591, 590, 166, 257, 168, 589, 257, - 596, 168, 257, 168, 612, 257, 592, 597, 257, 599, - - 613, 257, 257, 258, 257, 257, 598, 257, 257, 257, - 257, 168, 257, 166, 184, 257, 166, 166, 258, 216, - 184, 166, 166, 614, 184, 184, 216, 258, 789, 741, - 812, 600, 238, 625, 258, 238, 258, 812, 238, 168, - 602, 258, 168, 168, 628, 601, 603, 168, 168, 630, - 616, 216, 627, 216, 615, 643, 618, 645, 604, 216, - 216, 230, 812, 617, 812, 230, 230, 230, 230, 230, - 812, 812, 812, 238, 663, 662, 812, 812, 812, 812, - 812, 238, 238, 257, 644, 665, 257, 646, 184, 257, - 655, 785, 166, 257, 648, 770, 257, 184, 656, 257, - - 754, 658, 166, 660, 657, 647, 661, 257, 679, 803, - 257, 166, 166, 257, 659, 258, 166, 667, 168, 666, - 257, 257, 166, 257, 257, 258, 257, 257, 168, 257, - 166, 668, 257, 184, 216, 257, 216, 168, 168, 258, - 216, 680, 168, 216, 216, 812, 216, 812, 168, 238, - 669, 812, 258, 258, 812, 812, 168, 812, 681, 670, - 690, 258, 685, 230, 230, 230, 230, 230, 672, 230, - 238, 783, 671, 691, 812, 812, 812, 812, 812, 694, - 812, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 696, 257, 697, 257, 257, 257, 257, 257, 257, 257, - - 184, 257, 698, 695, 166, 166, 166, 216, 230, 216, - 230, 238, 238, 258, 258, 258, 238, 166, 812, 812, - 812, 812, 184, 258, 707, 258, 699, 258, 702, 782, - 168, 168, 168, 712, 716, 724, 166, 238, 740, 703, - 718, 713, 717, 168, 257, 257, 216, 257, 257, 719, - 257, 257, 216, 166, 230, 230, 729, 812, 216, 166, - 787, 184, 168, 812, 734, 812, 812, 746, 257, 812, - 781, 257, 738, 720, 257, 257, 258, 258, 257, 168, - 725, 257, 230, 216, 721, 168, 257, 230, 166, 257, - 238, 742, 257, 812, 812, 184, 735, 751, 812, 739, - - 258, 753, 216, 257, 230, 755, 257, 258, 759, 257, - 780, 757, 166, 812, 168, 812, 257, 765, 258, 257, - 216, 238, 257, 230, 743, 762, 778, 764, 166, 768, - 257, 812, 216, 257, 812, 258, 257, 773, 168, 230, - 775, 184, 776, 812, 766, 166, 216, 779, 258, 792, - 812, 784, 777, 257, 168, 230, 257, 812, 786, 257, - 238, 166, 258, 790, 795, 238, 812, 216, 230, 257, - 216, 168, 257, 797, 166, 257, 774, 788, 812, 812, - 772, 812, 798, 801, 230, 258, 771, 168, 769, 806, - 808, 809, 799, 257, 767, 812, 257, 763, 761, 257, - - 168, 258, 257, 760, 758, 257, 756, 238, 257, 752, - 750, 749, 184, 747, 745, 744, 737, 736, 733, 732, - 810, 731, 730, 727, 726, 258, 723, 722, 715, 714, - 711, 710, 709, 708, 258, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 66, 66, 66, - 66, 66, 66, 66, 66, 66, 66, 66, 66, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 155, 155, 155, 155, 155, 155, 155, - 155, 155, 155, 155, 155, 167, 167, 167, 167, 705, - - 167, 167, 177, 177, 177, 704, 177, 183, 701, 183, - 183, 183, 183, 183, 183, 183, 183, 183, 183, 187, - 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, - 187, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 209, 209, 209, 700, 209, 217, 217, - 238, 217, 217, 217, 223, 223, 223, 238, 223, 231, - 231, 238, 231, 231, 231, 237, 237, 237, 237, 237, - 237, 237, 237, 237, 237, 237, 237, 239, 239, 239, - 239, 239, 239, 239, 239, 239, 239, 239, 239, 256, - 238, 256, 256, 256, 256, 256, 256, 256, 256, 256, - - 256, 261, 693, 692, 261, 261, 261, 261, 261, 261, - 261, 261, 261, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 267, 689, 688, 267, 267, - 267, 267, 267, 267, 267, 267, 267, 284, 284, 284, - 687, 284, 292, 292, 292, 292, 686, 292, 292, 296, - 184, 296, 184, 296, 418, 418, 418, 184, 418, 184, - 683, 418, 433, 433, 433, 682, 433, 678, 677, 433, - 465, 465, 465, 676, 465, 675, 674, 465, 500, 500, - 500, 673, 500, 654, 653, 500, 514, 514, 514, 652, - 514, 651, 650, 514, 649, 642, 641, 640, 639, 638, - - 637, 636, 635, 634, 633, 632, 631, 624, 623, 622, - 621, 620, 619, 611, 610, 609, 608, 607, 606, 605, - 515, 586, 585, 584, 583, 582, 581, 501, 574, 573, - 572, 571, 570, 569, 568, 567, 566, 565, 564, 563, - 556, 555, 554, 553, 552, 551, 466, 541, 540, 539, - 538, 537, 536, 535, 534, 443, 515, 434, 513, 512, - 511, 510, 509, 508, 501, 419, 499, 498, 497, 496, - 495, 494, 493, 492, 491, 490, 489, 488, 481, 480, - 479, 478, 477, 476, 466, 382, 464, 463, 462, 461, - 460, 457, 367, 238, 434, 432, 431, 430, 427, 419, - - 417, 416, 415, 412, 411, 410, 409, 406, 184, 398, - 397, 396, 393, 297, 380, 377, 376, 375, 374, 373, - 367, 260, 255, 238, 238, 238, 238, 238, 238, 238, - 240, 238, 238, 348, 346, 343, 342, 341, 334, 332, - 329, 328, 327, 326, 323, 322, 321, 203, 184, 184, - 184, 184, 184, 156, 184, 312, 309, 308, 307, 297, - 295, 156, 291, 290, 289, 288, 285, 260, 240, 238, - 238, 238, 229, 228, 227, 226, 225, 224, 215, 214, - 213, 212, 211, 210, 208, 207, 206, 205, 204, 165, - 162, 161, 160, 156, 162, 184, 184, 182, 181, 180, - - 179, 178, 165, 162, 161, 160, 156, 812, 23, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812 - } ; - -static yyconst flex_int16_t yy_chk[2368] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 5, 5, 5, 29, - 5, 33, 35, 5, 33, 5, 37, 29, 5, 54, - 36, 5, 5, 5, 40, 38, 5, 39, 51, 51, - 56, 56, 61, 54, 843, 42, 43, 64, 35, 125, - 41, 5, 37, 51, 5, 36, 36, 61, 5, 37, - 40, 38, 122, 39, 40, 5, 6, 6, 6, 38, - 6, 42, 43, 6, 63, 6, 41, 64, 6, 62, - 43, 6, 6, 6, 55, 39, 6, 57, 57, 65, - 41, 122, 55, 125, 42, 60, 60, 59, 63, 55, - - 59, 6, 62, 59, 6, 67, 67, 75, 6, 124, - 75, 71, 123, 65, 132, 6, 7, 7, 7, 71, - 7, 841, 126, 7, 90, 7, 91, 92, 7, 93, - 94, 7, 7, 7, 95, 90, 7, 91, 92, 105, - 93, 94, 96, 132, 106, 95, 107, 124, 110, 123, - 105, 7, 92, 96, 7, 106, 250, 107, 7, 110, - 126, 108, 93, 187, 94, 7, 8, 8, 8, 109, - 8, 107, 108, 8, 95, 8, 96, 187, 8, 111, - 109, 8, 8, 8, 116, 116, 8, 117, 110, 120, - 111, 118, 116, 250, 108, 119, 121, 120, 127, 127, - - 120, 8, 117, 109, 8, 150, 118, 150, 8, 839, - 119, 121, 838, 111, 837, 8, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 17, 17, - 17, 134, 17, 128, 157, 17, 128, 17, 818, 128, - 17, 129, 129, 17, 17, 17, 131, 158, 17, 131, - 133, 133, 131, 133, 167, 158, 133, 134, 185, 185, - 157, 135, 159, 17, 135, 128, 17, 135, 181, 135, - 17, 196, 181, 185, 249, 189, 197, 17, 131, 315, - - 167, 196, 133, 189, 17, 18, 18, 18, 315, 18, - 189, 404, 18, 135, 18, 200, 170, 18, 249, 197, - 18, 18, 18, 136, 139, 18, 136, 139, 137, 136, - 139, 137, 169, 139, 137, 138, 139, 159, 138, 136, - 18, 138, 170, 18, 137, 404, 171, 18, 200, 170, - 198, 138, 169, 251, 18, 136, 139, 172, 169, 561, - 137, 18, 19, 19, 19, 19, 19, 138, 19, 19, - 140, 19, 171, 140, 19, 198, 140, 19, 19, 19, - 809, 171, 19, 172, 175, 143, 140, 217, 143, 362, - 141, 143, 251, 141, 19, 561, 141, 19, 217, 172, - - 19, 319, 140, 144, 19, 173, 144, 267, 176, 144, - 175, 19, 20, 20, 20, 20, 20, 143, 20, 20, - 141, 20, 141, 143, 20, 319, 199, 20, 20, 20, - 175, 173, 20, 267, 176, 144, 202, 202, 254, 254, - 362, 207, 144, 173, 20, 207, 231, 20, 199, 213, - 20, 176, 199, 213, 20, 227, 290, 231, 803, 227, - 290, 20, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 142, 142, 145, 142, 146, 145, 142, 146, 145, 174, - 146, 190, 221, 218, 222, 253, 219, 220, 232, 234, - 233, 242, 242, 221, 218, 222, 190, 219, 220, 232, - 234, 233, 142, 218, 145, 174, 146, 252, 232, 235, - 236, 174, 800, 146, 221, 174, 268, 145, 221, 219, - 235, 236, 220, 233, 234, 241, 241, 222, 256, 259, - 259, 256, 253, 241, 256, 261, 190, 262, 263, 292, - 263, 235, 268, 252, 796, 235, 242, 252, 257, 258, - - 258, 257, 258, 236, 257, 258, 264, 264, 269, 264, - 256, 293, 264, 269, 261, 292, 262, 265, 265, 263, - 265, 266, 266, 265, 266, 444, 270, 266, 405, 270, - 257, 258, 270, 320, 270, 294, 294, 271, 264, 269, - 271, 272, 273, 271, 272, 273, 300, 272, 273, 265, - 444, 274, 337, 266, 274, 405, 275, 274, 270, 275, - 302, 276, 275, 337, 276, 277, 293, 276, 277, 271, - 320, 277, 300, 272, 273, 278, 280, 299, 278, 280, - 301, 278, 280, 274, 281, 298, 302, 281, 275, 305, - 281, 303, 271, 276, 302, 282, 283, 277, 282, 283, - - 278, 282, 283, 299, 298, 304, 301, 278, 280, 306, - 308, 298, 318, 299, 280, 305, 281, 303, 313, 316, - 308, 301, 401, 299, 281, 305, 706, 282, 283, 794, - 303, 304, 282, 313, 706, 306, 282, 314, 314, 304, - 322, 318, 401, 328, 283, 316, 335, 336, 338, 340, - 322, 339, 314, 328, 342, 316, 306, 335, 336, 338, - 340, 349, 339, 350, 342, 335, 351, 352, 353, 357, - 354, 358, 349, 313, 350, 355, 355, 351, 352, 353, - 349, 354, 360, 336, 361, 339, 445, 338, 356, 356, - 374, 363, 357, 336, 363, 364, 340, 363, 364, 350, - - 374, 364, 353, 400, 365, 365, 352, 365, 448, 350, - 365, 358, 368, 366, 400, 368, 366, 354, 368, 366, - 445, 358, 361, 363, 793, 360, 369, 364, 370, 369, - 355, 370, 369, 384, 370, 371, 365, 366, 371, 381, - 381, 371, 387, 372, 368, 366, 372, 385, 403, 372, - 364, 402, 386, 368, 384, 388, 448, 389, 369, 384, - 370, 390, 391, 368, 392, 399, 399, 371, 387, 442, - 442, 402, 370, 385, 371, 372, 791, 385, 386, 789, - 399, 388, 386, 389, 447, 403, 387, 390, 391, 419, - 392, 421, 449, 483, 596, 372, 422, 423, 424, 388, - - 419, 392, 421, 391, 389, 390, 425, 422, 423, 424, - 426, 434, 421, 436, 437, 446, 466, 425, 438, 439, - 440, 426, 434, 483, 436, 437, 422, 423, 441, 438, - 439, 440, 596, 449, 436, 447, 468, 450, 450, 441, - 450, 785, 466, 450, 437, 424, 783, 426, 438, 446, - 425, 451, 452, 453, 451, 452, 453, 451, 452, 453, - 484, 524, 468, 467, 440, 441, 439, 454, 455, 450, - 454, 455, 456, 454, 455, 456, 468, 451, 456, 469, - 470, 471, 472, 451, 452, 453, 467, 452, 453, 467, - 473, 487, 474, 782, 475, 484, 482, 625, 485, 454, - - 455, 486, 501, 625, 456, 469, 470, 471, 472, 482, - 524, 523, 502, 501, 456, 472, 473, 455, 474, 454, - 475, 485, 471, 502, 469, 487, 470, 473, 486, 503, - 504, 505, 474, 506, 507, 502, 515, 516, 475, 517, - 503, 504, 505, 518, 506, 507, 520, 515, 516, 522, - 517, 519, 521, 525, 518, 523, 526, 520, 527, 558, - 516, 545, 519, 521, 505, 542, 684, 543, 728, 503, - 506, 528, 728, 780, 528, 504, 522, 528, 507, 517, - 684, 719, 558, 520, 519, 544, 529, 545, 518, 529, - 525, 542, 529, 543, 542, 530, 521, 526, 530, 528, - - 543, 530, 531, 528, 532, 531, 527, 532, 531, 533, - 532, 544, 533, 546, 557, 533, 547, 548, 529, 577, - 560, 549, 550, 544, 559, 562, 575, 530, 778, 719, - 577, 529, 595, 557, 531, 597, 532, 575, 594, 546, - 531, 533, 547, 548, 560, 530, 532, 549, 550, 562, - 547, 576, 559, 578, 546, 575, 550, 577, 533, 579, - 580, 587, 576, 548, 578, 588, 589, 590, 591, 592, - 579, 580, 587, 593, 595, 594, 588, 589, 590, 591, - 592, 598, 740, 599, 576, 597, 599, 578, 759, 599, - 587, 774, 612, 600, 580, 759, 600, 792, 588, 600, - - 740, 590, 613, 592, 589, 579, 593, 601, 612, 792, - 601, 614, 615, 601, 591, 599, 616, 599, 612, 598, - 602, 603, 617, 602, 603, 600, 602, 603, 613, 604, - 618, 600, 604, 626, 644, 604, 645, 614, 615, 601, - 646, 613, 616, 647, 643, 644, 648, 645, 617, 662, - 601, 646, 602, 603, 647, 643, 618, 648, 615, 602, - 643, 604, 626, 655, 656, 657, 658, 659, 604, 660, - 661, 772, 603, 644, 655, 656, 657, 658, 659, 655, - 660, 667, 668, 669, 667, 668, 669, 667, 668, 669, - 661, 670, 662, 671, 670, 672, 671, 670, 672, 671, - - 685, 672, 667, 656, 679, 680, 681, 691, 695, 690, - 694, 697, 696, 667, 668, 669, 718, 702, 691, 695, - 690, 694, 707, 670, 685, 671, 668, 672, 679, 771, - 679, 680, 681, 690, 694, 702, 703, 776, 718, 680, - 696, 691, 695, 702, 698, 699, 712, 698, 699, 697, - 698, 699, 713, 724, 716, 717, 707, 712, 735, 725, - 776, 770, 703, 713, 712, 716, 717, 724, 720, 735, - 770, 720, 716, 698, 720, 721, 698, 699, 721, 724, - 703, 721, 739, 734, 699, 725, 742, 738, 746, 742, - 754, 720, 742, 739, 734, 748, 713, 734, 738, 717, - - 720, 738, 751, 743, 753, 742, 743, 721, 748, 743, - 769, 746, 757, 751, 746, 753, 755, 754, 742, 755, - 762, 765, 755, 764, 721, 751, 767, 753, 768, 757, - 766, 762, 773, 766, 764, 743, 766, 762, 757, 775, - 764, 781, 765, 773, 755, 779, 784, 768, 755, 781, - 775, 773, 766, 777, 768, 786, 777, 784, 775, 777, - 787, 790, 766, 779, 784, 798, 786, 795, 797, 788, - 806, 779, 788, 786, 801, 788, 763, 777, 795, 797, - 761, 806, 787, 790, 808, 777, 760, 790, 758, 795, - 797, 798, 788, 799, 756, 808, 799, 752, 750, 799, - - 801, 788, 810, 749, 747, 810, 744, 741, 810, 736, - 732, 730, 729, 726, 723, 722, 715, 714, 711, 710, - 799, 709, 708, 705, 704, 799, 701, 700, 693, 692, - 689, 688, 687, 686, 810, 813, 813, 813, 813, 813, - 813, 813, 813, 813, 813, 813, 813, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 815, - 815, 815, 815, 815, 815, 815, 815, 815, 815, 815, - 815, 816, 816, 816, 816, 816, 816, 816, 816, 816, - 816, 816, 816, 817, 817, 817, 817, 817, 817, 817, - 817, 817, 817, 817, 817, 819, 819, 819, 819, 683, - - 819, 819, 820, 820, 820, 682, 820, 821, 674, 821, - 821, 821, 821, 821, 821, 821, 821, 821, 821, 822, - 822, 822, 822, 822, 822, 822, 822, 822, 822, 822, - 822, 823, 823, 823, 823, 823, 823, 823, 823, 823, - 823, 823, 823, 824, 824, 824, 673, 824, 825, 825, - 666, 825, 825, 825, 826, 826, 826, 665, 826, 827, - 827, 664, 827, 827, 827, 828, 828, 828, 828, 828, - 828, 828, 828, 828, 828, 828, 828, 829, 829, 829, - 829, 829, 829, 829, 829, 829, 829, 829, 829, 830, - 663, 830, 830, 830, 830, 830, 830, 830, 830, 830, - - 830, 831, 650, 649, 831, 831, 831, 831, 831, 831, - 831, 831, 831, 832, 832, 832, 832, 832, 832, 832, - 832, 832, 832, 832, 832, 833, 638, 637, 833, 833, - 833, 833, 833, 833, 833, 833, 833, 834, 834, 834, - 632, 834, 835, 835, 835, 835, 631, 835, 835, 836, - 630, 836, 629, 836, 840, 840, 840, 628, 840, 627, - 620, 840, 842, 842, 842, 619, 842, 611, 610, 842, - 844, 844, 844, 609, 844, 607, 606, 844, 845, 845, - 845, 605, 845, 586, 585, 845, 846, 846, 846, 584, - 846, 583, 582, 846, 581, 574, 573, 572, 571, 570, - - 569, 568, 567, 566, 565, 564, 563, 556, 555, 554, - 553, 552, 551, 541, 540, 539, 538, 536, 535, 534, - 514, 513, 512, 511, 510, 509, 508, 500, 499, 498, - 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, - 481, 480, 479, 478, 477, 476, 465, 464, 463, 462, - 461, 460, 459, 458, 457, 443, 435, 433, 432, 431, - 430, 429, 428, 427, 420, 418, 417, 416, 415, 414, - 413, 412, 411, 410, 409, 408, 407, 406, 398, 397, - 396, 395, 394, 393, 383, 382, 380, 379, 378, 376, - 375, 373, 367, 359, 347, 346, 345, 344, 341, 333, - - 332, 331, 330, 327, 326, 325, 324, 321, 317, 312, - 311, 310, 307, 296, 291, 289, 288, 287, 286, 285, - 279, 260, 255, 248, 247, 246, 245, 244, 243, 240, - 239, 238, 237, 230, 228, 226, 225, 224, 216, 214, - 212, 211, 210, 208, 206, 205, 204, 201, 195, 194, - 193, 192, 191, 188, 183, 182, 180, 179, 178, 168, - 166, 155, 154, 153, 152, 151, 149, 130, 115, 114, - 113, 112, 104, 103, 102, 101, 100, 99, 89, 88, - 87, 86, 85, 84, 81, 80, 79, 78, 77, 76, - 74, 73, 72, 70, 58, 53, 50, 49, 48, 47, - - 46, 45, 34, 32, 31, 30, 27, 23, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812 - } ; - -/* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[48] = - { 0, -0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 0, 0, }; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "bitbakescanner.l" -/* bbf.flex - - written by Marc Singer - 6 January 2005 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. - - DESCRIPTION - ----------- - - flex lexer specification for a BitBake input file parser. - - Unfortunately, flex doesn't welcome comments within the rule sets. - I say unfortunately because this lexer is unreasonably complex and - comments would make the code much easier to comprehend. - - The BitBake grammar is not regular. In order to interpret all - of the available input files, the lexer maintains much state as it - parses. There are places where this lexer will emit tokens that - are invalid. The parser will tend to catch these. - - The lexer requires C++ at the moment. The only reason for this has - to do with a very small amount of managed state. Producing a C - lexer should be a reasonably easy task as long as the %reentrant - option is used. - - - NOTES - ----- - - o RVALUES. There are three kinds of RVALUES. There are unquoted - values, double quote enclosed strings, and single quote - strings. Quoted strings may contain unescaped quotes (of either - type), *and* any type may span more than one line by using a - continuation '\' at the end of the line. This requires us to - recognize all types of values with a single expression. - Moreover, the only reason to quote a value is to include - trailing or leading whitespace. Whitespace within a value is - preserved, ugh. - - o CLASSES. C_ patterns define classes. Classes ought not include - a repitition operator, instead letting the reference to the class - define the repitition count. - - C_SS - symbol start - C_SB - symbol body - C_SP - whitespace - -*/ -#line 71 "bitbakescanner.l" - -#include "token.h" -#include "lexer.h" -#include "bitbakeparser.h" -#include <ctype.h> - -extern void *bbparseAlloc(void *(*mallocProc)(size_t)); -extern void bbparseFree(void *p, void (*freeProc)(void*)); -extern void *bbparseAlloc(void *(*mallocProc)(size_t)); -extern void *bbparse(void*, int, token_t, lex_t*); -extern void bbparseTrace(FILE *TraceFILE, char *zTracePrompt); - -//static const char* rgbInput; -//static size_t cbInput; - -extern "C" { - -int lineError; -int errorParse; - -enum { - errorNone = 0, - errorUnexpectedInput, - errorUnsupportedFeature, -}; - -} - -#define YY_EXTRA_TYPE lex_t* - - /* Read from buffer */ -#define YY_INPUT(buf,result,max_size) \ - { yyextra->input(buf, &result, max_size); } - -//#define YY_DECL static size_t yylex () - -#define ERROR(e) \ - do { lineError = yylineno; errorParse = e; yyterminate (); } while (0) - -static const char* fixup_escapes (const char* sz); - - - - - - - - - - - -#line 1367 "<stdout>" - -#define INITIAL 0 -#define S_DEF 1 -#define S_DEF_ARGS 2 -#define S_DEF_BODY 3 -#define S_FUNC 4 -#define S_INCLUDE 5 -#define S_INHERIT 6 -#define S_REQUIRE 7 -#define S_PROC 8 -#define S_RVALUE 9 -#define S_TASK 10 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include <unistd.h> -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t - { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - }; /* end struct yyguts_t */ - -static int yy_init_globals (yyscan_t yyscanner ); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy (yyscan_t yyscanner ); - -int yyget_debug (yyscan_t yyscanner ); - -void yyset_debug (int debug_flag ,yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner ); - -void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); - -FILE *yyget_in (yyscan_t yyscanner ); - -void yyset_in (FILE * in_str ,yyscan_t yyscanner ); - -FILE *yyget_out (yyscan_t yyscanner ); - -void yyset_out (FILE * out_str ,yyscan_t yyscanner ); - -int yyget_leng (yyscan_t yyscanner ); - -char *yyget_text (yyscan_t yyscanner ); - -int yyget_lineno (yyscan_t yyscanner ); - -void yyset_lineno (int line_number ,yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (yyscan_t yyscanner ); -#else -extern int yywrap (yyscan_t yyscanner ); -#endif -#endif - - static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (yyscan_t yyscanner ); -#else -static int input (yyscan_t yyscanner ); -#endif - -#endif - - static void yy_push_state (int new_state ,yyscan_t yyscanner); - - static void yy_pop_state (yyscan_t yyscanner ); - - static int yy_top_state (yyscan_t yyscanner ); - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (yyscan_t yyscanner); - -#define YY_DECL int yylex (yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - -#line 164 "bitbakescanner.l" - - -#line 1603 "<stdout>" - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - yy_load_buffer_state(yyscanner ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 813 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_current_state != 812 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - - if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) - { - int yyl; - for ( yyl = 0; yyl < yyleng; ++yyl ) - if ( yytext[yyl] == '\n' ) - - do{ yylineno++; - yycolumn=0; - }while(0) -; - } - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 166 "bitbakescanner.l" -{ BEGIN S_RVALUE; - yyextra->accept (T_OP_APPEND); } - YY_BREAK -case 2: -YY_RULE_SETUP -#line 168 "bitbakescanner.l" -{ BEGIN S_RVALUE; - yyextra->accept (T_OP_PREPEND); } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 170 "bitbakescanner.l" -{ BEGIN S_RVALUE; - yyextra->accept (T_OP_IMMEDIATE); } - YY_BREAK -case 4: -YY_RULE_SETUP -#line 172 "bitbakescanner.l" -{ BEGIN S_RVALUE; - yyextra->accept (T_OP_ASSIGN); } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 174 "bitbakescanner.l" -{ BEGIN S_RVALUE; - yyextra->accept (T_OP_PREDOT); } - YY_BREAK -case 6: -YY_RULE_SETUP -#line 176 "bitbakescanner.l" -{ BEGIN S_RVALUE; - yyextra->accept (T_OP_POSTDOT); } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 178 "bitbakescanner.l" -{ BEGIN S_RVALUE; - yyextra->accept (T_OP_COND); } - YY_BREAK -case 8: -/* rule 8 can match eol */ -YY_RULE_SETUP -#line 181 "bitbakescanner.l" -{ } - YY_BREAK -case 9: -/* rule 9 can match eol */ -YY_RULE_SETUP -#line 182 "bitbakescanner.l" -{ BEGIN INITIAL; - size_t cb = yyleng; - while (cb && isspace (yytext[cb - 1])) - --cb; - yytext[cb - 1] = 0; - yyextra->accept (T_STRING, yytext + 1); } - YY_BREAK -case 10: -/* rule 10 can match eol */ -YY_RULE_SETUP -#line 188 "bitbakescanner.l" -{ BEGIN INITIAL; - size_t cb = yyleng; - while (cb && isspace (yytext[cb - 1])) - --cb; - yytext[cb - 1] = 0; - yyextra->accept (T_STRING, yytext + 1); } - YY_BREAK -case 11: -/* rule 11 can match eol */ -YY_RULE_SETUP -#line 195 "bitbakescanner.l" -{ ERROR (errorUnexpectedInput); } - YY_BREAK -case 12: -/* rule 12 can match eol */ -YY_RULE_SETUP -#line 196 "bitbakescanner.l" -{ BEGIN INITIAL; - yyextra->accept (T_STRING, NULL); } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 199 "bitbakescanner.l" -{ BEGIN S_INCLUDE; - yyextra->accept (T_INCLUDE); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 201 "bitbakescanner.l" -{ BEGIN S_REQUIRE; - yyextra->accept (T_REQUIRE); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 203 "bitbakescanner.l" -{ BEGIN S_INHERIT; - yyextra->accept (T_INHERIT); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 205 "bitbakescanner.l" -{ BEGIN S_TASK; - yyextra->accept (T_ADDTASK); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 207 "bitbakescanner.l" -{ yyextra->accept (T_ADDHANDLER); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 208 "bitbakescanner.l" -{ BEGIN S_FUNC; - yyextra->accept (T_EXPORT_FUNC); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 210 "bitbakescanner.l" -{ yyextra->accept (T_BEFORE); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 211 "bitbakescanner.l" -{ yyextra->accept (T_AFTER); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 212 "bitbakescanner.l" -{ yyextra->accept (T_EXPORT); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 214 "bitbakescanner.l" -{ yyextra->accept (T_FAKEROOT); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 215 "bitbakescanner.l" -{ yyextra->accept (T_PYTHON); } - YY_BREAK -case 24: -/* rule 24 can match eol */ -YY_RULE_SETUP -#line 216 "bitbakescanner.l" -{ BEGIN S_PROC; - yyextra->accept (T_PROC_OPEN); } - YY_BREAK -case 25: -/* rule 25 can match eol */ -YY_RULE_SETUP -#line 218 "bitbakescanner.l" -{ BEGIN INITIAL; - yyextra->accept (T_PROC_CLOSE); } - YY_BREAK -case 26: -/* rule 26 can match eol */ -YY_RULE_SETUP -#line 220 "bitbakescanner.l" -{ yyextra->accept (T_PROC_BODY, yytext); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 222 "bitbakescanner.l" -{ BEGIN S_DEF; } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 223 "bitbakescanner.l" -{ BEGIN S_DEF_ARGS; - yyextra->accept (T_SYMBOL, yytext); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 225 "bitbakescanner.l" -{ yyextra->accept (T_DEF_ARGS, yytext); } - YY_BREAK -case 30: -/* rule 30 can match eol */ -YY_RULE_SETUP -#line 226 "bitbakescanner.l" -{ BEGIN S_DEF_BODY; } - YY_BREAK -case 31: -/* rule 31 can match eol */ -YY_RULE_SETUP -#line 227 "bitbakescanner.l" -{ yyextra->accept (T_DEF_BODY, yytext); } - YY_BREAK -case 32: -/* rule 32 can match eol */ -YY_RULE_SETUP -#line 228 "bitbakescanner.l" -{ yyextra->accept (T_DEF_BODY, yytext); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 229 "bitbakescanner.l" -{ BEGIN INITIAL; unput (yytext[0]); } - YY_BREAK -case 34: -/* rule 34 can match eol */ -YY_RULE_SETUP -#line 231 "bitbakescanner.l" -{ } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 233 "bitbakescanner.l" -{ yyextra->accept (T_SYMBOL, yytext); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 234 "bitbakescanner.l" -{ yyextra->accept (T_VARIABLE, yytext); } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 236 "bitbakescanner.l" -{ yyextra->accept (T_TSYMBOL, yytext); } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 237 "bitbakescanner.l" -{ yyextra->accept (T_FSYMBOL, yytext); } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 238 "bitbakescanner.l" -{ yyextra->accept (T_ISYMBOL, yytext); } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 239 "bitbakescanner.l" -{ BEGIN INITIAL; - yyextra->accept (T_ISYMBOL, yytext); } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 241 "bitbakescanner.l" -{ BEGIN INITIAL; - yyextra->accept (T_ISYMBOL, yytext); } - YY_BREAK -case 42: -/* rule 42 can match eol */ -YY_RULE_SETUP -#line 243 "bitbakescanner.l" -{ BEGIN INITIAL; } - YY_BREAK -case 43: -/* rule 43 can match eol */ -YY_RULE_SETUP -#line 244 "bitbakescanner.l" -{ BEGIN INITIAL; } - YY_BREAK -case 44: -/* rule 44 can match eol */ -YY_RULE_SETUP -#line 245 "bitbakescanner.l" -{ BEGIN INITIAL; } - YY_BREAK -case 45: -/* rule 45 can match eol */ -YY_RULE_SETUP -#line 247 "bitbakescanner.l" -/* Insignificant whitespace */ - YY_BREAK -case 46: -YY_RULE_SETUP -#line 249 "bitbakescanner.l" -{ ERROR (errorUnexpectedInput); } - YY_BREAK -/* Check for premature termination */ -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(S_DEF): -case YY_STATE_EOF(S_DEF_ARGS): -case YY_STATE_EOF(S_DEF_BODY): -case YY_STATE_EOF(S_FUNC): -case YY_STATE_EOF(S_INCLUDE): -case YY_STATE_EOF(S_INHERIT): -case YY_STATE_EOF(S_REQUIRE): -case YY_STATE_EOF(S_PROC): -case YY_STATE_EOF(S_RVALUE): -case YY_STATE_EOF(S_TASK): -#line 252 "bitbakescanner.l" -{ return T_EOF; } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 254 "bitbakescanner.l" -ECHO; - YY_BREAK -#line 1988 "<stdout>" - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap(yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ,yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 813 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) -{ - register int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - register char *yy_cp = yyg->yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 813 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 812); - - return yy_is_jam ? 0 : yy_current_state; -} - - static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner) -{ - register char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_cp = yyg->yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yyg->yy_hold_char; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yyg->yy_n_chars + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - if ( c == '\n' ){ - --yylineno; - } - - yyg->yytext_ptr = yy_bp; - yyg->yy_hold_char = *yy_cp; - yyg->yy_c_buf_p = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - -{ - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart(yyin ,yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap(yyscanner ) ) - return EOF; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - if ( c == '\n' ) - - do{ yylineno++; - yycolumn=0; - }while(0) -; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - yy_load_buffer_state(yyscanner ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state(yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; -} - -static void yy_load_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ,yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer(b,file ,yyscanner); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ,yyscanner ); - - yyfree((void *) b ,yyscanner ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - -{ - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_flush_buffer(b ,yyscanner); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state(yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - int num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b ,yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param str a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ,yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf,n ,yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - - static void yy_push_state (int new_state , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth ) - { - yy_size_t new_size; - - yyg->yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yyg->yy_start_stack_depth * sizeof( int ); - - if ( ! yyg->yy_start_stack ) - yyg->yy_start_stack = (int *) yyalloc(new_size ,yyscanner ); - - else - yyg->yy_start_stack = (int *) yyrealloc((void *) yyg->yy_start_stack,new_size ,yyscanner ); - - if ( ! yyg->yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } - - yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); -} - - static void yy_pop_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( --yyg->yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]); -} - - static int yy_top_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1]; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param line_number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "yyset_lineno called with no buffer" , yyscanner); - - yylineno = line_number; -} - -/** Set the current column. - * @param line_number - * @param yyscanner The scanner object. - */ -void yyset_column (int column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "yyset_column called with no buffer" , yyscanner); - - yycolumn = column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = in_str ; -} - -void yyset_out (FILE * out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ - -int yylex_init(yyscan_t* ptr_yy_globals) - -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - return yy_init_globals ( *ptr_yy_globals ); -} - -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = 0; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = (char *) 0; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack ,yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree(yyg->yy_start_stack ,yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - return (void *) malloc( size ); -} - -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 254 "bitbakescanner.l" - - - -void lex_t::accept (int token, const char* sz) -{ - token_t t; - memset (&t, 0, sizeof (t)); - t.copyString(sz); - - /* tell lemon to parse the token */ - parse (parser, token, t, this); -} - -void lex_t::input (char *buf, int *result, int max_size) -{ - /* printf("lex_t::input %p %d\n", buf, max_size); */ - *result = fread(buf, 1, max_size, file); - /* printf("lex_t::input result %d\n", *result); */ -} - -int lex_t::line ()const -{ - /* printf("lex_t::line\n"); */ - return yyget_lineno (scanner); -} - - -extern "C" { - - void parse (FILE* file, char* name, PyObject* data, int config) - { - /* printf("parse bbparseAlloc\n"); */ - void* parser = bbparseAlloc (malloc); - yyscan_t scanner; - lex_t lex; - - /* printf("parse yylex_init\n"); */ - yylex_init (&scanner); - - lex.parser = parser; - lex.scanner = scanner; - lex.file = file; - lex.name = name; - lex.data = data; - lex.config = config; - lex.parse = bbparse; - /*printf("parse yyset_extra\n"); */ - yyset_extra (&lex, scanner); - - /* printf("parse yylex\n"); */ - int result = yylex (scanner); - - /* printf("parse result %d\n", result); */ - - lex.accept (0); - /* printf("parse lex.accept\n"); */ - bbparseTrace (NULL, NULL); - /* printf("parse bbparseTrace\n"); */ - - if (result != T_EOF) - printf ("premature end of file\n"); - - yylex_destroy (scanner); - bbparseFree (parser, free); - } - -} - diff --git a/bitbake/lib/bb/parse/parse_c/bitbakescanner.l b/bitbake/lib/bb/parse/parse_c/bitbakescanner.l deleted file mode 100644 index b6592f28e9..0000000000 --- a/bitbake/lib/bb/parse/parse_c/bitbakescanner.l +++ /dev/null @@ -1,319 +0,0 @@ -/* bbf.flex - - written by Marc Singer - 6 January 2005 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. - - DESCRIPTION - ----------- - - flex lexer specification for a BitBake input file parser. - - Unfortunately, flex doesn't welcome comments within the rule sets. - I say unfortunately because this lexer is unreasonably complex and - comments would make the code much easier to comprehend. - - The BitBake grammar is not regular. In order to interpret all - of the available input files, the lexer maintains much state as it - parses. There are places where this lexer will emit tokens that - are invalid. The parser will tend to catch these. - - The lexer requires C++ at the moment. The only reason for this has - to do with a very small amount of managed state. Producing a C - lexer should be a reasonably easy task as long as the %reentrant - option is used. - - - NOTES - ----- - - o RVALUES. There are three kinds of RVALUES. There are unquoted - values, double quote enclosed strings, and single quote - strings. Quoted strings may contain unescaped quotes (of either - type), *and* any type may span more than one line by using a - continuation '\' at the end of the line. This requires us to - recognize all types of values with a single expression. - Moreover, the only reason to quote a value is to include - trailing or leading whitespace. Whitespace within a value is - preserved, ugh. - - o CLASSES. C_ patterns define classes. Classes ought not include - a repitition operator, instead letting the reference to the class - define the repitition count. - - C_SS - symbol start - C_SB - symbol body - C_SP - whitespace - -*/ - -%option never-interactive -%option yylineno -%option noyywrap -%option reentrant stack - - -%{ - -#include "token.h" -#include "lexer.h" -#include "bitbakeparser.h" -#include <ctype.h> - -extern void *bbparseAlloc(void *(*mallocProc)(size_t)); -extern void bbparseFree(void *p, void (*freeProc)(void*)); -extern void *bbparseAlloc(void *(*mallocProc)(size_t)); -extern void *bbparse(void*, int, token_t, lex_t*); -extern void bbparseTrace(FILE *TraceFILE, char *zTracePrompt); - -//static const char* rgbInput; -//static size_t cbInput; - -extern "C" { - -int lineError; -int errorParse; - -enum { - errorNone = 0, - errorUnexpectedInput, - errorUnsupportedFeature, -}; - -} - -#define YY_EXTRA_TYPE lex_t* - - /* Read from buffer */ -#define YY_INPUT(buf,result,max_size) \ - { yyextra->input(buf, &result, max_size); } - -//#define YY_DECL static size_t yylex () - -#define ERROR(e) \ - do { lineError = yylineno; errorParse = e; yyterminate (); } while (0) - -static const char* fixup_escapes (const char* sz); - -%} - - -C_SP [ \t] -COMMENT #.*\n -OP_ASSIGN "=" -OP_PREDOT ".=" -OP_POSTDOT "=." -OP_IMMEDIATE ":=" -OP_PREPEND "=+" -OP_APPEND "+=" -OP_COND "?=" -B_OPEN "{" -B_CLOSE "}" - -K_ADDTASK "addtask" -K_ADDHANDLER "addhandler" -K_AFTER "after" -K_BEFORE "before" -K_DEF "def" -K_INCLUDE "include" -K_REQUIRE "require" -K_INHERIT "inherit" -K_PYTHON "python" -K_FAKEROOT "fakeroot" -K_EXPORT "export" -K_EXPORT_FUNC "EXPORT_FUNCTIONS" - -STRING \"([^\n\r]|"\\\n")*\" -SSTRING \'([^\n\r]|"\\\n")*\' -VALUE ([^'" \t\n])|([^'" \t\n]([^\n]|(\\\n))*[^'" \t\n]) - -C_SS [a-zA-Z_] -C_SB [a-zA-Z0-9_+-./] -REF $\{{C_SS}{C_SB}*\} -SYMBOL {C_SS}{C_SB}* -VARIABLE $?{C_SS}({C_SB}*|{REF})*(\[[a-zA-Z0-9_]*\])? -FILENAME ([a-zA-Z_./]|{REF})(([-+a-zA-Z0-9_./]*)|{REF})* - -PROC \({C_SP}*\) - -%s S_DEF -%s S_DEF_ARGS -%s S_DEF_BODY -%s S_FUNC -%s S_INCLUDE -%s S_INHERIT -%s S_REQUIRE -%s S_PROC -%s S_RVALUE -%s S_TASK - -%% - -{OP_APPEND} { BEGIN S_RVALUE; - yyextra->accept (T_OP_APPEND); } -{OP_PREPEND} { BEGIN S_RVALUE; - yyextra->accept (T_OP_PREPEND); } -{OP_IMMEDIATE} { BEGIN S_RVALUE; - yyextra->accept (T_OP_IMMEDIATE); } -{OP_ASSIGN} { BEGIN S_RVALUE; - yyextra->accept (T_OP_ASSIGN); } -{OP_PREDOT} { BEGIN S_RVALUE; - yyextra->accept (T_OP_PREDOT); } -{OP_POSTDOT} { BEGIN S_RVALUE; - yyextra->accept (T_OP_POSTDOT); } -{OP_COND} { BEGIN S_RVALUE; - yyextra->accept (T_OP_COND); } - -<S_RVALUE>\\\n{C_SP}* { } -<S_RVALUE>{STRING} { BEGIN INITIAL; - size_t cb = yyleng; - while (cb && isspace (yytext[cb - 1])) - --cb; - yytext[cb - 1] = 0; - yyextra->accept (T_STRING, yytext + 1); } -<S_RVALUE>{SSTRING} { BEGIN INITIAL; - size_t cb = yyleng; - while (cb && isspace (yytext[cb - 1])) - --cb; - yytext[cb - 1] = 0; - yyextra->accept (T_STRING, yytext + 1); } - -<S_RVALUE>{VALUE} { ERROR (errorUnexpectedInput); } -<S_RVALUE>{C_SP}*\n+ { BEGIN INITIAL; - yyextra->accept (T_STRING, NULL); } - -{K_INCLUDE} { BEGIN S_INCLUDE; - yyextra->accept (T_INCLUDE); } -{K_REQUIRE} { BEGIN S_REQUIRE; - yyextra->accept (T_REQUIRE); } -{K_INHERIT} { BEGIN S_INHERIT; - yyextra->accept (T_INHERIT); } -{K_ADDTASK} { BEGIN S_TASK; - yyextra->accept (T_ADDTASK); } -{K_ADDHANDLER} { yyextra->accept (T_ADDHANDLER); } -{K_EXPORT_FUNC} { BEGIN S_FUNC; - yyextra->accept (T_EXPORT_FUNC); } -<S_TASK>{K_BEFORE} { yyextra->accept (T_BEFORE); } -<S_TASK>{K_AFTER} { yyextra->accept (T_AFTER); } -<INITIAL>{K_EXPORT} { yyextra->accept (T_EXPORT); } - -<INITIAL>{K_FAKEROOT} { yyextra->accept (T_FAKEROOT); } -<INITIAL>{K_PYTHON} { yyextra->accept (T_PYTHON); } -{PROC}{C_SP}*{B_OPEN}{C_SP}*\n* { BEGIN S_PROC; - yyextra->accept (T_PROC_OPEN); } -<S_PROC>{B_CLOSE}{C_SP}*\n* { BEGIN INITIAL; - yyextra->accept (T_PROC_CLOSE); } -<S_PROC>([^}][^\n]*)?\n* { yyextra->accept (T_PROC_BODY, yytext); } - -{K_DEF} { BEGIN S_DEF; } -<S_DEF>{SYMBOL} { BEGIN S_DEF_ARGS; - yyextra->accept (T_SYMBOL, yytext); } -<S_DEF_ARGS>[^\n:]*: { yyextra->accept (T_DEF_ARGS, yytext); } -<S_DEF_ARGS>{C_SP}*\n { BEGIN S_DEF_BODY; } -<S_DEF_BODY>{C_SP}+[^\n]*\n { yyextra->accept (T_DEF_BODY, yytext); } -<S_DEF_BODY>\n { yyextra->accept (T_DEF_BODY, yytext); } -<S_DEF_BODY>. { BEGIN INITIAL; unput (yytext[0]); } - -{COMMENT} { } - -<INITIAL>{SYMBOL} { yyextra->accept (T_SYMBOL, yytext); } -<INITIAL>{VARIABLE} { yyextra->accept (T_VARIABLE, yytext); } - -<S_TASK>{SYMBOL} { yyextra->accept (T_TSYMBOL, yytext); } -<S_FUNC>{SYMBOL} { yyextra->accept (T_FSYMBOL, yytext); } -<S_INHERIT>{SYMBOL} { yyextra->accept (T_ISYMBOL, yytext); } -<S_INCLUDE>{FILENAME} { BEGIN INITIAL; - yyextra->accept (T_ISYMBOL, yytext); } -<S_REQUIRE>{FILENAME} { BEGIN INITIAL; - yyextra->accept (T_ISYMBOL, yytext); } -<S_TASK>\n { BEGIN INITIAL; } -<S_FUNC>\n { BEGIN INITIAL; } -<S_INHERIT>\n { BEGIN INITIAL; } - -[ \t\r\n] /* Insignificant whitespace */ - -. { ERROR (errorUnexpectedInput); } - - /* Check for premature termination */ -<<EOF>> { return T_EOF; } - -%% - -void lex_t::accept (int token, const char* sz) -{ - token_t t; - memset (&t, 0, sizeof (t)); - t.copyString(sz); - - /* tell lemon to parse the token */ - parse (parser, token, t, this); -} - -void lex_t::input (char *buf, int *result, int max_size) -{ - /* printf("lex_t::input %p %d\n", buf, max_size); */ - *result = fread(buf, 1, max_size, file); - /* printf("lex_t::input result %d\n", *result); */ -} - -int lex_t::line ()const -{ - /* printf("lex_t::line\n"); */ - return yyget_lineno (scanner); -} - - -extern "C" { - - void parse (FILE* file, char* name, PyObject* data, int config) - { - /* printf("parse bbparseAlloc\n"); */ - void* parser = bbparseAlloc (malloc); - yyscan_t scanner; - lex_t lex; - - /* printf("parse yylex_init\n"); */ - yylex_init (&scanner); - - lex.parser = parser; - lex.scanner = scanner; - lex.file = file; - lex.name = name; - lex.data = data; - lex.config = config; - lex.parse = bbparse; - /*printf("parse yyset_extra\n"); */ - yyset_extra (&lex, scanner); - - /* printf("parse yylex\n"); */ - int result = yylex (scanner); - - /* printf("parse result %d\n", result); */ - - lex.accept (0); - /* printf("parse lex.accept\n"); */ - bbparseTrace (NULL, NULL); - /* printf("parse bbparseTrace\n"); */ - - if (result != T_EOF) - printf ("premature end of file\n"); - - yylex_destroy (scanner); - bbparseFree (parser, free); - } - -} diff --git a/bitbake/lib/bb/parse/parse_c/lexer.h b/bitbake/lib/bb/parse/parse_c/lexer.h deleted file mode 100644 index cb32be7037..0000000000 --- a/bitbake/lib/bb/parse/parse_c/lexer.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -Copyright (C) 2005 Holger Hans Peter Freyther - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -*/ - -#ifndef LEXER_H -#define LEXER_H - -#include "Python.h" - -extern "C" { - -struct lex_t { - void* parser; - void* scanner; - FILE* file; - char *name; - PyObject *data; - int config; - - void* (*parse)(void*, int, token_t, lex_t*); - - void accept(int token, const char* sz = NULL); - void input(char *buf, int *result, int max_size); - int line()const; -}; - -} - -#endif diff --git a/bitbake/lib/bb/parse/parse_c/lexerc.h b/bitbake/lib/bb/parse/parse_c/lexerc.h deleted file mode 100644 index c8a19fb222..0000000000 --- a/bitbake/lib/bb/parse/parse_c/lexerc.h +++ /dev/null @@ -1,19 +0,0 @@ - -#ifndef LEXERC_H -#define LEXERC_H - -#include <stdio.h> - -extern int lineError; -extern int errorParse; - -typedef struct { - void *parser; - void *scanner; - FILE *file; - char *name; - PyObject *data; - int config; -} lex_t; - -#endif diff --git a/bitbake/lib/bb/parse/parse_c/python_output.h b/bitbake/lib/bb/parse/parse_c/python_output.h deleted file mode 100644 index bf34527c0a..0000000000 --- a/bitbake/lib/bb/parse/parse_c/python_output.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef PYTHON_OUTPUT_H -#define PYTHON_OUTPUT_H -/* -Copyright (C) 2006 Holger Hans Peter Freyther - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -This is the glue: - It will be called from the lemon grammar and will call into - python to set certain things. - -*/ - -extern "C" { - -struct lex_t; - -extern void e_assign(lex_t*, const char*, const char*); -extern void e_export(lex_t*, const char*); -extern void e_immediate(lex_t*, const char*, const char*); -extern void e_cond(lex_t*, const char*, const char*); -extern void e_prepend(lex_t*, const char*, const char*); -extern void e_append(lex_t*, const char*, const char*); -extern void e_precat(lex_t*, const char*, const char*); -extern void e_postcat(lex_t*, const char*, const char*); - -extern void e_addtask(lex_t*, const char*, const char*, const char*); -extern void e_addhandler(lex_t*,const char*); -extern void e_export_func(lex_t*, const char*); -extern void e_inherit(lex_t*, const char*); -extern void e_include(lex_t*, const char*); -extern void e_require(lex_t*, const char*); -extern void e_proc(lex_t*, const char*, const char*); -extern void e_proc_python(lex_t*, const char*, const char*); -extern void e_proc_fakeroot(lex_t*, const char*, const char*); -extern void e_def(lex_t*, const char*, const char*, const char*); -extern void e_parse_error(lex_t*); - -} -#endif // PYTHON_OUTPUT_H diff --git a/bitbake/lib/bb/parse/parse_c/token.h b/bitbake/lib/bb/parse/parse_c/token.h deleted file mode 100644 index c6242015b7..0000000000 --- a/bitbake/lib/bb/parse/parse_c/token.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright (C) 2005 Holger Hans Peter Freyther - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -*/ - -#ifndef TOKEN_H -#define TOKEN_H - -#include <ctype.h> -#include <string.h> - -#define PURE_METHOD - - -/** - * Special Value for End Of File Handling. We set it to - * 1001 so we can have up to 1000 Terminal Symbols on - * grammar. Currenlty we have around 20 - */ -#define T_EOF 1001 - -struct token_t { - const char* string()const PURE_METHOD; - - static char* concatString(const char* l, const char* r); - void assignString(char* str); - void copyString(const char* str); - - void release_this(); - -private: - char *m_string; - size_t m_stringLen; -}; - -inline const char* token_t::string()const -{ - return m_string; -} - -/* - * append str to the current string - */ -inline char* token_t::concatString(const char* l, const char* r) -{ - size_t cb = (l ? strlen (l) : 0) + strlen (r) + 1; - char *r_sz = new char[cb]; - *r_sz = 0; - - if (l) - strcat (r_sz, l); - strcat (r_sz, r); - - return r_sz; -} - -inline void token_t::assignString(char* str) -{ - m_string = str; - m_stringLen = str ? strlen(str) : 0; -} - -inline void token_t::copyString(const char* str) -{ - if( str ) { - m_stringLen = strlen(str); - m_string = new char[m_stringLen+1]; - strcpy(m_string, str); - } -} - -inline void token_t::release_this() -{ - delete m_string; - m_string = 0; -} - -#endif diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py deleted file mode 100644 index 2a30e5895a..0000000000 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env python -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" - class for handling .bb files - - Reads a .bb file and obtains its metadata - -""" - - -# Copyright (C) 2003, 2004 Chris Larson -# Copyright (C) 2003, 2004 Phil Blundell -# -# 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. -# -# 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 re, bb, os, sys, time -import bb.fetch, bb.build, bb.utils -from bb import data, fetch, methodpool - -from ConfHandler import include, localpath, obtain, init -from bb.parse import ParseError - -__func_start_regexp__ = re.compile( r"(((?P<py>python)|(?P<fr>fakeroot))\s*)*(?P<func>[\w\.\-\+\{\}\$]+)?\s*\(\s*\)\s*{$" ) -__inherit_regexp__ = re.compile( r"inherit\s+(.+)" ) -__export_func_regexp__ = re.compile( r"EXPORT_FUNCTIONS\s+(.+)" ) -__addtask_regexp__ = re.compile("addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*") -__addhandler_regexp__ = re.compile( r"addhandler\s+(.+)" ) -__def_regexp__ = re.compile( r"def\s+(\w+).*:" ) -__python_func_regexp__ = re.compile( r"(\s+.*)|(^$)" ) -__word__ = re.compile(r"\S+") - -__infunc__ = "" -__inpython__ = False -__body__ = [] -__classname__ = "" -classes = [ None, ] - -# We need to indicate EOF to the feeder. This code is so messy that -# factoring it out to a close_parse_file method is out of question. -# We will use the IN_PYTHON_EOF as an indicator to just close the method -# -# The two parts using it are tightly integrated anyway -IN_PYTHON_EOF = -9999999999999 - -__parsed_methods__ = methodpool.get_parsed_dict() - -def supports(fn, d): - localfn = localpath(fn, d) - return localfn[-3:] == ".bb" or localfn[-8:] == ".bbclass" or localfn[-4:] == ".inc" - -def inherit(files, d): - __inherit_cache = data.getVar('__inherit_cache', d) or [] - fn = "" - lineno = 0 - files = data.expand(files, d) - for file in files: - if file[0] != "/" and file[-8:] != ".bbclass": - file = os.path.join('classes', '%s.bbclass' % file) - - if not file in __inherit_cache: - bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file)) - __inherit_cache.append( file ) - data.setVar('__inherit_cache', __inherit_cache, d) - include(fn, file, d, "inherit") - __inherit_cache = data.getVar('__inherit_cache', d) or [] - -def handle(fn, d, include = 0): - global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__ - __body__ = [] - __infunc__ = "" - __classname__ = "" - __residue__ = [] - - if include == 0: - bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data)") - else: - bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data, include)") - - (root, ext) = os.path.splitext(os.path.basename(fn)) - base_name = "%s%s" % (root,ext) - init(d) - - if ext == ".bbclass": - __classname__ = root - classes.append(__classname__) - - if include != 0: - oldfile = data.getVar('FILE', d) - else: - oldfile = None - - fn = obtain(fn, d) - bbpath = (data.getVar('BBPATH', d, 1) or '').split(':') - if not os.path.isabs(fn): - f = None - for p in bbpath: - j = os.path.join(p, fn) - if os.access(j, os.R_OK): - abs_fn = j - f = open(j, 'r') - break - if f is None: - raise IOError("file not found") - else: - f = open(fn,'r') - abs_fn = fn - - if ext != ".bbclass": - bbpath.insert(0, os.path.dirname(abs_fn)) - data.setVar('BBPATH', ":".join(bbpath), d) - - if include: - bb.parse.mark_dependency(d, abs_fn) - - if ext != ".bbclass": - data.setVar('FILE', fn, d) - i = (data.getVar("INHERIT", d, 1) or "").split() - if not "base" in i and __classname__ != "base": - i[0:0] = ["base"] - inherit(i, d) - - lineno = 0 - while 1: - lineno = lineno + 1 - s = f.readline() - if not s: break - s = s.rstrip() - feeder(lineno, s, fn, base_name, d) - if __inpython__: - # add a blank line to close out any python definition - feeder(IN_PYTHON_EOF, "", fn, base_name, d) - if ext == ".bbclass": - classes.remove(__classname__) - else: - if include == 0: - data.expandKeys(d) - data.update_data(d) - anonqueue = data.getVar("__anonqueue", d, 1) or [] - body = [x['content'] for x in anonqueue] - flag = { 'python' : 1, 'func' : 1 } - data.setVar("__anonfunc", "\n".join(body), d) - data.setVarFlags("__anonfunc", flag, d) - from bb import build - try: - t = data.getVar('T', d) - data.setVar('T', '${TMPDIR}/', d) - build.exec_func("__anonfunc", d) - data.delVar('T', d) - if t: - data.setVar('T', t, d) - except Exception, e: - bb.msg.debug(1, bb.msg.domain.Parsing, "Exception when executing anonymous function: %s" % e) - raise - data.delVar("__anonqueue", d) - data.delVar("__anonfunc", d) - set_additional_vars(fn, d, include) - data.update_data(d) - - all_handlers = {} - for var in data.getVar('__BBHANDLERS', d) or []: - # try to add the handler - # if we added it remember the choiche - handler = data.getVar(var,d) - if bb.event.register(var,handler) == bb.event.Registered: - all_handlers[var] = handler - - tasklist = {} - for var in data.getVar('__BBTASKS', d) or []: - if var not in tasklist: - tasklist[var] = [] - deps = data.getVarFlag(var, 'deps', d) or [] - for p in deps: - if p not in tasklist[var]: - tasklist[var].append(p) - - postdeps = data.getVarFlag(var, 'postdeps', d) or [] - for p in postdeps: - if p not in tasklist: - tasklist[p] = [] - if var not in tasklist[p]: - tasklist[p].append(var) - - bb.build.add_tasks(tasklist, d) - - # now add the handlers - if not len(all_handlers) == 0: - data.setVar('__all_handlers__', all_handlers, d) - - bbpath.pop(0) - if oldfile: - bb.data.setVar("FILE", oldfile, d) - - # we have parsed the bb class now - if ext == ".bbclass" or ext == ".inc": - __parsed_methods__[base_name] = 1 - - return d - -def feeder(lineno, s, fn, root, d): - global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__,__infunc__, __body__, classes, bb, __residue__ - if __infunc__: - if s == '}': - __body__.append('') - data.setVar(__infunc__, '\n'.join(__body__), d) - data.setVarFlag(__infunc__, "func", 1, d) - if __infunc__ == "__anonymous": - anonqueue = bb.data.getVar("__anonqueue", d) or [] - anonitem = {} - anonitem["content"] = bb.data.getVar("__anonymous", d) - anonitem["flags"] = bb.data.getVarFlags("__anonymous", d) - anonqueue.append(anonitem) - bb.data.setVar("__anonqueue", anonqueue, d) - bb.data.delVarFlags("__anonymous", d) - bb.data.delVar("__anonymous", d) - __infunc__ = "" - __body__ = [] - else: - __body__.append(s) - return - - if __inpython__: - m = __python_func_regexp__.match(s) - if m and lineno != IN_PYTHON_EOF: - __body__.append(s) - return - else: - # Note we will add root to parsedmethods after having parse - # 'this' file. This means we will not parse methods from - # bb classes twice - if not root in __parsed_methods__: - text = '\n'.join(__body__) - methodpool.insert_method( root, text, fn ) - funcs = data.getVar('__functions__', d) or {} - if not funcs.has_key( root ): - funcs[root] = text - else: - funcs[root] = "%s\n%s" % (funcs[root], text) - - data.setVar('__functions__', funcs, d) - __body__ = [] - __inpython__ = False - - if lineno == IN_PYTHON_EOF: - return - -# fall through - - if s == '' or s[0] == '#': return # skip comments and empty lines - - if s[-1] == '\\': - __residue__.append(s[:-1]) - return - - s = "".join(__residue__) + s - __residue__ = [] - - m = __func_start_regexp__.match(s) - if m: - __infunc__ = m.group("func") or "__anonymous" - key = __infunc__ - if data.getVar(key, d): -# clean up old version of this piece of metadata, as its -# flags could cause problems - data.setVarFlag(key, 'python', None, d) - data.setVarFlag(key, 'fakeroot', None, d) - if m.group("py") is not None: - data.setVarFlag(key, "python", "1", d) - else: - data.delVarFlag(key, "python", d) - if m.group("fr") is not None: - data.setVarFlag(key, "fakeroot", "1", d) - else: - data.delVarFlag(key, "fakeroot", d) - return - - m = __def_regexp__.match(s) - if m: - __body__.append(s) - __inpython__ = True - return - - m = __export_func_regexp__.match(s) - if m: - fns = m.group(1) - n = __word__.findall(fns) - for f in n: - allvars = [] - allvars.append(f) - allvars.append(classes[-1] + "_" + f) - - vars = [[ allvars[0], allvars[1] ]] - if len(classes) > 1 and classes[-2] is not None: - allvars.append(classes[-2] + "_" + f) - vars = [] - vars.append([allvars[2], allvars[1]]) - vars.append([allvars[0], allvars[2]]) - - for (var, calledvar) in vars: - if data.getVar(var, d) and not data.getVarFlag(var, 'export_func', d): - continue - - if data.getVar(var, d): - data.setVarFlag(var, 'python', None, d) - data.setVarFlag(var, 'func', None, d) - - for flag in [ "func", "python" ]: - if data.getVarFlag(calledvar, flag, d): - data.setVarFlag(var, flag, data.getVarFlag(calledvar, flag, d), d) - for flag in [ "dirs" ]: - if data.getVarFlag(var, flag, d): - data.setVarFlag(calledvar, flag, data.getVarFlag(var, flag, d), d) - - if data.getVarFlag(calledvar, "python", d): - data.setVar(var, "\tbb.build.exec_func('" + calledvar + "', d)\n", d) - else: - data.setVar(var, "\t" + calledvar + "\n", d) - data.setVarFlag(var, 'export_func', '1', d) - - return - - m = __addtask_regexp__.match(s) - if m: - func = m.group("func") - before = m.group("before") - after = m.group("after") - if func is None: - return - var = "do_" + func - - data.setVarFlag(var, "task", 1, d) - - bbtasks = data.getVar('__BBTASKS', d) or [] - bbtasks.append(var) - data.setVar('__BBTASKS', bbtasks, d) - - if after is not None: -# set up deps for function - data.setVarFlag(var, "deps", after.split(), d) - if before is not None: -# set up things that depend on this func - data.setVarFlag(var, "postdeps", before.split(), d) - return - - m = __addhandler_regexp__.match(s) - if m: - fns = m.group(1) - hs = __word__.findall(fns) - bbhands = data.getVar('__BBHANDLERS', d) or [] - for h in hs: - bbhands.append(h) - data.setVarFlag(h, "handler", 1, d) - data.setVar('__BBHANDLERS', bbhands, d) - return - - m = __inherit_regexp__.match(s) - if m: - - files = m.group(1) - n = __word__.findall(files) - inherit(n, d) - return - - from bb.parse import ConfHandler - return ConfHandler.feeder(lineno, s, fn, d) - -__pkgsplit_cache__={} -def vars_from_file(mypkg, d): - if not mypkg: - return (None, None, None) - if mypkg in __pkgsplit_cache__: - return __pkgsplit_cache__[mypkg] - - myfile = os.path.splitext(os.path.basename(mypkg)) - parts = myfile[0].split('_') - __pkgsplit_cache__[mypkg] = parts - if len(parts) > 3: - raise ParseError("Unable to generate default variables from the filename: %s (too many underscores)" % mypkg) - exp = 3 - len(parts) - tmplist = [] - while exp != 0: - exp -= 1 - tmplist.append(None) - parts.extend(tmplist) - return parts - -def set_additional_vars(file, d, include): - """Deduce rest of variables, e.g. ${A} out of ${SRC_URI}""" - - return - # Nothing seems to use this variable - #bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s: set_additional_vars" % file) - - #src_uri = data.getVar('SRC_URI', d, 1) - #if not src_uri: - # return - - #a = (data.getVar('A', d, 1) or '').split() - - #from bb import fetch - #try: - # ud = fetch.init(src_uri.split(), d) - # a += fetch.localpaths(d, ud) - #except fetch.NoMethodError: - # pass - #except bb.MalformedUrl,e: - # raise ParseError("Unable to generate local paths for SRC_URI due to malformed uri: %s" % e) - #del fetch - - #data.setVar('A', " ".join(a), d) - - -# Add us to the handlers list -from bb.parse import handlers -handlers.append({'supports': supports, 'handle': handle, 'init': init}) -del handlers diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py deleted file mode 100644 index e6488bbe11..0000000000 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ /dev/null @@ -1,228 +0,0 @@ -#!/usr/bin/env python -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" - class for handling configuration data files - - Reads a .conf file and obtains its metadata - -""" - -# Copyright (C) 2003, 2004 Chris Larson -# Copyright (C) 2003, 2004 Phil Blundell -# -# 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. -# -# 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 re, bb.data, os, sys -from bb.parse import ParseError - -#__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}]+)\s*(?P<colon>:)?(?P<ques>\?)?=\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") -__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") -__include_regexp__ = re.compile( r"include\s+(.+)" ) -__require_regexp__ = re.compile( r"require\s+(.+)" ) -__export_regexp__ = re.compile( r"export\s+(.+)" ) - -def init(data): - if not bb.data.getVar('TOPDIR', data): - bb.data.setVar('TOPDIR', os.getcwd(), data) - if not bb.data.getVar('BBPATH', data): - bb.data.setVar('BBPATH', os.path.join(sys.prefix, 'share', 'bitbake'), data) - -def supports(fn, d): - return localpath(fn, d)[-5:] == ".conf" - -def localpath(fn, d): - if os.path.exists(fn): - return fn - - if "://" not in fn: - return fn - - localfn = None - try: - localfn = bb.fetch.localpath(fn, d, False) - except bb.MalformedUrl: - pass - - if not localfn: - return fn - return localfn - -def obtain(fn, data): - import sys, bb - fn = bb.data.expand(fn, data) - localfn = bb.data.expand(localpath(fn, data), data) - - if localfn != fn: - dldir = bb.data.getVar('DL_DIR', data, 1) - if not dldir: - bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: DL_DIR not defined") - return localfn - bb.mkdirhier(dldir) - try: - bb.fetch.init([fn], data) - except bb.fetch.NoMethodError: - (type, value, traceback) = sys.exc_info() - bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: no method: %s" % value) - return localfn - - try: - bb.fetch.go(data) - except bb.fetch.MissingParameterError: - (type, value, traceback) = sys.exc_info() - bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: missing parameters: %s" % value) - return localfn - except bb.fetch.FetchError: - (type, value, traceback) = sys.exc_info() - bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: failed: %s" % value) - return localfn - return localfn - - -def include(oldfn, fn, data, error_out): - """ - - error_out If True a ParseError will be reaised if the to be included - """ - if oldfn == fn: # prevent infinate recursion - return None - - import bb - fn = bb.data.expand(fn, data) - oldfn = bb.data.expand(oldfn, data) - - from bb.parse import handle - try: - ret = handle(fn, data, True) - except IOError: - if error_out: - raise ParseError("Could not %(error_out)s file %(fn)s" % vars() ) - bb.msg.debug(2, bb.msg.domain.Parsing, "CONF file '%s' not found" % fn) - -def handle(fn, data, include = 0): - if include: - inc_string = "including" - else: - inc_string = "reading" - init(data) - - if include == 0: - bb.data.inheritFromOS(data) - oldfile = None - else: - oldfile = bb.data.getVar('FILE', data) - - fn = obtain(fn, data) - if not os.path.isabs(fn): - f = None - bbpath = bb.data.getVar("BBPATH", data, 1) or [] - for p in bbpath.split(":"): - currname = os.path.join(p, fn) - if os.access(currname, os.R_OK): - f = open(currname, 'r') - abs_fn = currname - bb.msg.debug(2, bb.msg.domain.Parsing, "CONF %s %s" % (inc_string, currname)) - break - if f is None: - raise IOError("file '%s' not found" % fn) - else: - f = open(fn,'r') - bb.msg.debug(1, bb.msg.domain.Parsing, "CONF %s %s" % (inc_string,fn)) - abs_fn = fn - - if include: - bb.parse.mark_dependency(data, abs_fn) - - lineno = 0 - bb.data.setVar('FILE', fn, data) - while 1: - lineno = lineno + 1 - s = f.readline() - if not s: break - w = s.strip() - if not w: continue # skip empty lines - s = s.rstrip() - if s[0] == '#': continue # skip comments - while s[-1] == '\\': - s2 = f.readline()[:-1].strip() - lineno = lineno + 1 - s = s[:-1] + s2 - feeder(lineno, s, fn, data) - - if oldfile: - bb.data.setVar('FILE', oldfile, data) - return data - -def feeder(lineno, s, fn, data): - def getFunc(groupd, key, data): - if 'flag' in groupd and groupd['flag'] != None: - return bb.data.getVarFlag(key, groupd['flag'], data) - else: - return bb.data.getVar(key, data) - - m = __config_regexp__.match(s) - if m: - groupd = m.groupdict() - key = groupd["var"] - if "exp" in groupd and groupd["exp"] != None: - bb.data.setVarFlag(key, "export", 1, data) - if "ques" in groupd and groupd["ques"] != None: - val = getFunc(groupd, key, data) - if val == None: - val = groupd["value"] - elif "colon" in groupd and groupd["colon"] != None: - e = data.createCopy() - bb.data.update_data(e) - val = bb.data.expand(groupd["value"], e) - elif "append" in groupd and groupd["append"] != None: - val = "%s %s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) - elif "prepend" in groupd and groupd["prepend"] != None: - val = "%s %s" % (groupd["value"], (getFunc(groupd, key, data) or "")) - elif "postdot" in groupd and groupd["postdot"] != None: - val = "%s%s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) - elif "predot" in groupd and groupd["predot"] != None: - val = "%s%s" % (groupd["value"], (getFunc(groupd, key, data) or "")) - else: - val = groupd["value"] - if 'flag' in groupd and groupd['flag'] != None: - bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val)) - bb.data.setVarFlag(key, groupd['flag'], val, data) - else: - bb.data.setVar(key, val, data) - return - - m = __include_regexp__.match(s) - if m: - s = bb.data.expand(m.group(1), data) - bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s)) - include(fn, s, data, False) - return - - m = __require_regexp__.match(s) - if m: - s = bb.data.expand(m.group(1), data) - include(fn, s, data, "include required") - return - - m = __export_regexp__.match(s) - if m: - bb.data.setVarFlag(m.group(1), "export", 1, data) - return - - raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); - -# Add us to the handlers list -from bb.parse import handlers -handlers.append({'supports': supports, 'handle': handle, 'init': init}) -del handlers diff --git a/bitbake/lib/bb/parse/parse_py/__init__.py b/bitbake/lib/bb/parse/parse_py/__init__.py deleted file mode 100644 index 9e0e00adda..0000000000 --- a/bitbake/lib/bb/parse/parse_py/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake Parsers - -File parsers for the BitBake build tools. - -""" - -# Copyright (C) 2003, 2004 Chris Larson -# Copyright (C) 2003, 2004 Phil Blundell -# -# 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. -# -# 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. -# -# Based on functions from the base bb module, Copyright 2003 Holger Schurig -__version__ = '1.0' - -__all__ = [ 'ConfHandler', 'BBHandler'] - -import ConfHandler -import BBHandler diff --git a/bitbake/lib/bb/persist_data.py b/bitbake/lib/bb/persist_data.py deleted file mode 100644 index 0b88dadba5..0000000000 --- a/bitbake/lib/bb/persist_data.py +++ /dev/null @@ -1,106 +0,0 @@ -# BitBake Persistent Data Store -# -# Copyright (C) 2007 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. -# -# 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 bb, os - -try: - import sqlite3 -except ImportError: - try: - from pysqlite2 import dbapi2 as sqlite3 - except ImportError: - bb.msg.fatal(bb.msg.domain.PersistData, "Importing sqlite3 and pysqlite2 failed, please install one of them. A 'python-pysqlite2' like package is likely to be what you need.") - -class PersistData: - """ - BitBake Persistent Data Store - - Used to store data in a central location such that other threads/tasks can - access them at some future date. - - The "domain" is used as a key to isolate each data pool and in this - implementation corresponds to an SQL table. The SQL table consists of a - simple key and value pair. - - Why sqlite? It handles all the locking issues for us. - """ - def __init__(self, d): - self.cachedir = bb.data.getVar("CACHE", d, True) - if self.cachedir in [None, '']: - bb.msg.fatal(bb.msg.domain.PersistData, "Please set the 'CACHE' variable.") - try: - os.stat(self.cachedir) - except OSError: - bb.mkdirhier(self.cachedir) - - self.cachefile = os.path.join(self.cachedir,"bb_persist_data.sqlite3") - bb.msg.debug(1, bb.msg.domain.PersistData, "Using '%s' as the persistent data cache" % self.cachefile) - - self.connection = sqlite3.connect(self.cachefile, timeout=5, isolation_level=None) - - def addDomain(self, domain): - """ - Should be called before any domain is used - Creates it if it doesn't exist. - """ - self.connection.execute("CREATE TABLE IF NOT EXISTS %s(key TEXT, value TEXT);" % domain) - - def delDomain(self, domain): - """ - Removes a domain and all the data it contains - """ - self.connection.execute("DROP TABLE IF EXISTS %s;" % domain) - - def getValue(self, domain, key): - """ - Return the value of a key for a domain - """ - data = self.connection.execute("SELECT * from %s where key=?;" % domain, [key]) - for row in data: - return row[1] - - def setValue(self, domain, key, value): - """ - Sets the value of a key for a domain - """ - data = self.connection.execute("SELECT * from %s where key=?;" % domain, [key]) - rows = 0 - for row in data: - rows = rows + 1 - if rows: - self._execute("UPDATE %s SET value=? WHERE key=?;" % domain, [value, key]) - else: - self._execute("INSERT into %s(key, value) values (?, ?);" % domain, [key, value]) - - def delValue(self, domain, key): - """ - Deletes a key/value pair - """ - self._execute("DELETE from %s where key=?;" % domain, [key]) - - def _execute(self, *query): - while True: - try: - self.connection.execute(*query) - return - except sqlite3.OperationalError, e: - if 'database is locked' in str(e): - continue - raise - - - diff --git a/bitbake/lib/bb/providers.py b/bitbake/lib/bb/providers.py deleted file mode 100644 index 2f6b620b3d..0000000000 --- a/bitbake/lib/bb/providers.py +++ /dev/null @@ -1,325 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -# -# Copyright (C) 2003, 2004 Chris Larson -# Copyright (C) 2003, 2004 Phil Blundell -# Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer -# Copyright (C) 2005 Holger Hans Peter Freyther -# Copyright (C) 2005 ROAD GmbH -# Copyright (C) 2006 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. -# -# 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 os, re -from bb import data, utils -import bb - -class NoProvider(Exception): - """Exception raised when no provider of a build dependency can be found""" - -class NoRProvider(Exception): - """Exception raised when no provider of a runtime dependency can be found""" - - -def sortPriorities(pn, dataCache, pkg_pn = None): - """ - Reorder pkg_pn by file priority and default preference - """ - - if not pkg_pn: - pkg_pn = dataCache.pkg_pn - - files = pkg_pn[pn] - priorities = {} - for f in files: - priority = dataCache.bbfile_priority[f] - preference = dataCache.pkg_dp[f] - if priority not in priorities: - priorities[priority] = {} - if preference not in priorities[priority]: - priorities[priority][preference] = [] - priorities[priority][preference].append(f) - pri_list = priorities.keys() - pri_list.sort(lambda a, b: a - b) - tmp_pn = [] - for pri in pri_list: - pref_list = priorities[pri].keys() - pref_list.sort(lambda a, b: b - a) - tmp_pref = [] - for pref in pref_list: - tmp_pref.extend(priorities[pri][pref]) - tmp_pn = [tmp_pref] + tmp_pn - - return tmp_pn - - -def findPreferredProvider(pn, cfgData, dataCache, pkg_pn = None, item = None): - """ - Find the first provider in pkg_pn with a PREFERRED_VERSION set. - """ - - preferred_file = None - preferred_ver = None - - localdata = data.createCopy(cfgData) - bb.data.setVar('OVERRIDES', "pn-%s:%s:%s" % (pn, pn, data.getVar('OVERRIDES', localdata)), localdata) - bb.data.update_data(localdata) - - preferred_v = bb.data.getVar('PREFERRED_VERSION_%s' % pn, localdata, True) - if preferred_v: - m = re.match('(\d+:)*(.*)(_.*)*', preferred_v) - if m: - if m.group(1): - preferred_e = int(m.group(1)[:-1]) - else: - preferred_e = None - preferred_v = m.group(2) - if m.group(3): - preferred_r = m.group(3)[1:] - else: - preferred_r = None - else: - preferred_e = None - preferred_r = None - - for file_set in pkg_pn: - for f in file_set: - pe,pv,pr = dataCache.pkg_pepvpr[f] - if preferred_v == pv and (preferred_r == pr or preferred_r == None) and (preferred_e == pe or preferred_e == None): - preferred_file = f - preferred_ver = (pe, pv, pr) - break - if preferred_file: - break; - if preferred_r: - pv_str = '%s-%s' % (preferred_v, preferred_r) - else: - pv_str = preferred_v - if not (preferred_e is None): - pv_str = '%s:%s' % (preferred_e, pv_str) - itemstr = "" - if item: - itemstr = " (for item %s)" % item - if preferred_file is None: - bb.msg.note(1, bb.msg.domain.Provider, "preferred version %s of %s not available%s" % (pv_str, pn, itemstr)) - else: - bb.msg.debug(1, bb.msg.domain.Provider, "selecting %s as PREFERRED_VERSION %s of package %s%s" % (preferred_file, pv_str, pn, itemstr)) - - return (preferred_ver, preferred_file) - - -def findLatestProvider(pn, cfgData, dataCache, file_set): - """ - Return the highest version of the providers in file_set. - Take default preferences into account. - """ - latest = None - latest_p = 0 - latest_f = None - for file_name in file_set: - pe,pv,pr = dataCache.pkg_pepvpr[file_name] - dp = dataCache.pkg_dp[file_name] - - if (latest is None) or ((latest_p == dp) and (utils.vercmp(latest, (pe, pv, pr)) < 0)) or (dp > latest_p): - latest = (pe, pv, pr) - latest_f = file_name - latest_p = dp - - return (latest, latest_f) - - -def findBestProvider(pn, cfgData, dataCache, pkg_pn = None, item = None): - """ - If there is a PREFERRED_VERSION, find the highest-priority bbfile - providing that version. If not, find the latest version provided by - an bbfile in the highest-priority set. - """ - - sortpkg_pn = sortPriorities(pn, dataCache, pkg_pn) - # Find the highest priority provider with a PREFERRED_VERSION set - (preferred_ver, preferred_file) = findPreferredProvider(pn, cfgData, dataCache, sortpkg_pn, item) - # Find the latest version of the highest priority provider - (latest, latest_f) = findLatestProvider(pn, cfgData, dataCache, sortpkg_pn[0]) - - if preferred_file is None: - preferred_file = latest_f - preferred_ver = latest - - return (latest, latest_f, preferred_ver, preferred_file) - - -def _filterProviders(providers, item, cfgData, dataCache): - """ - Take a list of providers and filter/reorder according to the - environment variables and previous build results - """ - eligible = [] - preferred_versions = {} - sortpkg_pn = {} - - # The order of providers depends on the order of the files on the disk - # up to here. Sort pkg_pn to make dependency issues reproducible rather - # than effectively random. - providers.sort() - - # Collate providers by PN - pkg_pn = {} - for p in providers: - pn = dataCache.pkg_fn[p] - if pn not in pkg_pn: - pkg_pn[pn] = [] - pkg_pn[pn].append(p) - - bb.msg.debug(1, bb.msg.domain.Provider, "providers for %s are: %s" % (item, pkg_pn.keys())) - - # First add PREFERRED_VERSIONS - for pn in pkg_pn.keys(): - sortpkg_pn[pn] = sortPriorities(pn, dataCache, pkg_pn) - preferred_versions[pn] = findPreferredProvider(pn, cfgData, dataCache, sortpkg_pn[pn], item) - if preferred_versions[pn][1]: - eligible.append(preferred_versions[pn][1]) - - # Now add latest verisons - for pn in pkg_pn.keys(): - if pn in preferred_versions and preferred_versions[pn][1]: - continue - preferred_versions[pn] = findLatestProvider(pn, cfgData, dataCache, sortpkg_pn[pn][0]) - eligible.append(preferred_versions[pn][1]) - - if len(eligible) == 0: - bb.msg.error(bb.msg.domain.Provider, "no eligible providers for %s" % item) - return 0 - - # If pn == item, give it a slight default preference - # This means PREFERRED_PROVIDER_foobar defaults to foobar if available - for p in providers: - pn = dataCache.pkg_fn[p] - if pn != item: - continue - (newvers, fn) = preferred_versions[pn] - if not fn in eligible: - continue - eligible.remove(fn) - eligible = [fn] + eligible - - # look to see if one of them is already staged, or marked as preferred. - # if so, bump it to the head of the queue - for p in providers: - pn = dataCache.pkg_fn[p] - pe, pv, pr = dataCache.pkg_pepvpr[p] - - stamp = '%s.do_populate_staging' % dataCache.stamp[p] - if os.path.exists(stamp): - (newvers, fn) = preferred_versions[pn] - if not fn in eligible: - # package was made ineligible by already-failed check - continue - oldver = "%s-%s" % (pv, pr) - if pe > 0: - oldver = "%s:%s" % (pe, oldver) - newver = "%s-%s" % (newvers[1], newvers[2]) - if newvers[0] > 0: - newver = "%s:%s" % (newvers[0], newver) - if (newver != oldver): - extra_chat = "%s (%s) already staged but upgrading to %s to satisfy %s" % (pn, oldver, newver, item) - else: - extra_chat = "Selecting already-staged %s (%s) to satisfy %s" % (pn, oldver, item) - - bb.msg.note(2, bb.msg.domain.Provider, "%s" % extra_chat) - eligible.remove(fn) - eligible = [fn] + eligible - break - - return eligible - - -def filterProviders(providers, item, cfgData, dataCache): - """ - Take a list of providers and filter/reorder according to the - environment variables and previous build results - Takes a "normal" target item - """ - - eligible = _filterProviders(providers, item, cfgData, dataCache) - - prefervar = bb.data.getVar('PREFERRED_PROVIDER_%s' % item, cfgData, 1) - if prefervar: - dataCache.preferred[item] = prefervar - - foundUnique = False - if item in dataCache.preferred: - for p in eligible: - pn = dataCache.pkg_fn[p] - if dataCache.preferred[item] == pn: - bb.msg.note(2, bb.msg.domain.Provider, "selecting %s to satisfy %s due to PREFERRED_PROVIDERS" % (pn, item)) - eligible.remove(p) - eligible = [p] + eligible - foundUnique = True - break - - bb.msg.debug(1, bb.msg.domain.Provider, "sorted providers for %s are: %s" % (item, eligible)) - - return eligible, foundUnique - -def filterProvidersRunTime(providers, item, cfgData, dataCache): - """ - Take a list of providers and filter/reorder according to the - environment variables and previous build results - Takes a "runtime" target item - """ - - eligible = _filterProviders(providers, item, cfgData, dataCache) - - # Should use dataCache.preferred here? - preferred = [] - for p in eligible: - pn = dataCache.pkg_fn[p] - provides = dataCache.pn_provides[pn] - for provide in provides: - prefervar = bb.data.getVar('PREFERRED_PROVIDER_%s' % provide, cfgData, 1) - if prefervar == pn: - bb.msg.note(2, bb.msg.domain.Provider, "selecting %s to satisfy runtime %s due to PREFERRED_PROVIDERS" % (pn, item)) - eligible.remove(p) - eligible = [p] + eligible - preferred.append(p) - break - - numberPreferred = len(preferred) - - bb.msg.debug(1, bb.msg.domain.Provider, "sorted providers for %s are: %s" % (item, eligible)) - - return eligible, numberPreferred - -def getRuntimeProviders(dataCache, rdepend): - """ - Return any providers of runtime dependency - """ - rproviders = [] - - if rdepend in dataCache.rproviders: - rproviders += dataCache.rproviders[rdepend] - - if rdepend in dataCache.packages: - rproviders += dataCache.packages[rdepend] - - if rproviders: - return rproviders - - # Only search dynamic packages if we can't find anything in other variables - for pattern in dataCache.packages_dynamic: - regexp = re.compile(pattern) - if regexp.match(rdepend): - rproviders += dataCache.packages_dynamic[pattern] - - return rproviders diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py deleted file mode 100644 index f245fd6c1d..0000000000 --- a/bitbake/lib/bb/runqueue.py +++ /dev/null @@ -1,646 +0,0 @@ -#!/usr/bin/env python -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'RunQueue' implementation - -Handles preparation and execution of a queue of tasks -""" - -# Copyright (C) 2006-2007 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. -# -# 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. - -from bb import msg, data, event, mkdirhier, utils -from sets import Set -import bb, os, sys -import signal - -class TaskFailure(Exception): - """Exception raised when a task in a runqueue fails""" - def __init__(self, x): - self.args = x - - -class RunQueueStats: - """ - Holds statistics on the tasks handled by the associated runQueue - """ - def __init__(self): - self.completed = 0 - self.skipped = 0 - self.failed = 0 - - def taskFailed(self): - self.failed = self.failed + 1 - - def taskCompleted(self): - self.completed = self.completed + 1 - - def taskSkipped(self): - self.skipped = self.skipped + 1 - -class RunQueue: - """ - BitBake Run Queue implementation - """ - def __init__(self, cooker, cfgData, dataCache, taskData, targets): - self.reset_runqueue() - self.cooker = cooker - self.dataCache = dataCache - self.taskData = taskData - self.targets = targets - - self.number_tasks = int(bb.data.getVar("BB_NUMBER_THREADS", cfgData) or 1) - self.multi_provider_whitelist = (bb.data.getVar("MULTI_PROVIDER_WHITELIST", cfgData) or "").split() - - def reset_runqueue(self): - - self.runq_fnid = [] - self.runq_task = [] - self.runq_depends = [] - self.runq_revdeps = [] - self.runq_weight = [] - self.prio_map = [] - - def get_user_idstring(self, task): - fn = self.taskData.fn_index[self.runq_fnid[task]] - taskname = self.runq_task[task] - return "%s, %s" % (fn, taskname) - - def prepare_runqueue(self): - """ - Turn a set of taskData into a RunQueue and compute data needed - to optimise the execution order. - """ - - depends = [] - runq_weight1 = [] - runq_build = [] - runq_done = [] - - taskData = self.taskData - - if len(taskData.tasks_name) == 0: - # Nothing to do - return - - bb.msg.note(1, bb.msg.domain.RunQueue, "Preparing runqueue") - - for task in range(len(taskData.tasks_name)): - fnid = taskData.tasks_fnid[task] - fn = taskData.fn_index[fnid] - task_deps = self.dataCache.task_deps[fn] - - if fnid not in taskData.failed_fnids: - - depends = taskData.tasks_tdepends[task] - - # Resolve Depends - if 'deptask' in task_deps and taskData.tasks_name[task] in task_deps['deptask']: - taskname = task_deps['deptask'][taskData.tasks_name[task]] - for depid in taskData.depids[fnid]: - # Won't be in build_targets if ASSUME_PROVIDED - if depid in taskData.build_targets: - depdata = taskData.build_targets[depid][0] - if depdata is not None: - dep = taskData.fn_index[depdata] - depends.append(taskData.gettask_id(dep, taskname)) - - # Resolve Runtime Depends - if 'rdeptask' in task_deps and taskData.tasks_name[task] in task_deps['rdeptask']: - taskname = task_deps['rdeptask'][taskData.tasks_name[task]] - for depid in taskData.rdepids[fnid]: - if depid in taskData.run_targets: - depdata = taskData.run_targets[depid][0] - if depdata is not None: - dep = taskData.fn_index[depdata] - depends.append(taskData.gettask_id(dep, taskname)) - - idepends = taskData.tasks_idepends[task] - for idepend in idepends: - depid = int(idepend.split(":")[0]) - if depid in taskData.build_targets: - # Won't be in build_targets if ASSUME_PROVIDED - depdata = taskData.build_targets[depid][0] - if depdata is not None: - dep = taskData.fn_index[depdata] - depends.append(taskData.gettask_id(dep, idepend.split(":")[1])) - - def add_recursive_build(depid, depfnid): - """ - Add build depends of depid to depends - (if we've not see it before) - (calls itself recursively) - """ - if str(depid) in dep_seen: - return - dep_seen.append(depid) - if depid in taskData.build_targets: - depdata = taskData.build_targets[depid][0] - if depdata is not None: - dep = taskData.fn_index[depdata] - idepends = [] - # Need to avoid creating new tasks here - taskid = taskData.gettask_id(dep, taskname, False) - if taskid is not None: - depends.append(taskid) - fnid = taskData.tasks_fnid[taskid] - idepends = taskData.tasks_idepends[taskid] - #print "Added %s (%s) due to %s" % (taskid, taskData.fn_index[fnid], taskData.fn_index[depfnid]) - else: - fnid = taskData.getfn_id(dep) - for nextdepid in taskData.depids[fnid]: - if nextdepid not in dep_seen: - add_recursive_build(nextdepid, fnid) - for nextdepid in taskData.rdepids[fnid]: - if nextdepid not in rdep_seen: - add_recursive_run(nextdepid, fnid) - for idepend in idepends: - nextdepid = int(idepend.split(":")[0]) - if nextdepid not in dep_seen: - add_recursive_build(nextdepid, fnid) - - def add_recursive_run(rdepid, depfnid): - """ - Add runtime depends of rdepid to depends - (if we've not see it before) - (calls itself recursively) - """ - if str(rdepid) in rdep_seen: - return - rdep_seen.append(rdepid) - if rdepid in taskData.run_targets: - depdata = taskData.run_targets[rdepid][0] - if depdata is not None: - dep = taskData.fn_index[depdata] - idepends = [] - # Need to avoid creating new tasks here - taskid = taskData.gettask_id(dep, taskname, False) - if taskid is not None: - depends.append(taskid) - fnid = taskData.tasks_fnid[taskid] - idepends = taskData.tasks_idepends[taskid] - #print "Added %s (%s) due to %s" % (taskid, taskData.fn_index[fnid], taskData.fn_index[depfnid]) - else: - fnid = taskData.getfn_id(dep) - for nextdepid in taskData.depids[fnid]: - if nextdepid not in dep_seen: - add_recursive_build(nextdepid, fnid) - for nextdepid in taskData.rdepids[fnid]: - if nextdepid not in rdep_seen: - add_recursive_run(nextdepid, fnid) - for idepend in idepends: - nextdepid = int(idepend.split(":")[0]) - if nextdepid not in dep_seen: - add_recursive_build(nextdepid, fnid) - - - # Resolve Recursive Runtime Depends - # Also includes all thier build depends, intertask depends and runtime depends - if 'recrdeptask' in task_deps and taskData.tasks_name[task] in task_deps['recrdeptask']: - for taskname in task_deps['recrdeptask'][taskData.tasks_name[task]].split(): - dep_seen = [] - rdep_seen = [] - idep_seen = [] - for depid in taskData.depids[fnid]: - add_recursive_build(depid, fnid) - for rdepid in taskData.rdepids[fnid]: - add_recursive_run(rdepid, fnid) - for idepend in idepends: - depid = int(idepend.split(":")[0]) - add_recursive_build(depid, fnid) - - #Prune self references - if task in depends: - newdep = [] - bb.msg.debug(2, bb.msg.domain.RunQueue, "Task %s (%s %s) contains self reference! %s" % (task, taskData.fn_index[taskData.tasks_fnid[task]], taskData.tasks_name[task], depends)) - for dep in depends: - if task != dep: - newdep.append(dep) - depends = newdep - - - self.runq_fnid.append(taskData.tasks_fnid[task]) - self.runq_task.append(taskData.tasks_name[task]) - self.runq_depends.append(Set(depends)) - self.runq_revdeps.append(Set()) - self.runq_weight.append(0) - - runq_weight1.append(0) - runq_build.append(0) - runq_done.append(0) - - bb.msg.note(2, bb.msg.domain.RunQueue, "Marking Active Tasks") - - def mark_active(listid, depth): - """ - Mark an item as active along with its depends - (calls itself recursively) - """ - - if runq_build[listid] == 1: - return - - runq_build[listid] = 1 - - depends = self.runq_depends[listid] - for depend in depends: - mark_active(depend, depth+1) - - for target in self.targets: - targetid = taskData.getbuild_id(target[0]) - - if targetid not in taskData.build_targets: - continue - - if targetid in taskData.failed_deps: - continue - - fnid = taskData.build_targets[targetid][0] - - # Remove stamps for targets if force mode active - if self.cooker.configuration.force: - fn = taskData.fn_index[fnid] - bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (target[1], fn)) - bb.build.del_stamp(target[1], self.dataCache, fn) - - if fnid in taskData.failed_fnids: - continue - - listid = taskData.tasks_lookup[fnid][target[1]] - - mark_active(listid, 1) - - # Prune inactive tasks - maps = [] - delcount = 0 - for listid in range(len(self.runq_fnid)): - if runq_build[listid-delcount] == 1: - maps.append(listid-delcount) - else: - del self.runq_fnid[listid-delcount] - del self.runq_task[listid-delcount] - del self.runq_depends[listid-delcount] - del self.runq_weight[listid-delcount] - del runq_weight1[listid-delcount] - del runq_build[listid-delcount] - del runq_done[listid-delcount] - del self.runq_revdeps[listid-delcount] - delcount = delcount + 1 - maps.append(-1) - - if len(self.runq_fnid) == 0: - if not taskData.abort: - bb.msg.note(1, bb.msg.domain.RunQueue, "All possible tasks have been run but build incomplete (--continue mode). See errors above for incomplete tasks.") - return - bb.msg.fatal(bb.msg.domain.RunQueue, "No active tasks and not in --continue mode?! Please report this bug.") - - bb.msg.note(2, bb.msg.domain.RunQueue, "Pruned %s inactive tasks, %s left" % (delcount, len(self.runq_fnid))) - - for listid in range(len(self.runq_fnid)): - newdeps = [] - origdeps = self.runq_depends[listid] - for origdep in origdeps: - if maps[origdep] == -1: - bb.msg.fatal(bb.msg.domain.RunQueue, "Invalid mapping - Should never happen!") - newdeps.append(maps[origdep]) - self.runq_depends[listid] = Set(newdeps) - - bb.msg.note(2, bb.msg.domain.RunQueue, "Assign Weightings") - - for listid in range(len(self.runq_fnid)): - for dep in self.runq_depends[listid]: - self.runq_revdeps[dep].add(listid) - - endpoints = [] - for listid in range(len(self.runq_fnid)): - revdeps = self.runq_revdeps[listid] - if len(revdeps) == 0: - runq_done[listid] = 1 - self.runq_weight[listid] = 1 - endpoints.append(listid) - for dep in revdeps: - if dep in self.runq_depends[listid]: - #self.dump_data(taskData) - bb.msg.fatal(bb.msg.domain.RunQueue, "Task %s (%s) has circular dependency on %s (%s)" % (taskData.fn_index[self.runq_fnid[dep]], self.runq_task[dep] , taskData.fn_index[self.runq_fnid[listid]], self.runq_task[listid])) - runq_weight1[listid] = len(revdeps) - - bb.msg.note(2, bb.msg.domain.RunQueue, "Compute totals (have %s endpoint(s))" % len(endpoints)) - - while 1: - next_points = [] - for listid in endpoints: - for revdep in self.runq_depends[listid]: - self.runq_weight[revdep] = self.runq_weight[revdep] + self.runq_weight[listid] - runq_weight1[revdep] = runq_weight1[revdep] - 1 - if runq_weight1[revdep] == 0: - next_points.append(revdep) - runq_done[revdep] = 1 - endpoints = next_points - if len(next_points) == 0: - break - - # Sanity Checks - for task in range(len(self.runq_fnid)): - if runq_done[task] == 0: - seen = [] - deps_seen = [] - def print_chain(taskid, finish): - seen.append(taskid) - for revdep in self.runq_revdeps[taskid]: - if runq_done[revdep] == 0 and revdep not in seen and not finish: - bb.msg.error(bb.msg.domain.RunQueue, "Task %s (%s) (depends: %s)" % (revdep, self.get_user_idstring(revdep), self.runq_depends[revdep])) - if revdep in deps_seen: - bb.msg.error(bb.msg.domain.RunQueue, "Chain ends at Task %s (%s)" % (revdep, self.get_user_idstring(revdep))) - finish = True - return - for dep in self.runq_depends[revdep]: - deps_seen.append(dep) - print_chain(revdep, finish) - print_chain(task, False) - bb.msg.fatal(bb.msg.domain.RunQueue, "Task %s (%s) not processed!\nThis is probably a circular dependency (the chain might be printed above)." % (task, self.get_user_idstring(task))) - if runq_weight1[task] != 0: - bb.msg.fatal(bb.msg.domain.RunQueue, "Task %s (%s) count not zero!" % (task, self.get_user_idstring(task))) - - - # Check for mulitple taska building the same provider - prov_list = {} - seen_fn = [] - for task in range(len(self.runq_fnid)): - fn = taskData.fn_index[self.runq_fnid[task]] - if fn in seen_fn: - continue - seen_fn.append(fn) - for prov in self.dataCache.fn_provides[fn]: - if prov not in prov_list: - prov_list[prov] = [fn] - elif fn not in prov_list[prov]: - prov_list[prov].append(fn) - error = False - for prov in prov_list: - if len(prov_list[prov]) > 1 and prov not in self.multi_provider_whitelist: - error = True - bb.msg.error(bb.msg.domain.RunQueue, "Multiple files due to be built which all provide %s (%s)" % (prov, " ".join(prov_list[prov]))) - #if error: - # bb.msg.fatal(bb.msg.domain.RunQueue, "Corrupted metadata configuration detected, aborting...") - - - # Make a weight sorted map - from copy import deepcopy - - sortweight = deepcopy(self.runq_weight) - sortweight.sort() - copyweight = deepcopy(self.runq_weight) - self.prio_map = [] - - for weight in sortweight: - idx = copyweight.index(weight) - self.prio_map.append(idx) - copyweight[idx] = -1 - self.prio_map.reverse() - - #self.dump_data(taskData) - - def execute_runqueue(self): - """ - Run the tasks in a queue prepared by prepare_runqueue - Upon failure, optionally try to recover the build using any alternate providers - (if the abort on failure configuration option isn't set) - """ - - failures = 0 - while 1: - failed_fnids = [] - try: - self.execute_runqueue_internal() - finally: - if self.master_process: - failed_fnids = self.finish_runqueue() - if len(failed_fnids) == 0: - return failures - if self.taskData.abort: - raise bb.runqueue.TaskFailure(failed_fnids) - for fnid in failed_fnids: - #print "Failure: %s %s %s" % (fnid, self.taskData.fn_index[fnid], self.runq_task[fnid]) - self.taskData.fail_fnid(fnid) - failures = failures + 1 - self.reset_runqueue() - self.prepare_runqueue() - - def execute_runqueue_initVars(self): - - self.stats = RunQueueStats() - - self.active_builds = 0 - self.runq_buildable = [] - self.runq_running = [] - self.runq_complete = [] - self.build_pids = {} - self.failed_fnids = [] - self.master_process = True - - # Mark initial buildable tasks - for task in range(len(self.runq_fnid)): - self.runq_running.append(0) - self.runq_complete.append(0) - if len(self.runq_depends[task]) == 0: - self.runq_buildable.append(1) - else: - self.runq_buildable.append(0) - - def task_complete(self, task): - """ - Mark a task as completed - Look at the reverse dependencies and mark any task with - completed dependencies as buildable - """ - self.runq_complete[task] = 1 - for revdep in self.runq_revdeps[task]: - if self.runq_running[revdep] == 1: - continue - if self.runq_buildable[revdep] == 1: - continue - alldeps = 1 - for dep in self.runq_depends[revdep]: - if self.runq_complete[dep] != 1: - alldeps = 0 - if alldeps == 1: - self.runq_buildable[revdep] = 1 - fn = self.taskData.fn_index[self.runq_fnid[revdep]] - taskname = self.runq_task[revdep] - bb.msg.debug(1, bb.msg.domain.RunQueue, "Marking task %s (%s, %s) as buildable" % (revdep, fn, taskname)) - - def get_next_task(self): - """ - Return the id of the highest priority task that is buildable - """ - for task1 in range(len(self.runq_fnid)): - task = self.prio_map[task1] - if self.runq_running[task] == 1: - continue - if self.runq_buildable[task] == 1: - return task - return None - - def execute_runqueue_internal(self): - """ - Run the tasks in a queue prepared by prepare_runqueue - """ - - bb.msg.note(1, bb.msg.domain.RunQueue, "Executing runqueue") - - self.execute_runqueue_initVars() - - if len(self.runq_fnid) == 0: - # nothing to do - return [] - - def sigint_handler(signum, frame): - raise KeyboardInterrupt - - # Find any tasks with current stamps and remove them from the queue - for task1 in range(len(self.runq_fnid)): - task = self.prio_map[task1] - fn = self.taskData.fn_index[self.runq_fnid[task]] - taskname = self.runq_task[task] - if bb.build.stamp_is_current(taskname, self.dataCache, fn): - bb.msg.debug(2, bb.msg.domain.RunQueue, "Stamp current task %s (%s)" % (task, self.get_user_idstring(task))) - self.runq_running[task] = 1 - self.task_complete(task) - self.stats.taskCompleted() - self.stats.taskSkipped() - - while True: - task = self.get_next_task() - if task is not None: - fn = self.taskData.fn_index[self.runq_fnid[task]] - - taskname = self.runq_task[task] - if bb.build.stamp_is_current(taskname, self.dataCache, fn): - bb.msg.debug(2, bb.msg.domain.RunQueue, "Stamp current task %s (%s)" % (task, self.get_user_idstring(task))) - self.runq_running[task] = 1 - self.task_complete(task) - self.stats.taskCompleted() - self.stats.taskSkipped() - continue - - bb.msg.note(1, bb.msg.domain.RunQueue, "Running task %d of %d (ID: %s, %s)" % (self.stats.completed + self.active_builds + 1, len(self.runq_fnid), task, self.get_user_idstring(task))) - try: - pid = os.fork() - except OSError, e: - bb.msg.fatal(bb.msg.domain.RunQueue, "fork failed: %d (%s)" % (e.errno, e.strerror)) - if pid == 0: - # Bypass master process' handling - self.master_process = False - # Stop Ctrl+C being sent to children - # signal.signal(signal.SIGINT, signal.SIG_IGN) - # Make the child the process group leader - os.setpgid(0, 0) - newsi = os.open('/dev/null', os.O_RDWR) - os.dup2(newsi, sys.stdin.fileno()) - self.cooker.configuration.cmd = taskname[3:] - try: - self.cooker.tryBuild(fn, False) - except bb.build.EventException: - bb.msg.error(bb.msg.domain.Build, "Build of " + fn + " " + taskname + " failed") - sys.exit(1) - except: - bb.msg.error(bb.msg.domain.Build, "Build of " + fn + " " + taskname + " failed") - raise - sys.exit(0) - self.build_pids[pid] = task - self.runq_running[task] = 1 - self.active_builds = self.active_builds + 1 - if self.active_builds < self.number_tasks: - continue - if self.active_builds > 0: - result = os.waitpid(-1, 0) - self.active_builds = self.active_builds - 1 - task = self.build_pids[result[0]] - if result[1] != 0: - del self.build_pids[result[0]] - bb.msg.error(bb.msg.domain.RunQueue, "Task %s (%s) failed" % (task, self.get_user_idstring(task))) - self.failed_fnids.append(self.runq_fnid[task]) - self.stats.taskFailed() - break - self.task_complete(task) - self.stats.taskCompleted() - del self.build_pids[result[0]] - continue - return - - def finish_runqueue(self): - try: - while self.active_builds > 0: - bb.msg.note(1, bb.msg.domain.RunQueue, "Waiting for %s active tasks to finish" % self.active_builds) - tasknum = 1 - for k, v in self.build_pids.iteritems(): - bb.msg.note(1, bb.msg.domain.RunQueue, "%s: %s (%s)" % (tasknum, self.get_user_idstring(v), k)) - tasknum = tasknum + 1 - result = os.waitpid(-1, 0) - task = self.build_pids[result[0]] - if result[1] != 0: - bb.msg.error(bb.msg.domain.RunQueue, "Task %s (%s) failed" % (task, self.get_user_idstring(task))) - self.failed_fnids.append(self.runq_fnid[task]) - self.stats.taskFailed() - del self.build_pids[result[0]] - self.active_builds = self.active_builds - 1 - bb.msg.note(1, bb.msg.domain.RunQueue, "Tasks Summary: Attempted %d tasks of which %d didn't need to be rerun and %d failed." % (self.stats.completed, self.stats.skipped, self.stats.failed)) - return self.failed_fnids - except KeyboardInterrupt: - bb.msg.note(1, bb.msg.domain.RunQueue, "Sending SIGINT to remaining %s tasks" % self.active_builds) - for k, v in self.build_pids.iteritems(): - try: - os.kill(-k, signal.SIGINT) - except: - pass - raise - - # Sanity Checks - for task in range(len(self.runq_fnid)): - if self.runq_buildable[task] == 0: - bb.msg.error(bb.msg.domain.RunQueue, "Task %s never buildable!" % task) - if self.runq_running[task] == 0: - bb.msg.error(bb.msg.domain.RunQueue, "Task %s never ran!" % task) - if self.runq_complete[task] == 0: - bb.msg.error(bb.msg.domain.RunQueue, "Task %s never completed!" % task) - - bb.msg.note(1, bb.msg.domain.RunQueue, "Tasks Summary: Attempted %d tasks of which %d didn't need to be rerun and %d failed." % (self.stats.completed, self.stats.skipped, self.stats.failed)) - - return self.failed_fnids - - def dump_data(self, taskQueue): - """ - Dump some debug information on the internal data structures - """ - bb.msg.debug(3, bb.msg.domain.RunQueue, "run_tasks:") - for task in range(len(self.runq_fnid)): - bb.msg.debug(3, bb.msg.domain.RunQueue, " (%s)%s - %s: %s Deps %s RevDeps %s" % (task, - taskQueue.fn_index[self.runq_fnid[task]], - self.runq_task[task], - self.runq_weight[task], - self.runq_depends[task], - self.runq_revdeps[task])) - - bb.msg.debug(3, bb.msg.domain.RunQueue, "sorted_tasks:") - for task1 in range(len(self.runq_fnid)): - if task1 in self.prio_map: - task = self.prio_map[task1] - bb.msg.debug(3, bb.msg.domain.RunQueue, " (%s)%s - %s: %s Deps %s RevDeps %s" % (task, - taskQueue.fn_index[self.runq_fnid[task]], - self.runq_task[task], - self.runq_weight[task], - self.runq_depends[task], - self.runq_revdeps[task])) diff --git a/bitbake/lib/bb/shell.py b/bitbake/lib/bb/shell.py deleted file mode 100644 index fc213c3f4a..0000000000 --- a/bitbake/lib/bb/shell.py +++ /dev/null @@ -1,838 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -########################################################################## -# -# Copyright (C) 2005-2006 Michael 'Mickey' Lauer <mickey@Vanille.de> -# Copyright (C) 2005-2006 Vanille Media -# -# 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. -# -# 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. -# -########################################################################## -# -# Thanks to: -# * Holger Freyther <zecke@handhelds.org> -# * Justin Patrin <papercrane@reversefold.com> -# -########################################################################## - -""" -BitBake Shell - -IDEAS: - * list defined tasks per package - * list classes - * toggle force - * command to reparse just one (or more) bbfile(s) - * automatic check if reparsing is necessary (inotify?) - * frontend for bb file manipulation - * more shell-like features: - - output control, i.e. pipe output into grep, sort, etc. - - job control, i.e. bring running commands into background and foreground - * start parsing in background right after startup - * ncurses interface - -PROBLEMS: - * force doesn't always work - * readline completion for commands with more than one parameters - -""" - -########################################################################## -# Import and setup global variables -########################################################################## - -try: - set -except NameError: - from sets import Set as set -import sys, os, readline, socket, httplib, urllib, commands, popen2, copy, shlex, Queue, fnmatch -from bb import data, parse, build, fatal, cache, taskdata, runqueue, providers as Providers - -__version__ = "0.5.3.1" -__credits__ = """BitBake Shell Version %s (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> -Type 'help' for more information, press CTRL-D to exit.""" % __version__ - -cmds = {} -leave_mainloop = False -last_exception = None -cooker = None -parsed = False -initdata = None -debug = os.environ.get( "BBSHELL_DEBUG", "" ) - -########################################################################## -# Class BitBakeShellCommands -########################################################################## - -class BitBakeShellCommands: - """This class contains the valid commands for the shell""" - - def __init__( self, shell ): - """Register all the commands""" - self._shell = shell - for attr in BitBakeShellCommands.__dict__: - if not attr.startswith( "_" ): - if attr.endswith( "_" ): - command = attr[:-1].lower() - else: - command = attr[:].lower() - method = getattr( BitBakeShellCommands, attr ) - debugOut( "registering command '%s'" % command ) - # scan number of arguments - usage = getattr( method, "usage", "" ) - if usage != "<...>": - numArgs = len( usage.split() ) - else: - numArgs = -1 - shell.registerCommand( command, method, numArgs, "%s %s" % ( command, usage ), method.__doc__ ) - - def _checkParsed( self ): - if not parsed: - print "SHELL: This command needs to parse bbfiles..." - self.parse( None ) - - def _findProvider( self, item ): - self._checkParsed() - # Need to use taskData for this information - preferred = data.getVar( "PREFERRED_PROVIDER_%s" % item, cooker.configuration.data, 1 ) - if not preferred: preferred = item - try: - lv, lf, pv, pf = Providers.findBestProvider(preferred, cooker.configuration.data, cooker.status) - except KeyError: - if item in cooker.status.providers: - pf = cooker.status.providers[item][0] - else: - pf = None - return pf - - def alias( self, params ): - """Register a new name for a command""" - new, old = params - if not old in cmds: - print "ERROR: Command '%s' not known" % old - else: - cmds[new] = cmds[old] - print "OK" - alias.usage = "<alias> <command>" - - def buffer( self, params ): - """Dump specified output buffer""" - index = params[0] - print self._shell.myout.buffer( int( index ) ) - buffer.usage = "<index>" - - def buffers( self, params ): - """Show the available output buffers""" - commands = self._shell.myout.bufferedCommands() - if not commands: - print "SHELL: No buffered commands available yet. Start doing something." - else: - print "="*35, "Available Output Buffers", "="*27 - for index, cmd in enumerate( commands ): - print "| %s %s" % ( str( index ).ljust( 3 ), cmd ) - print "="*88 - - def build( self, params, cmd = "build" ): - """Build a providee""" - global last_exception - globexpr = params[0] - self._checkParsed() - names = globfilter( cooker.status.pkg_pn.keys(), globexpr ) - if len( names ) == 0: names = [ globexpr ] - print "SHELL: Building %s" % ' '.join( names ) - - oldcmd = cooker.configuration.cmd - cooker.configuration.cmd = cmd - - td = taskdata.TaskData(cooker.configuration.abort) - - try: - tasks = [] - for name in names: - td.add_provider(cooker.configuration.data, cooker.status, name) - providers = td.get_provider(name) - - if len(providers) == 0: - raise Providers.NoProvider - - tasks.append([name, "do_%s" % cooker.configuration.cmd]) - - td.add_unresolved(cooker.configuration.data, cooker.status) - - rq = runqueue.RunQueue(cooker, cooker.configuration.data, cooker.status, td, tasks) - rq.prepare_runqueue() - rq.execute_runqueue() - - except Providers.NoProvider: - print "ERROR: No Provider" - last_exception = Providers.NoProvider - - except runqueue.TaskFailure, fnids: - for fnid in fnids: - print "ERROR: '%s' failed" % td.fn_index[fnid] - last_exception = runqueue.TaskFailure - - except build.EventException, e: - print "ERROR: Couldn't build '%s'" % names - last_exception = e - - cooker.configuration.cmd = oldcmd - - build.usage = "<providee>" - - def clean( self, params ): - """Clean a providee""" - self.build( params, "clean" ) - clean.usage = "<providee>" - - def compile( self, params ): - """Execute 'compile' on a providee""" - self.build( params, "compile" ) - compile.usage = "<providee>" - - def configure( self, params ): - """Execute 'configure' on a providee""" - self.build( params, "configure" ) - configure.usage = "<providee>" - - def edit( self, params ): - """Call $EDITOR on a providee""" - name = params[0] - bbfile = self._findProvider( name ) - if bbfile is not None: - os.system( "%s %s" % ( os.environ.get( "EDITOR", "vi" ), bbfile ) ) - else: - print "ERROR: Nothing provides '%s'" % name - edit.usage = "<providee>" - - def environment( self, params ): - """Dump out the outer BitBake environment (see bbread)""" - data.emit_env(sys.__stdout__, cooker.configuration.data, True) - - def exit_( self, params ): - """Leave the BitBake Shell""" - debugOut( "setting leave_mainloop to true" ) - global leave_mainloop - leave_mainloop = True - - def fetch( self, params ): - """Fetch a providee""" - self.build( params, "fetch" ) - fetch.usage = "<providee>" - - def fileBuild( self, params, cmd = "build" ): - """Parse and build a .bb file""" - global last_exception - name = params[0] - bf = completeFilePath( name ) - print "SHELL: Calling '%s' on '%s'" % ( cmd, bf ) - - oldcmd = cooker.configuration.cmd - cooker.configuration.cmd = cmd - - thisdata = copy.deepcopy( initdata ) - # Caution: parse.handle modifies thisdata, hence it would - # lead to pollution cooker.configuration.data, which is - # why we use it on a safe copy we obtained from cooker right after - # parsing the initial *.conf files - try: - bbfile_data = parse.handle( bf, thisdata ) - except parse.ParseError: - print "ERROR: Unable to open or parse '%s'" % bf - else: - # Remove stamp for target if force mode active - if cooker.configuration.force: - bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (cmd, bf)) - bb.build.del_stamp('do_%s' % cmd, bbfile_data) - - item = data.getVar('PN', bbfile_data, 1) - data.setVar( "_task_cache", [], bbfile_data ) # force - try: - cooker.tryBuildPackage( os.path.abspath( bf ), item, cmd, bbfile_data, True ) - except build.EventException, e: - print "ERROR: Couldn't build '%s'" % name - last_exception = e - - cooker.configuration.cmd = oldcmd - fileBuild.usage = "<bbfile>" - - def fileClean( self, params ): - """Clean a .bb file""" - self.fileBuild( params, "clean" ) - fileClean.usage = "<bbfile>" - - def fileEdit( self, params ): - """Call $EDITOR on a .bb file""" - name = params[0] - os.system( "%s %s" % ( os.environ.get( "EDITOR", "vi" ), completeFilePath( name ) ) ) - fileEdit.usage = "<bbfile>" - - def fileRebuild( self, params ): - """Rebuild (clean & build) a .bb file""" - self.fileBuild( params, "rebuild" ) - fileRebuild.usage = "<bbfile>" - - def fileReparse( self, params ): - """(re)Parse a bb file""" - bbfile = params[0] - print "SHELL: Parsing '%s'" % bbfile - parse.update_mtime( bbfile ) - cooker.bb_cache.cacheValidUpdate(bbfile) - fromCache = cooker.bb_cache.loadData(bbfile, cooker.configuration.data) - cooker.bb_cache.sync() - if False: #fromCache: - print "SHELL: File has not been updated, not reparsing" - else: - print "SHELL: Parsed" - fileReparse.usage = "<bbfile>" - - def abort( self, params ): - """Toggle abort task execution flag (see bitbake -k)""" - cooker.configuration.abort = not cooker.configuration.abort - print "SHELL: Abort Flag is now '%s'" % repr( cooker.configuration.abort ) - - def force( self, params ): - """Toggle force task execution flag (see bitbake -f)""" - cooker.configuration.force = not cooker.configuration.force - print "SHELL: Force Flag is now '%s'" % repr( cooker.configuration.force ) - - def help( self, params ): - """Show a comprehensive list of commands and their purpose""" - print "="*30, "Available Commands", "="*30 - allcmds = cmds.keys() - allcmds.sort() - for cmd in allcmds: - function,numparams,usage,helptext = cmds[cmd] - print "| %s | %s" % (usage.ljust(30), helptext) - print "="*78 - - def lastError( self, params ): - """Show the reason or log that was produced by the last BitBake event exception""" - if last_exception is None: - print "SHELL: No Errors yet (Phew)..." - else: - reason, event = last_exception.args - print "SHELL: Reason for the last error: '%s'" % reason - if ':' in reason: - msg, filename = reason.split( ':' ) - filename = filename.strip() - print "SHELL: Dumping log file for last error:" - try: - print open( filename ).read() - except IOError: - print "ERROR: Couldn't open '%s'" % filename - - def match( self, params ): - """Dump all files or providers matching a glob expression""" - what, globexpr = params - if what == "files": - self._checkParsed() - for key in globfilter( cooker.status.pkg_fn.keys(), globexpr ): print key - elif what == "providers": - self._checkParsed() - for key in globfilter( cooker.status.pkg_pn.keys(), globexpr ): print key - else: - print "Usage: match %s" % self.print_.usage - match.usage = "<files|providers> <glob>" - - def new( self, params ): - """Create a new .bb file and open the editor""" - dirname, filename = params - packages = '/'.join( data.getVar( "BBFILES", cooker.configuration.data, 1 ).split('/')[:-2] ) - fulldirname = "%s/%s" % ( packages, dirname ) - - if not os.path.exists( fulldirname ): - print "SHELL: Creating '%s'" % fulldirname - os.mkdir( fulldirname ) - if os.path.exists( fulldirname ) and os.path.isdir( fulldirname ): - if os.path.exists( "%s/%s" % ( fulldirname, filename ) ): - print "SHELL: ERROR: %s/%s already exists" % ( fulldirname, filename ) - return False - print "SHELL: Creating '%s/%s'" % ( fulldirname, filename ) - newpackage = open( "%s/%s" % ( fulldirname, filename ), "w" ) - print >>newpackage,"""DESCRIPTION = "" -SECTION = "" -AUTHOR = "" -HOMEPAGE = "" -MAINTAINER = "" -LICENSE = "GPL" -PR = "r0" - -SRC_URI = "" - -#inherit base - -#do_configure() { -# -#} - -#do_compile() { -# -#} - -#do_stage() { -# -#} - -#do_install() { -# -#} -""" - newpackage.close() - os.system( "%s %s/%s" % ( os.environ.get( "EDITOR" ), fulldirname, filename ) ) - new.usage = "<directory> <filename>" - - def pasteBin( self, params ): - """Send a command + output buffer to the pastebin at http://rafb.net/paste""" - index = params[0] - contents = self._shell.myout.buffer( int( index ) ) - sendToPastebin( "output of " + params[0], contents ) - pasteBin.usage = "<index>" - - def pasteLog( self, params ): - """Send the last event exception error log (if there is one) to http://rafb.net/paste""" - if last_exception is None: - print "SHELL: No Errors yet (Phew)..." - else: - reason, event = last_exception.args - print "SHELL: Reason for the last error: '%s'" % reason - if ':' in reason: - msg, filename = reason.split( ':' ) - filename = filename.strip() - print "SHELL: Pasting log file to pastebin..." - - file = open( filename ).read() - sendToPastebin( "contents of " + filename, file ) - - def patch( self, params ): - """Execute 'patch' command on a providee""" - self.build( params, "patch" ) - patch.usage = "<providee>" - - def parse( self, params ): - """(Re-)parse .bb files and calculate the dependency graph""" - cooker.status = cache.CacheData() - ignore = data.getVar("ASSUME_PROVIDED", cooker.configuration.data, 1) or "" - cooker.status.ignored_dependencies = set( ignore.split() ) - cooker.handleCollections( data.getVar("BBFILE_COLLECTIONS", cooker.configuration.data, 1) ) - - (filelist, masked) = cooker.collect_bbfiles() - cooker.parse_bbfiles(filelist, masked, cooker.myProgressCallback) - cooker.buildDepgraph() - global parsed - parsed = True - print - - def reparse( self, params ): - """(re)Parse a providee's bb file""" - bbfile = self._findProvider( params[0] ) - if bbfile is not None: - print "SHELL: Found bbfile '%s' for '%s'" % ( bbfile, params[0] ) - self.fileReparse( [ bbfile ] ) - else: - print "ERROR: Nothing provides '%s'" % params[0] - reparse.usage = "<providee>" - - def getvar( self, params ): - """Dump the contents of an outer BitBake environment variable""" - var = params[0] - value = data.getVar( var, cooker.configuration.data, 1 ) - print value - getvar.usage = "<variable>" - - def peek( self, params ): - """Dump contents of variable defined in providee's metadata""" - name, var = params - bbfile = self._findProvider( name ) - if bbfile is not None: - the_data = cooker.bb_cache.loadDataFull(bbfile, cooker.configuration.data) - value = the_data.getVar( var, 1 ) - print value - else: - print "ERROR: Nothing provides '%s'" % name - peek.usage = "<providee> <variable>" - - def poke( self, params ): - """Set contents of variable defined in providee's metadata""" - name, var, value = params - bbfile = self._findProvider( name ) - if bbfile is not None: - print "ERROR: Sorry, this functionality is currently broken" - #d = cooker.pkgdata[bbfile] - #data.setVar( var, value, d ) - - # mark the change semi persistant - #cooker.pkgdata.setDirty(bbfile, d) - #print "OK" - else: - print "ERROR: Nothing provides '%s'" % name - poke.usage = "<providee> <variable> <value>" - - def print_( self, params ): - """Dump all files or providers""" - what = params[0] - if what == "files": - self._checkParsed() - for key in cooker.status.pkg_fn.keys(): print key - elif what == "providers": - self._checkParsed() - for key in cooker.status.providers.keys(): print key - else: - print "Usage: print %s" % self.print_.usage - print_.usage = "<files|providers>" - - def python( self, params ): - """Enter the expert mode - an interactive BitBake Python Interpreter""" - sys.ps1 = "EXPERT BB>>> " - sys.ps2 = "EXPERT BB... " - import code - interpreter = code.InteractiveConsole( dict( globals() ) ) - interpreter.interact( "SHELL: Expert Mode - BitBake Python %s\nType 'help' for more information, press CTRL-D to switch back to BBSHELL." % sys.version ) - - def showdata( self, params ): - """Execute 'showdata' on a providee""" - self.build( params, "showdata" ) - showdata.usage = "<providee>" - - def setVar( self, params ): - """Set an outer BitBake environment variable""" - var, value = params - data.setVar( var, value, cooker.configuration.data ) - print "OK" - setVar.usage = "<variable> <value>" - - def rebuild( self, params ): - """Clean and rebuild a .bb file or a providee""" - self.build( params, "clean" ) - self.build( params, "build" ) - rebuild.usage = "<providee>" - - def shell( self, params ): - """Execute a shell command and dump the output""" - if params != "": - print commands.getoutput( " ".join( params ) ) - shell.usage = "<...>" - - def stage( self, params ): - """Execute 'stage' on a providee""" - self.build( params, "stage" ) - stage.usage = "<providee>" - - def status( self, params ): - """<just for testing>""" - print "-" * 78 - print "building list = '%s'" % cooker.building_list - print "build path = '%s'" % cooker.build_path - print "consider_msgs_cache = '%s'" % cooker.consider_msgs_cache - print "build stats = '%s'" % cooker.stats - if last_exception is not None: print "last_exception = '%s'" % repr( last_exception.args ) - print "memory output contents = '%s'" % self._shell.myout._buffer - - def test( self, params ): - """<just for testing>""" - print "testCommand called with '%s'" % params - - def unpack( self, params ): - """Execute 'unpack' on a providee""" - self.build( params, "unpack" ) - unpack.usage = "<providee>" - - def which( self, params ): - """Computes the providers for a given providee""" - # Need to use taskData for this information - item = params[0] - - self._checkParsed() - - preferred = data.getVar( "PREFERRED_PROVIDER_%s" % item, cooker.configuration.data, 1 ) - if not preferred: preferred = item - - try: - lv, lf, pv, pf = Providers.findBestProvider(preferred, cooker.configuration.data, cooker.status) - except KeyError: - lv, lf, pv, pf = (None,)*4 - - try: - providers = cooker.status.providers[item] - except KeyError: - print "SHELL: ERROR: Nothing provides", preferred - else: - for provider in providers: - if provider == pf: provider = " (***) %s" % provider - else: provider = " %s" % provider - print provider - which.usage = "<providee>" - -########################################################################## -# Common helper functions -########################################################################## - -def completeFilePath( bbfile ): - """Get the complete bbfile path""" - if not cooker.status.pkg_fn: return bbfile - for key in cooker.status.pkg_fn.keys(): - if key.endswith( bbfile ): - return key - return bbfile - -def sendToPastebin( desc, content ): - """Send content to http://oe.pastebin.com""" - mydata = {} - mydata["lang"] = "Plain Text" - mydata["desc"] = desc - mydata["cvt_tabs"] = "No" - mydata["nick"] = "%s@%s" % ( os.environ.get( "USER", "unknown" ), socket.gethostname() or "unknown" ) - mydata["text"] = content - params = urllib.urlencode( mydata ) - headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} - - host = "rafb.net" - conn = httplib.HTTPConnection( "%s:80" % host ) - conn.request("POST", "/paste/paste.php", params, headers ) - - response = conn.getresponse() - conn.close() - - if response.status == 302: - location = response.getheader( "location" ) or "unknown" - print "SHELL: Pasted to http://%s%s" % ( host, location ) - else: - print "ERROR: %s %s" % ( response.status, response.reason ) - -def completer( text, state ): - """Return a possible readline completion""" - debugOut( "completer called with text='%s', state='%d'" % ( text, state ) ) - - if state == 0: - line = readline.get_line_buffer() - if " " in line: - line = line.split() - # we are in second (or more) argument - if line[0] in cmds and hasattr( cmds[line[0]][0], "usage" ): # known command and usage - u = getattr( cmds[line[0]][0], "usage" ).split()[0] - if u == "<variable>": - allmatches = cooker.configuration.data.keys() - elif u == "<bbfile>": - if cooker.status.pkg_fn is None: allmatches = [ "(No Matches Available. Parsed yet?)" ] - else: allmatches = [ x.split("/")[-1] for x in cooker.status.pkg_fn.keys() ] - elif u == "<providee>": - if cooker.status.pkg_fn is None: allmatches = [ "(No Matches Available. Parsed yet?)" ] - else: allmatches = cooker.status.providers.iterkeys() - else: allmatches = [ "(No tab completion available for this command)" ] - else: allmatches = [ "(No tab completion available for this command)" ] - else: - # we are in first argument - allmatches = cmds.iterkeys() - - completer.matches = [ x for x in allmatches if x[:len(text)] == text ] - #print "completer.matches = '%s'" % completer.matches - if len( completer.matches ) > state: - return completer.matches[state] - else: - return None - -def debugOut( text ): - if debug: - sys.stderr.write( "( %s )\n" % text ) - -def columnize( alist, width = 80 ): - """ - A word-wrap function that preserves existing line breaks - and most spaces in the text. Expects that existing line - breaks are posix newlines (\n). - """ - return reduce(lambda line, word, width=width: '%s%s%s' % - (line, - ' \n'[(len(line[line.rfind('\n')+1:]) - + len(word.split('\n',1)[0] - ) >= width)], - word), - alist - ) - -def globfilter( names, pattern ): - return fnmatch.filter( names, pattern ) - -########################################################################## -# Class MemoryOutput -########################################################################## - -class MemoryOutput: - """File-like output class buffering the output of the last 10 commands""" - def __init__( self, delegate ): - self.delegate = delegate - self._buffer = [] - self.text = [] - self._command = None - - def startCommand( self, command ): - self._command = command - self.text = [] - def endCommand( self ): - if self._command is not None: - if len( self._buffer ) == 10: del self._buffer[0] - self._buffer.append( ( self._command, self.text ) ) - def removeLast( self ): - if self._buffer: - del self._buffer[ len( self._buffer ) - 1 ] - self.text = [] - self._command = None - def lastBuffer( self ): - if self._buffer: - return self._buffer[ len( self._buffer ) -1 ][1] - def bufferedCommands( self ): - return [ cmd for cmd, output in self._buffer ] - def buffer( self, i ): - if i < len( self._buffer ): - return "BB>> %s\n%s" % ( self._buffer[i][0], "".join( self._buffer[i][1] ) ) - else: return "ERROR: Invalid buffer number. Buffer needs to be in (0, %d)" % ( len( self._buffer ) - 1 ) - def write( self, text ): - if self._command is not None and text != "BB>> ": self.text.append( text ) - if self.delegate is not None: self.delegate.write( text ) - def flush( self ): - return self.delegate.flush() - def fileno( self ): - return self.delegate.fileno() - def isatty( self ): - return self.delegate.isatty() - -########################################################################## -# Class BitBakeShell -########################################################################## - -class BitBakeShell: - - def __init__( self ): - """Register commands and set up readline""" - self.commandQ = Queue.Queue() - self.commands = BitBakeShellCommands( self ) - self.myout = MemoryOutput( sys.stdout ) - self.historyfilename = os.path.expanduser( "~/.bbsh_history" ) - self.startupfilename = os.path.expanduser( "~/.bbsh_startup" ) - - readline.set_completer( completer ) - readline.set_completer_delims( " " ) - readline.parse_and_bind("tab: complete") - - try: - readline.read_history_file( self.historyfilename ) - except IOError: - pass # It doesn't exist yet. - - print __credits__ - - # save initial cooker configuration (will be reused in file*** commands) - global initdata - initdata = copy.deepcopy( cooker.configuration.data ) - - def cleanup( self ): - """Write readline history and clean up resources""" - debugOut( "writing command history" ) - try: - readline.write_history_file( self.historyfilename ) - except: - print "SHELL: Unable to save command history" - - def registerCommand( self, command, function, numparams = 0, usage = "", helptext = "" ): - """Register a command""" - if usage == "": usage = command - if helptext == "": helptext = function.__doc__ or "<not yet documented>" - cmds[command] = ( function, numparams, usage, helptext ) - - def processCommand( self, command, params ): - """Process a command. Check number of params and print a usage string, if appropriate""" - debugOut( "processing command '%s'..." % command ) - try: - function, numparams, usage, helptext = cmds[command] - except KeyError: - print "SHELL: ERROR: '%s' command is not a valid command." % command - self.myout.removeLast() - else: - if (numparams != -1) and (not len( params ) == numparams): - print "Usage: '%s'" % usage - return - - result = function( self.commands, params ) - debugOut( "result was '%s'" % result ) - - def processStartupFile( self ): - """Read and execute all commands found in $HOME/.bbsh_startup""" - if os.path.exists( self.startupfilename ): - startupfile = open( self.startupfilename, "r" ) - for cmdline in startupfile: - debugOut( "processing startup line '%s'" % cmdline ) - if not cmdline: - continue - if "|" in cmdline: - print "ERROR: '|' in startup file is not allowed. Ignoring line" - continue - self.commandQ.put( cmdline.strip() ) - - def main( self ): - """The main command loop""" - while not leave_mainloop: - try: - if self.commandQ.empty(): - sys.stdout = self.myout.delegate - cmdline = raw_input( "BB>> " ) - sys.stdout = self.myout - else: - cmdline = self.commandQ.get() - if cmdline: - allCommands = cmdline.split( ';' ) - for command in allCommands: - pipecmd = None - # - # special case for expert mode - if command == 'python': - sys.stdout = self.myout.delegate - self.processCommand( command, "" ) - sys.stdout = self.myout - else: - self.myout.startCommand( command ) - if '|' in command: # disable output - command, pipecmd = command.split( '|' ) - delegate = self.myout.delegate - self.myout.delegate = None - tokens = shlex.split( command, True ) - self.processCommand( tokens[0], tokens[1:] or "" ) - self.myout.endCommand() - if pipecmd is not None: # restore output - self.myout.delegate = delegate - - pipe = popen2.Popen4( pipecmd ) - pipe.tochild.write( "\n".join( self.myout.lastBuffer() ) ) - pipe.tochild.close() - sys.stdout.write( pipe.fromchild.read() ) - # - except EOFError: - print - return - except KeyboardInterrupt: - print - -########################################################################## -# Start function - called from the BitBake command line utility -########################################################################## - -def start( aCooker ): - global cooker - cooker = aCooker - bbshell = BitBakeShell() - bbshell.processStartupFile() - bbshell.main() - bbshell.cleanup() - -if __name__ == "__main__": - print "SHELL: Sorry, this program should only be called by BitBake." diff --git a/bitbake/lib/bb/taskdata.py b/bitbake/lib/bb/taskdata.py deleted file mode 100644 index 5b2418f665..0000000000 --- a/bitbake/lib/bb/taskdata.py +++ /dev/null @@ -1,566 +0,0 @@ -#!/usr/bin/env python -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake 'TaskData' implementation - -Task data collection and handling - -""" - -# Copyright (C) 2006 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. -# -# 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. - -from bb import data, event, mkdirhier, utils -import bb, os - -class TaskData: - """ - BitBake Task Data implementation - """ - def __init__(self, abort = True): - self.build_names_index = [] - self.run_names_index = [] - self.fn_index = [] - - self.build_targets = {} - self.run_targets = {} - - self.external_targets = [] - - self.tasks_fnid = [] - self.tasks_name = [] - self.tasks_tdepends = [] - self.tasks_idepends = [] - # Cache to speed up task ID lookups - self.tasks_lookup = {} - - self.depids = {} - self.rdepids = {} - - self.consider_msgs_cache = [] - - self.failed_deps = [] - self.failed_rdeps = [] - self.failed_fnids = [] - - self.abort = abort - - def getbuild_id(self, name): - """ - Return an ID number for the build target name. - If it doesn't exist, create one. - """ - if not name in self.build_names_index: - self.build_names_index.append(name) - return len(self.build_names_index) - 1 - - return self.build_names_index.index(name) - - def getrun_id(self, name): - """ - Return an ID number for the run target name. - If it doesn't exist, create one. - """ - if not name in self.run_names_index: - self.run_names_index.append(name) - return len(self.run_names_index) - 1 - - return self.run_names_index.index(name) - - def getfn_id(self, name): - """ - Return an ID number for the filename. - If it doesn't exist, create one. - """ - if not name in self.fn_index: - self.fn_index.append(name) - return len(self.fn_index) - 1 - - return self.fn_index.index(name) - - def gettask_id(self, fn, task, create = True): - """ - Return an ID number for the task matching fn and task. - If it doesn't exist, create one by default. - Optionally return None instead. - """ - fnid = self.getfn_id(fn) - - if fnid in self.tasks_lookup: - if task in self.tasks_lookup[fnid]: - return self.tasks_lookup[fnid][task] - - if not create: - return None - - self.tasks_name.append(task) - self.tasks_fnid.append(fnid) - self.tasks_tdepends.append([]) - self.tasks_idepends.append([]) - - listid = len(self.tasks_name) - 1 - - if fnid not in self.tasks_lookup: - self.tasks_lookup[fnid] = {} - self.tasks_lookup[fnid][task] = listid - - return listid - - def add_tasks(self, fn, dataCache): - """ - Add tasks for a given fn to the database - """ - - task_graph = dataCache.task_queues[fn] - task_deps = dataCache.task_deps[fn] - - fnid = self.getfn_id(fn) - - if fnid in self.failed_fnids: - bb.msg.fatal(bb.msg.domain.TaskData, "Trying to re-add a failed file? Something is broken...") - - # Check if we've already seen this fn - if fnid in self.tasks_fnid: - return - - for task in task_graph.allnodes(): - - # Work out task dependencies - parentids = [] - for dep in task_graph.getparents(task): - parentid = self.gettask_id(fn, dep) - parentids.append(parentid) - taskid = self.gettask_id(fn, task) - self.tasks_tdepends[taskid].extend(parentids) - - # Touch all intertask dependencies - if 'depends' in task_deps and task in task_deps['depends']: - ids = [] - for dep in task_deps['depends'][task].split(): - if dep: - ids.append(str(self.getbuild_id(dep.split(":")[0])) + ":" + dep.split(":")[1]) - self.tasks_idepends[taskid].extend(ids) - - # Work out build dependencies - if not fnid in self.depids: - dependids = {} - for depend in dataCache.deps[fn]: - bb.msg.debug(2, bb.msg.domain.TaskData, "Added dependency %s for %s" % (depend, fn)) - dependids[self.getbuild_id(depend)] = None - self.depids[fnid] = dependids.keys() - - # Work out runtime dependencies - if not fnid in self.rdepids: - rdependids = {} - rdepends = dataCache.rundeps[fn] - rrecs = dataCache.runrecs[fn] - for package in rdepends: - for rdepend in rdepends[package]: - bb.msg.debug(2, bb.msg.domain.TaskData, "Added runtime dependency %s for %s" % (rdepend, fn)) - rdependids[self.getrun_id(rdepend)] = None - for package in rrecs: - for rdepend in rrecs[package]: - bb.msg.debug(2, bb.msg.domain.TaskData, "Added runtime recommendation %s for %s" % (rdepend, fn)) - rdependids[self.getrun_id(rdepend)] = None - self.rdepids[fnid] = rdependids.keys() - - for dep in self.depids[fnid]: - if dep in self.failed_deps: - self.fail_fnid(fnid) - return - for dep in self.rdepids[fnid]: - if dep in self.failed_rdeps: - self.fail_fnid(fnid) - return - - def have_build_target(self, target): - """ - Have we a build target matching this name? - """ - targetid = self.getbuild_id(target) - - if targetid in self.build_targets: - return True - return False - - def have_runtime_target(self, target): - """ - Have we a runtime target matching this name? - """ - targetid = self.getrun_id(target) - - if targetid in self.run_targets: - return True - return False - - def add_build_target(self, fn, item): - """ - Add a build target. - If already present, append the provider fn to the list - """ - targetid = self.getbuild_id(item) - fnid = self.getfn_id(fn) - - if targetid in self.build_targets: - if fnid in self.build_targets[targetid]: - return - self.build_targets[targetid].append(fnid) - return - self.build_targets[targetid] = [fnid] - - def add_runtime_target(self, fn, item): - """ - Add a runtime target. - If already present, append the provider fn to the list - """ - targetid = self.getrun_id(item) - fnid = self.getfn_id(fn) - - if targetid in self.run_targets: - if fnid in self.run_targets[targetid]: - return - self.run_targets[targetid].append(fnid) - return - self.run_targets[targetid] = [fnid] - - def mark_external_target(self, item): - """ - Mark a build target as being externally requested - """ - targetid = self.getbuild_id(item) - - if targetid not in self.external_targets: - self.external_targets.append(targetid) - - def get_unresolved_build_targets(self, dataCache): - """ - Return a list of build targets who's providers - are unknown. - """ - unresolved = [] - for target in self.build_names_index: - if target in dataCache.ignored_dependencies: - continue - if self.build_names_index.index(target) in self.failed_deps: - continue - if not self.have_build_target(target): - unresolved.append(target) - return unresolved - - def get_unresolved_run_targets(self, dataCache): - """ - Return a list of runtime targets who's providers - are unknown. - """ - unresolved = [] - for target in self.run_names_index: - if target in dataCache.ignored_dependencies: - continue - if self.run_names_index.index(target) in self.failed_rdeps: - continue - if not self.have_runtime_target(target): - unresolved.append(target) - return unresolved - - def get_provider(self, item): - """ - Return a list of providers of item - """ - targetid = self.getbuild_id(item) - - return self.build_targets[targetid] - - def get_dependees(self, itemid): - """ - Return a list of targets which depend on item - """ - dependees = [] - for fnid in self.depids: - if itemid in self.depids[fnid]: - dependees.append(fnid) - return dependees - - def get_dependees_str(self, item): - """ - Return a list of targets which depend on item as a user readable string - """ - itemid = self.getbuild_id(item) - dependees = [] - for fnid in self.depids: - if itemid in self.depids[fnid]: - dependees.append(self.fn_index[fnid]) - return dependees - - def get_rdependees(self, itemid): - """ - Return a list of targets which depend on runtime item - """ - dependees = [] - for fnid in self.rdepids: - if itemid in self.rdepids[fnid]: - dependees.append(fnid) - return dependees - - def get_rdependees_str(self, item): - """ - Return a list of targets which depend on runtime item as a user readable string - """ - itemid = self.getrun_id(item) - dependees = [] - for fnid in self.rdepids: - if itemid in self.rdepids[fnid]: - dependees.append(self.fn_index[fnid]) - return dependees - - def add_provider(self, cfgData, dataCache, item): - try: - self.add_provider_internal(cfgData, dataCache, item) - except bb.providers.NoProvider: - if self.abort: - bb.msg.error(bb.msg.domain.Provider, "No providers of build target %s (for %s)" % (item, self.get_dependees_str(item))) - raise - targetid = self.getbuild_id(item) - self.remove_buildtarget(targetid) - - self.mark_external_target(item) - - def add_provider_internal(self, cfgData, dataCache, item): - """ - Add the providers of item to the task data - Mark entries were specifically added externally as against dependencies - added internally during dependency resolution - """ - - if item in dataCache.ignored_dependencies: - return - - if not item in dataCache.providers: - bb.msg.note(2, bb.msg.domain.Provider, "No providers of build target %s (for %s)" % (item, self.get_dependees_str(item))) - bb.event.fire(bb.event.NoProvider(item, cfgData)) - raise bb.providers.NoProvider(item) - - if self.have_build_target(item): - return - - all_p = dataCache.providers[item] - - eligible, foundUnique = bb.providers.filterProviders(all_p, item, cfgData, dataCache) - - for p in eligible: - fnid = self.getfn_id(p) - if fnid in self.failed_fnids: - eligible.remove(p) - - if not eligible: - bb.msg.note(2, bb.msg.domain.Provider, "No providers of build target %s after filtering (for %s)" % (item, self.get_dependees_str(item))) - bb.event.fire(bb.event.NoProvider(item, cfgData)) - raise bb.providers.NoProvider(item) - - if len(eligible) > 1 and foundUnique == False: - if item not in self.consider_msgs_cache: - providers_list = [] - for fn in eligible: - providers_list.append(dataCache.pkg_fn[fn]) - bb.msg.note(1, bb.msg.domain.Provider, "multiple providers are available for %s (%s);" % (item, ", ".join(providers_list))) - bb.msg.note(1, bb.msg.domain.Provider, "consider defining PREFERRED_PROVIDER_%s" % item) - bb.event.fire(bb.event.MultipleProviders(item,providers_list,cfgData)) - self.consider_msgs_cache.append(item) - - for fn in eligible: - fnid = self.getfn_id(fn) - if fnid in self.failed_fnids: - continue - bb.msg.debug(2, bb.msg.domain.Provider, "adding %s to satisfy %s" % (fn, item)) - self.add_build_target(fn, item) - self.add_tasks(fn, dataCache) - - - #item = dataCache.pkg_fn[fn] - - def add_rprovider(self, cfgData, dataCache, item): - """ - Add the runtime providers of item to the task data - (takes item names from RDEPENDS/PACKAGES namespace) - """ - - if item in dataCache.ignored_dependencies: - return - - if self.have_runtime_target(item): - return - - all_p = bb.providers.getRuntimeProviders(dataCache, item) - - if not all_p: - bb.msg.error(bb.msg.domain.Provider, "No providers of runtime build target %s (for %s)" % (item, self.get_rdependees_str(item))) - bb.event.fire(bb.event.NoProvider(item, cfgData, runtime=True)) - raise bb.providers.NoRProvider(item) - - eligible, numberPreferred = bb.providers.filterProvidersRunTime(all_p, item, cfgData, dataCache) - - for p in eligible: - fnid = self.getfn_id(p) - if fnid in self.failed_fnids: - eligible.remove(p) - - if not eligible: - bb.msg.error(bb.msg.domain.Provider, "No providers of runtime build target %s after filtering (for %s)" % (item, self.get_rdependees_str(item))) - bb.event.fire(bb.event.NoProvider(item, cfgData, runtime=True)) - raise bb.providers.NoRProvider(item) - - if len(eligible) > 1 and numberPreferred == 0: - if item not in self.consider_msgs_cache: - providers_list = [] - for fn in eligible: - providers_list.append(dataCache.pkg_fn[fn]) - bb.msg.note(2, bb.msg.domain.Provider, "multiple providers are available for runtime %s (%s);" % (item, ", ".join(providers_list))) - bb.msg.note(2, bb.msg.domain.Provider, "consider defining a PREFERRED_PROVIDER entry to match runtime %s" % item) - bb.event.fire(bb.event.MultipleProviders(item,providers_list, cfgData, runtime=True)) - self.consider_msgs_cache.append(item) - - if numberPreferred > 1: - if item not in self.consider_msgs_cache: - providers_list = [] - for fn in eligible: - providers_list.append(dataCache.pkg_fn[fn]) - bb.msg.note(2, bb.msg.domain.Provider, "multiple providers are available for runtime %s (top %s entries preferred) (%s);" % (item, numberPreferred, ", ".join(providers_list))) - bb.msg.note(2, bb.msg.domain.Provider, "consider defining only one PREFERRED_PROVIDER entry to match runtime %s" % item) - bb.event.fire(bb.event.MultipleProviders(item,providers_list, cfgData, runtime=True)) - self.consider_msgs_cache.append(item) - - # run through the list until we find one that we can build - for fn in eligible: - fnid = self.getfn_id(fn) - if fnid in self.failed_fnids: - continue - bb.msg.debug(2, bb.msg.domain.Provider, "adding %s to satisfy runtime %s" % (fn, item)) - self.add_runtime_target(fn, item) - self.add_tasks(fn, dataCache) - - def fail_fnid(self, fnid, missing_list = []): - """ - Mark a file as failed (unbuildable) - Remove any references from build and runtime provider lists - - missing_list, A list of missing requirements for this target - """ - if fnid in self.failed_fnids: - return - bb.msg.debug(1, bb.msg.domain.Provider, "Removing failed file %s" % self.fn_index[fnid]) - self.failed_fnids.append(fnid) - for target in self.build_targets: - if fnid in self.build_targets[target]: - self.build_targets[target].remove(fnid) - if len(self.build_targets[target]) == 0: - self.remove_buildtarget(target, missing_list) - for target in self.run_targets: - if fnid in self.run_targets[target]: - self.run_targets[target].remove(fnid) - if len(self.run_targets[target]) == 0: - self.remove_runtarget(target, missing_list) - - def remove_buildtarget(self, targetid, missing_list = []): - """ - Mark a build target as failed (unbuildable) - Trigger removal of any files that have this as a dependency - """ - bb.msg.note(2, bb.msg.domain.Provider, "Removing failed build target %s" % self.build_names_index[targetid]) - self.failed_deps.append(targetid) - dependees = self.get_dependees(targetid) - for fnid in dependees: - self.fail_fnid(fnid, [self.build_names_index[targetid]]+missing_list) - if self.abort and targetid in self.external_targets: - bb.msg.error(bb.msg.domain.Provider, "No buildable providers available for required build target %s ('%s')" % (self.build_names_index[targetid], missing_list)) - raise bb.providers.NoProvider - - def remove_runtarget(self, targetid, missing_list = []): - """ - Mark a run target as failed (unbuildable) - Trigger removal of any files that have this as a dependency - """ - bb.msg.note(1, bb.msg.domain.Provider, "Removing failed runtime build target %s ('%s')" % (self.run_names_index[targetid], missing_list)) - self.failed_rdeps.append(targetid) - dependees = self.get_rdependees(targetid) - for fnid in dependees: - self.fail_fnid(fnid, [self.run_names_index[targetid]]+missing_list) - - def add_unresolved(self, cfgData, dataCache): - """ - Resolve all unresolved build and runtime targets - """ - bb.msg.note(1, bb.msg.domain.TaskData, "Resolving missing task queue dependencies") - while 1: - added = 0 - for target in self.get_unresolved_build_targets(dataCache): - try: - self.add_provider_internal(cfgData, dataCache, target) - added = added + 1 - except bb.providers.NoProvider: - targetid = self.getbuild_id(target) - if self.abort and targetid in self.external_targets: - bb.msg.error(bb.msg.domain.Provider, "No providers of build target %s (for %s)" % (target, self.get_dependees_str(target))) - raise - self.remove_buildtarget(targetid) - for target in self.get_unresolved_run_targets(dataCache): - try: - self.add_rprovider(cfgData, dataCache, target) - added = added + 1 - except bb.providers.NoRProvider: - self.remove_runtarget(self.getrun_id(target)) - bb.msg.debug(1, bb.msg.domain.TaskData, "Resolved " + str(added) + " extra dependecies") - if added == 0: - break - # self.dump_data() - - def dump_data(self): - """ - Dump some debug information on the internal data structures - """ - bb.msg.debug(3, bb.msg.domain.TaskData, "build_names:") - bb.msg.debug(3, bb.msg.domain.TaskData, ", ".join(self.build_names_index)) - - bb.msg.debug(3, bb.msg.domain.TaskData, "run_names:") - bb.msg.debug(3, bb.msg.domain.TaskData, ", ".join(self.run_names_index)) - - bb.msg.debug(3, bb.msg.domain.TaskData, "build_targets:") - for buildid in range(len(self.build_names_index)): - target = self.build_names_index[buildid] - targets = "None" - if buildid in self.build_targets: - targets = self.build_targets[buildid] - bb.msg.debug(3, bb.msg.domain.TaskData, " (%s)%s: %s" % (buildid, target, targets)) - - bb.msg.debug(3, bb.msg.domain.TaskData, "run_targets:") - for runid in range(len(self.run_names_index)): - target = self.run_names_index[runid] - targets = "None" - if runid in self.run_targets: - targets = self.run_targets[runid] - bb.msg.debug(3, bb.msg.domain.TaskData, " (%s)%s: %s" % (runid, target, targets)) - - bb.msg.debug(3, bb.msg.domain.TaskData, "tasks:") - for task in range(len(self.tasks_name)): - bb.msg.debug(3, bb.msg.domain.TaskData, " (%s)%s - %s: %s" % ( - task, - self.fn_index[self.tasks_fnid[task]], - self.tasks_name[task], - self.tasks_tdepends[task])) - - bb.msg.debug(3, bb.msg.domain.TaskData, "runtime ids (per fn):") - for fnid in self.rdepids: - bb.msg.debug(3, bb.msg.domain.TaskData, " %s %s: %s" % (fnid, self.fn_index[fnid], self.rdepids[fnid])) - - diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py deleted file mode 100644 index c2884f2633..0000000000 --- a/bitbake/lib/bb/utils.py +++ /dev/null @@ -1,204 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -""" -BitBake Utility Functions -""" - -# Copyright (C) 2004 Michael Lauer -# -# 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. -# -# 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. - -digits = "0123456789" -ascii_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - -import re - -def explode_version(s): - r = [] - alpha_regexp = re.compile('^([a-zA-Z]+)(.*)$') - numeric_regexp = re.compile('^(\d+)(.*)$') - while (s != ''): - if s[0] in digits: - m = numeric_regexp.match(s) - r.append(int(m.group(1))) - s = m.group(2) - continue - if s[0] in ascii_letters: - m = alpha_regexp.match(s) - r.append(m.group(1)) - s = m.group(2) - continue - s = s[1:] - return r - -def vercmp_part(a, b): - va = explode_version(a) - vb = explode_version(b) - while True: - if va == []: - ca = None - else: - ca = va.pop(0) - if vb == []: - cb = None - else: - cb = vb.pop(0) - if ca == None and cb == None: - return 0 - if ca > cb: - return 1 - if ca < cb: - return -1 - -def vercmp(ta, tb): - (ea, va, ra) = ta - (eb, vb, rb) = tb - - r = int(ea)-int(eb) - if (r == 0): - r = vercmp_part(va, vb) - if (r == 0): - r = vercmp_part(ra, rb) - return r - -def explode_deps(s): - """ - Take an RDEPENDS style string of format: - "DEPEND1 (optional version) DEPEND2 (optional version) ..." - and return a list of dependencies. - Version information is ignored. - """ - r = [] - l = s.split() - flag = False - for i in l: - if i[0] == '(': - flag = True - j = [] - if flag: - j.append(i) - else: - r.append(i) - if flag and i.endswith(')'): - flag = False - # Ignore version - #r[-1] += ' ' + ' '.join(j) - return r - - - -def _print_trace(body, line): - """ - Print the Environment of a Text Body - """ - import bb - - # print the environment of the method - bb.msg.error(bb.msg.domain.Util, "Printing the environment of the function") - min_line = max(1,line-4) - max_line = min(line+4,len(body)-1) - for i in range(min_line,max_line+1): - bb.msg.error(bb.msg.domain.Util, "\t%.4d:%s" % (i, body[i-1]) ) - - -def better_compile(text, file, realfile): - """ - A better compile method. This method - will print the offending lines. - """ - try: - return compile(text, file, "exec") - except Exception, e: - import bb,sys - - # split the text into lines again - body = text.split('\n') - bb.msg.error(bb.msg.domain.Util, "Error in compiling: ", realfile) - bb.msg.error(bb.msg.domain.Util, "The lines resulting into this error were:") - bb.msg.error(bb.msg.domain.Util, "\t%d:%s:'%s'" % (e.lineno, e.__class__.__name__, body[e.lineno-1])) - - _print_trace(body, e.lineno) - - # exit now - sys.exit(1) - -def better_exec(code, context, text, realfile): - """ - Similiar to better_compile, better_exec will - print the lines that are responsible for the - error. - """ - import bb,sys - try: - exec code in context - except: - (t,value,tb) = sys.exc_info() - - if t in [bb.parse.SkipPackage, bb.build.FuncFailed]: - raise - - # print the Header of the Error Message - bb.msg.error(bb.msg.domain.Util, "Error in executing: ", realfile) - bb.msg.error(bb.msg.domain.Util, "Exception:%s Message:%s" % (t,value) ) - - # let us find the line number now - while tb.tb_next: - tb = tb.tb_next - - import traceback - line = traceback.tb_lineno(tb) - - _print_trace( text.split('\n'), line ) - - raise - -def Enum(*names): - """ - A simple class to give Enum support - """ - - assert names, "Empty enums are not supported" - - class EnumClass(object): - __slots__ = names - def __iter__(self): return iter(constants) - def __len__(self): return len(constants) - def __getitem__(self, i): return constants[i] - def __repr__(self): return 'Enum' + str(names) - def __str__(self): return 'enum ' + str(constants) - - class EnumValue(object): - __slots__ = ('__value') - def __init__(self, value): self.__value = value - Value = property(lambda self: self.__value) - EnumType = property(lambda self: EnumType) - def __hash__(self): return hash(self.__value) - def __cmp__(self, other): - # C fans might want to remove the following assertion - # to make all enums comparable by ordinal value {;)) - assert self.EnumType is other.EnumType, "Only values from the same enum are comparable" - return cmp(self.__value, other.__value) - def __invert__(self): return constants[maximum - self.__value] - def __nonzero__(self): return bool(self.__value) - def __repr__(self): return str(names[self.__value]) - - maximum = len(names) - 1 - constants = [None] * len(names) - for i, each in enumerate(names): - val = EnumValue(i) - setattr(EnumClass, each, val) - constants[i] = val - constants = tuple(constants) - EnumType = EnumClass() - return EnumType |
