From b26a945734ce271aa7d443ff9e96fe2851b21138 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 20 Mar 2006 17:45:11 +0000 Subject: Update to latest bitbake git-svn-id: https://svn.o-hand.com/repos/poky/trunk@309 311d38ba-8fff-0310-9ca6-ca027cbcb966 --- bitbake/ChangeLog | 7 + bitbake/MANIFEST | 1 + bitbake/bin/bitbake | 31 +- bitbake/bin/bitdoc | 55 +- bitbake/doc/manual/usermanual.xml | 88 +- bitbake/lib/bb/__init__.py | 34 +- bitbake/lib/bb/build.py | 9 +- bitbake/lib/bb/data.py | 7 +- bitbake/lib/bb/data_smart.py | 6 +- bitbake/lib/bb/event.py | 66 +- bitbake/lib/bb/fetch/__init__.py | 35 +- bitbake/lib/bb/fetch/bk.py | 40 - bitbake/lib/bb/fetch/cvs.py | 20 +- bitbake/lib/bb/fetch/git.py | 95 +- bitbake/lib/bb/fetch/svn.py | 27 +- bitbake/lib/bb/parse/parse_c/BBHandler.py | 65 + bitbake/lib/bb/parse/parse_c/README.build | 12 + bitbake/lib/bb/parse/parse_c/__init__.py | 28 + bitbake/lib/bb/parse/parse_c/bitbakeparser.cc | 1105 +++++++++ bitbake/lib/bb/parse/parse_c/bitbakeparser.h | 27 + bitbake/lib/bb/parse/parse_c/bitbakeparser.l | 288 --- bitbake/lib/bb/parse/parse_c/bitbakeparser.py | 133 - bitbake/lib/bb/parse/parse_c/bitbakeparser.y | 66 +- bitbake/lib/bb/parse/parse_c/bitbakescanner.cc | 3126 ++++++++++++++++++++++++ bitbake/lib/bb/parse/parse_c/bitbakescanner.l | 288 +++ bitbake/lib/bb/parse/parse_c/lexer.h | 20 +- bitbake/lib/bb/parse/parse_c/python_output.h | 51 + bitbake/lib/bb/parse/parse_c/token.h | 23 +- bitbake/lib/bb/parse/parse_py/BBHandler.py | 6 +- bitbake/lib/bb/utils.py | 73 +- 30 files changed, 5145 insertions(+), 687 deletions(-) delete mode 100644 bitbake/lib/bb/fetch/bk.py create mode 100644 bitbake/lib/bb/parse/parse_c/BBHandler.py create mode 100644 bitbake/lib/bb/parse/parse_c/README.build create mode 100644 bitbake/lib/bb/parse/parse_c/__init__.py create mode 100644 bitbake/lib/bb/parse/parse_c/bitbakeparser.cc create mode 100644 bitbake/lib/bb/parse/parse_c/bitbakeparser.h delete mode 100644 bitbake/lib/bb/parse/parse_c/bitbakeparser.l delete mode 100644 bitbake/lib/bb/parse/parse_c/bitbakeparser.py create mode 100644 bitbake/lib/bb/parse/parse_c/bitbakescanner.cc create mode 100644 bitbake/lib/bb/parse/parse_c/bitbakescanner.l create mode 100644 bitbake/lib/bb/parse/parse_c/python_output.h (limited to 'bitbake') diff --git a/bitbake/ChangeLog b/bitbake/ChangeLog index c05ff96ab9..3dfba1ed81 100644 --- a/bitbake/ChangeLog +++ b/bitbake/ChangeLog @@ -1,3 +1,10 @@ +Changes in BitBake 1.3.x: + - Fix to check both RDEPENDS and RDEPENDS_${PN} + - Fix a RDEPENDS parsing bug in utils:explode_deps() + - Update git fetcher behaviour to match git changes + - ASSUME_PROVIDED allowed to include runtime packages + - git fetcher cleanup and efficency improvements + Changes in BitBake 1.3.3: - Create a new Fetcher module to ease the development of new Fetchers. diff --git a/bitbake/MANIFEST b/bitbake/MANIFEST index cf0aac99d9..14a21d7bf4 100644 --- a/bitbake/MANIFEST +++ b/bitbake/MANIFEST @@ -14,6 +14,7 @@ lib/bb/fetch/cvs.py lib/bb/fetch/git.py lib/bb/fetch/__init__.py lib/bb/fetch/local.py +lib/bb/fetch/svk.py lib/bb/fetch/svn.py lib/bb/fetch/wget.py lib/bb/manifest.py diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake index 63bd07fe34..457fbb7527 100755 --- a/bitbake/bin/bitbake +++ b/bitbake/bin/bitbake @@ -22,7 +22,7 @@ # Place, Suite 330, Boston, MA 02111-1307 USA. import sys, os, getopt, glob, copy, os.path, re, time -sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) +sys.path.insert(0,os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) import bb from bb import utils, data, parse, debug, event, fatal from sets import Set @@ -31,7 +31,7 @@ import itertools, optparse parsespin = itertools.cycle( r'|/-\\' ) bbdebug = 0 -__version__ = "1.3.3" +__version__ = "1.3.3.2" #============================================================================# # BBParsingStatus @@ -80,7 +80,7 @@ class BBParsingStatus: depends = (bb.data.getVar("DEPENDS", bb_data, True) or "").split() packages = (bb.data.getVar('PACKAGES', bb_data, True) or "").split() packages_dynamic = (bb.data.getVar('PACKAGES_DYNAMIC', bb_data, True) or "").split() - rprovides = Set((bb.data.getVar("RPROVIDES_%s" % pn, bb_data, 1) or "").split() + (bb.data.getVar("RPROVIDES", bb_data, 1) or "").split()) + rprovides = (bb.data.getVar("RPROVIDES", bb_data, 1) or "").split() # build PackageName to FileName lookup table @@ -110,11 +110,11 @@ class BBParsingStatus: # Build reverse hash for PACKAGES, so runtime dependencies # can be be resolved (RDEPENDS, RRECOMMENDS etc.) - for package in packages: if not package in self.packages: self.packages[package] = [] self.packages[package].append(file_name) + rprovides += (bb.data.getVar("RPROVIDES_%s" % package, bb_data, 1) or "").split() for package in packages_dynamic: if not package in self.packages_dynamic: @@ -493,6 +493,7 @@ class BBCooker: if not item in self.status.providers: bb.error("Nothing provides dependency %s" % item) + bb.event.fire(bb.event.NoProvider(item,self.configuration.data)) return 0 all_p = self.status.providers[item] @@ -529,6 +530,7 @@ class BBCooker: providers_list.append(self.status.pkg_fn[fn]) bb.note("multiple providers are available (%s);" % ", ".join(providers_list)) bb.note("consider defining PREFERRED_PROVIDER_%s" % item) + bb.event.fire(bb.event.MultipleProviders(item,providers_list,self.configuration.data)) self.consider_msgs_cache.append(item) @@ -539,6 +541,7 @@ class BBCooker: return 1 bb.note("no buildable providers for %s" % item) + bb.event.fire(bb.event.NoProvider(item,self.configuration.data)) return 0 def buildRProvider( self, item , buildAllDeps ): @@ -558,6 +561,7 @@ class BBCooker: if not all_p: bb.error("Nothing provides runtime dependency %s" % (item)) + bb.event.fire(bb.event.NoProvider(item,self.configuration.data,runtime=True)) return False for p in all_p: @@ -592,6 +596,7 @@ class BBCooker: providers_list.append(self.status.pkg_fn[fn]) bb.note("multiple providers are available (%s);" % ", ".join(providers_list)) bb.note("consider defining a PREFERRED_PROVIDER to match runtime %s" % item) + bb.event.fire(bb.event.MultipleProviders(item,providers_list,self.configuration.data,runtime=True)) self.consider_msgs_cache.append(item) if len(preferred) > 1: @@ -601,6 +606,7 @@ class BBCooker: providers_list.append(self.status.pkg_fn[fn]) bb.note("multiple preferred providers are available (%s);" % ", ".join(providers_list)) bb.note("consider defining only one PREFERRED_PROVIDER to match runtime %s" % item) + bb.event.fire(bb.event.MultipleProviders(item,providers_list,self.configuration.data,runtime=True)) self.consider_msgs_cache.append(item) # run through the list until we find one that we can build @@ -610,6 +616,7 @@ class BBCooker: return True bb.error("No buildable providers for runtime %s" % item) + bb.event.fire(bb.event.NoProvider(item,self.configuration.data)) return False def getProvidersRun(self, rdepend): @@ -666,7 +673,9 @@ class BBCooker: bb.debug(2, "Additional runtime dependencies for %s are: %s" % (item, " ".join(rdepends))) - for rdepend in rdepends: + for rdepend in rdepends: + if rdepend in self.status.ignored_dependencies: + continue if not self.buildRProvider(rdepend, buildAllDeps): return False return True @@ -880,6 +889,7 @@ class BBCooker: bb.event.fire(bb.event.BuildStarted(buildname, pkgs_to_build, self.configuration.data)) + failures = 0 for k in pkgs_to_build: failed = False try: @@ -891,10 +901,11 @@ class BBCooker: failed = True if failed: + failures += failures if self.configuration.abort: sys.exit(1) - bb.event.fire(bb.event.BuildCompleted(buildname, pkgs_to_build, self.configuration.data)) + bb.event.fire(bb.event.BuildCompleted(buildname, pkgs_to_build, self.configuration.data, failures)) sys.exit( self.stats.show() ) @@ -1067,8 +1078,7 @@ class BBCooker: # main #============================================================================# -if __name__ == "__main__": - +def main(): parser = optparse.OptionParser( version = "BitBake Build Tool Core version %s, %%prog version %s" % ( bb.__version__, __version__ ), usage = """%prog [options] [package ...] @@ -1120,3 +1130,8 @@ Default BBFILES are the .bb files in the current directory.""" ) cooker = BBCooker() cooker.cook( BBConfiguration( options ), args[1:] ) + + + +if __name__ == "__main__": + main() diff --git a/bitbake/bin/bitdoc b/bitbake/bin/bitdoc index 64d32945ba..84d2ee23ce 100755 --- a/bitbake/bin/bitdoc +++ b/bitbake/bin/bitdoc @@ -30,7 +30,7 @@ import optparse, os, sys # bitbake sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) import bb -from bb import make +import bb.parse from string import split, join __version__ = "0.0.2" @@ -45,8 +45,8 @@ class HTMLFormatter: one site for each key with links to the relations and groups. index.html - keys.html - groups.html + all_keys.html + all_groups.html groupNAME.html keyNAME.html """ @@ -75,8 +75,8 @@ class HTMLFormatter: return """ - - + + """ @@ -89,10 +89,11 @@ class HTMLFormatter: return "" txt = "

See also:
" + txts = [] for it in item.related(): - txt += """%s, """ % (it, it) + txts.append("""%(it)s""" % vars() ) - return txt + return txt + ",".join(txts) def groups(self,item): """ @@ -103,11 +104,12 @@ class HTMLFormatter: return "" - txt = "

Seel also:
" + txt = "

See also:
" + txts = [] for group in item.groups(): - txt += """%s, """ % (group,group) + txts.append( """%s """ % (group,group) ) - return txt + return txt + ",".join(txts) def createKeySite(self,item): @@ -125,23 +127,23 @@ class HTMLFormatter:

Synopsis

-
+

%s -

+

Related Keys

-
+

%s -

+

Groups

-
+

%s -

+

@@ -181,8 +183,8 @@ class HTMLFormatter: %s

Documentation Entrance

-All available groups
-All available keys
+All available groups
+All available keys
""" % self.createNavigator() @@ -206,13 +208,21 @@ class HTMLFormatter: """ % (self.createNavigator(), keys) - def createGroupSite(self,gr, items): + def createGroupSite(self, gr, items, _description = None): """ Create a site for a group: Group the name of the group, items contain the name of the keys inside this group """ groups = "" + description = "" + + # create a section with the group descriptions + if _description: + description += "

" % gr + description += _description + + items.sort(lambda x,y:cmp(x.name(),y.name())) for group in items: groups += """%s
""" % (group.name(), group.name()) @@ -221,6 +231,7 @@ class HTMLFormatter: %s +%s

Keys in Group %s

@@ -228,7 +239,7 @@ class HTMLFormatter:
 
-""" % (gr, self.createNavigator(), gr, groups) +""" % (gr, self.createNavigator(), description, gr, groups) @@ -508,10 +519,10 @@ def main(): f = file('index.html', 'w') print >> f, html_slave.createIndex() - f = file('groups.html', 'w') + f = file('all_groups.html', 'w') print >> f, html_slave.createGroupsSite(doc) - f = file('keys.html', 'w') + f = file('all_keys.html', 'w') print >> f, html_slave.createKeysSite(doc) # now for each group create the site diff --git a/bitbake/doc/manual/usermanual.xml b/bitbake/doc/manual/usermanual.xml index 277e615100..33150b10f2 100644 --- a/bitbake/doc/manual/usermanual.xml +++ b/bitbake/doc/manual/usermanual.xml @@ -12,7 +12,7 @@ BitBake Team - 2004, 2005 + 2004, 2005, 2006 Chris Larson Phil Blundell @@ -111,9 +111,9 @@ share common metadata between many packages.
Appending (.=) and prepending (=.) without spaces B = "bval" -B += "additionaldata" +B .= "additionaldata" C = "cval" -C =+ "test" +C =. "test" In this example, B is now bvaladditionaldata and C is testcval. In contrast to the above Appending and Prepending operators no additional space will be introduced.
@@ -228,6 +228,86 @@ of the event and the content of the FILE variable. + + + File Download support +
+ Overview + BitBake provides support to download files this procedure is called fetching. The SRC_URI is normally used to indicate BitBake which files to fetch. The next sections will describe th available fetchers and the options they have. Each Fetcher honors a set of Variables and +a per URI parameters separated by a ; consisting of a key and a value. The semantic of the Variables and Parameters are defined by the Fetcher. BitBakes tries to have a consistent semantic between the different Fetchers. + +
+ +
+ Local File Fetcher + The URN for the Local File Fetcher is file. The filename can be either absolute or relative. If the filename is relative FILESPATH and FILESDIR will be used to find the appropriate relative file depending on the OVERRIDES. Single files and complete directories can be specified. +SRC_URI= "file://relativefile.patch" +SRC_URI= "file://relativefile.patch;this=ignored" +SRC_URI= "file:///Users/ich/very_important_software" + + +
+ +
+ CVS File Fetcher + The URN for the CVS Fetcher is cvs. This Fetcher honors the variables DL_DIR, SRCDATE, FETCHCOMMAND_cvs, UPDATECOMMAND_cvs. DL_DIRS specifies where a temporary checkout is saved, SRCDATE specifies which date to use when doing the fetching, FETCHCOMMAND and UPDATECOMMAND specify which executables should be used when doing the CVS checkout or update. + + The supported Parameters are module, tag, date, method, localdir, rsh. The module specifies which module to check out, the tag describes which CVS TAG should be used for the checkout by default the TAG is empty. A date can be specified to override the SRCDATE of the configuration to checkout a specific date. method is by default pserver, if ext is used the rsh parameter will be evaluated and CVS_RSH will be set. Finally localdir is used to checkout into a special directory relative to CVSDIR>. +SRC_URI = "cvs://CVSROOT;module=mymodule;tag=some-version;method=ext" +SRC_URI = "cvs://CVSROOT;module=mymodule;date=20060126;localdir=usethat" + + +
+ +
+ HTTP/FTP Fetcher + The URNs for the HTTP/FTP are http, https and ftp. This Fetcher honors the variables DL_DIR, FETCHCOMMAND_wget, PREMIRRORS, MIRRORS. The DL_DIR defines where to store the fetched file, FETCHCOMMAND contains the command used for fetching. ${URI} and ${FILES} will be replaced by the uri and basename of the to be fetched file. PREMIRRORS +will be tried first when fetching a file if that fails the actual file will be tried and finally all MIRRORS will be tried. + + The only supported Parameter is md5sum. After a fetch the md5sum of the file will be calculated and the two sums will be compared. + + SRC_URI = "http://oe.handhelds.org/not_there.aac;md5sum=12343" +SRC_URI = "ftp://oe.handhelds.org/not_there_as_well.aac;md5sum=1234" +SRC_URI = "ftp://you@oe.handheld.sorg/home/you/secret.plan;md5sum=1234" + +
+ +
+ SVK Fetcher + + Currently NOT suppoered + +
+ +
+ SVN Fetcher + The URN for the SVN Fetcher is svn. + + The Variables FETCHCOMMAND_svn, DL_DIR are used by the SVN Fetcher. FETCHCOMMAND contains the subversion command, DL_DIR is the directory where tarballs will be saved. + + The supported Parameters are proto, rev. proto is the subversion prototype, rev is the subversions revision. + + SRC_URI = "svn://svn.oe.handhelds.org/svn;module=vip;proto=http;rev=667" +SRC_URI = "svn://svn.oe.handhelds.org/svn/;module=opie;proto=svn+ssh;date=20060126" + +
+ +
+ GIT Fetcher + The URN for the GIT Fetcher is git. + + The Variables DL_DIR, GITDIR are used. DL_DIR will be used to store the checkedout version. GITDIR will be used as the base directory where the git tree is cloned to. + + The Parameters are tag, protocol. tag is a git tag, the default is master. protocol is the git protocol to use and defaults to rsync. + + SRC_URI = "git://git.oe.handhelds.org/git/vip.git;tag=version-1" +SRC_URI = "git://git.oe.handhelds.org/git/vip.git;protocol=http" + +
+ +
+ + Commands
@@ -320,7 +400,7 @@ options: Depending on another .bb a.bb: PN = "package-a" - DEPENDS += "package-b" +DEPENDS += "package-b" b.bb: PN = "package-b" diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py index dabe978bf5..c6c0beb792 100644 --- a/bitbake/lib/bb/__init__.py +++ b/bitbake/lib/bb/__init__.py @@ -23,7 +23,7 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. """ -__version__ = "1.3.3.0" +__version__ = "1.3.3.4" __all__ = [ @@ -1229,38 +1229,6 @@ class digraph: mygraph.okeys=self.okeys[:] return mygraph -####################################################################### -####################################################################### -# -# SECTION: Config -# -# PURPOSE: Reading and handling of system/target-specific/local configuration -# reading of package configuration -# -####################################################################### -####################################################################### - -def reader(cfgfile, feeder): - """Generic configuration file reader that opens a file, reads the lines, - handles continuation lines, comments, empty lines and feed all read lines - into the function feeder(lineno, line). - """ - - f = open(cfgfile,'r') - lineno = 0 - 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() - s = s[:-1] + s2 - feeder(lineno, s) - if __name__ == "__main__": import doctest, bb doctest.testmod(bb) diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index 599b45d9d3..b59473bc23 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py @@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License along with Based on functions from the base bb module, Copyright 2003 Holger Schurig """ -from bb import debug, data, fetch, fatal, error, note, event, mkdirhier +from bb import debug, data, fetch, fatal, error, note, event, mkdirhier, utils import bb, os # data holds flags and function name for a given task @@ -122,14 +122,15 @@ def exec_func_python(func, d): """Execute a python BB 'function'""" import re, os - tmp = "def " + func + "():\n%s" % data.getVar(func, d) - comp = compile(tmp + '\n' + func + '()', bb.data.getVar('FILE', d, 1) + ':' + func, "exec") + 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 - exec comp in g + utils.better_exec(comp,g,tmp, bb.data.getVar('FILE',d,1)) if os.path.exists(prevdir): os.chdir(prevdir) diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py index b7d707a920..56ee977f66 100644 --- a/bitbake/lib/bb/data.py +++ b/bitbake/lib/bb/data.py @@ -31,7 +31,7 @@ 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.append(path) +sys.path.insert(0,path) from bb import note, debug, data_smart @@ -211,6 +211,11 @@ def delVarFlag(var, flag, d): 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 = {} diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 741790502f..52f391dec1 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py @@ -29,7 +29,7 @@ Based on functions from the base bb module, Copyright 2003 Holger Schurig """ import copy, os, re, sys, time, types -from bb import note, debug, fatal +from bb import note, debug, fatal, utils try: import cPickle as pickle @@ -287,8 +287,8 @@ class DataSmartPackage(DataSmart): self.unpickle_prep() funcstr = self.getVar('__functions__', 0) if funcstr: - comp = compile(funcstr, "", "exec") - exec comp in __builtins__ + comp = utils.better_compile(funcstr, "", self.bbfile) + utils.better_exec(comp, __builtins__, funcstr, self.bbfile) def linkDataSet(self): if not self.parent == None: diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index c4e88fa35d..cbe6d2a11a 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py @@ -25,6 +25,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA. import os, re import bb.data +import bb.utils class Event: """Base class for events""" @@ -50,8 +51,8 @@ def tmpHandler(event): return NotHandled def defaultTmpHandler(): - tmp = "def tmpHandler(e):\n\t\"\"\"heh\"\"\"\n\treturn 0" - comp = compile(tmp, "tmpHandler(e)", "exec") + 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): @@ -71,12 +72,12 @@ def register(handler): if handler is not None: # handle string containing python code if type(handler).__name__ == "str": - return registerCode(handler) + return _registerCode(handler) # prevent duplicate registration if not handler in handlers: handlers.append(handler) -def registerCode(handlerStr): +def _registerCode(handlerStr): """Register a 'code' Event. Deprecated interface; call register instead. @@ -85,7 +86,7 @@ def registerCode(handlerStr): the code will be within a function, so should have had appropriate tabbing put in place.""" tmp = "def tmpHandler(e):\n%s" % handlerStr - comp = compile(tmp, "tmpHandler(e)", "exec") + comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event._registerCode") # prevent duplicate registration if not comp in handlers: handlers.append(comp) @@ -94,16 +95,16 @@ def remove(handler): """Remove an Event handler""" for h in handlers: if type(handler).__name__ == "str": - return removeCode(handler) + return _removeCode(handler) if handler is h: handlers.remove(handler) -def removeCode(handlerStr): +def _removeCode(handlerStr): """Remove a 'code' Event handler Deprecated interface; call remove instead.""" tmp = "def tmpHandler(e):\n%s" % handlerStr - comp = compile(tmp, "tmpHandler(e)", "exec") + comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event._removeCode") handlers.remove(comp) def getName(e): @@ -117,7 +118,7 @@ def getName(e): class PkgBase(Event): """Base class for package events""" - def __init__(self, t, d = {}): + def __init__(self, t, d = bb.data.init()): self._pkg = t Event.__init__(self, d) @@ -133,10 +134,11 @@ class PkgBase(Event): class BuildBase(Event): """Base class for bbmake run events""" - def __init__(self, n, p, c): + 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 @@ -156,6 +158,12 @@ class BuildBase(Event): 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") @@ -204,7 +212,43 @@ class UnsatisfiedDep(DepBase): 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(PkgBase): +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 index da5b10c4b6..0515f2a5e9 100644 --- a/bitbake/lib/bb/fetch/__init__.py +++ b/bitbake/lib/bb/fetch/__init__.py @@ -158,18 +158,47 @@ class Fetch(object): return data.getVar("SRCDATE", d, 1) or data.getVar("CVSDATE", d, 1) or data.getVar("DATE", d, 1 ) getSRCDate = staticmethod(getSRCDate) -#if __name__ == "__main__": + 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): + 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.note("fetch " + uri) + fetchcmd = fetchcmd.replace("${URI}", uri) + ret = os.system(fetchcmd) + if ret == 0: + bb.note("Fetched %s from tarball stash, skipping checkout" % tarfn) + return True + return False + try_mirror = staticmethod(try_mirror) -import bk import cvs import git import local import svn import wget +import svk -methods.append(bk.Bk()) methods.append(cvs.Cvs()) methods.append(git.Git()) methods.append(local.Local()) methods.append(svn.Svn()) methods.append(wget.Wget()) +methods.append(svk.Svk()) diff --git a/bitbake/lib/bb/fetch/bk.py b/bitbake/lib/bb/fetch/bk.py deleted file mode 100644 index 6bd6c018fb..0000000000 --- a/bitbake/lib/bb/fetch/bk.py +++ /dev/null @@ -1,40 +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 '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 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. - -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 Bk(Fetch): - def supports(url, d): - """Check to see if a given url can be fetched via bitkeeper. - Expects supplied url in list form, as outputted by bb.decodeurl(). - """ - (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d)) - return type in ['bk'] - supports = staticmethod(supports) diff --git a/bitbake/lib/bb/fetch/cvs.py b/bitbake/lib/bb/fetch/cvs.py index 461a2f50f9..10ec700dc9 100644 --- a/bitbake/lib/bb/fetch/cvs.py +++ b/bitbake/lib/bb/fetch/cvs.py @@ -133,21 +133,9 @@ class Cvs(Fetch): bb.debug(1, "%s already exists, skipping cvs checkout." % tarfn) continue - pn = data.getVar('PN', d, 1) - cvs_tarball_stash = None - if pn: - cvs_tarball_stash = data.getVar('CVS_TARBALL_STASH_%s' % pn, d, 1) - if cvs_tarball_stash == None: - cvs_tarball_stash = data.getVar('CVS_TARBALL_STASH', d, 1) - if cvs_tarball_stash: - fetchcmd = data.getVar("FETCHCOMMAND_wget", d, 1) - uri = cvs_tarball_stash + tarfn - bb.note("fetch " + uri) - fetchcmd = fetchcmd.replace("${URI}", uri) - ret = os.system(fetchcmd) - if ret == 0: - bb.note("Fetched %s from tarball stash, skipping checkout" % tarfn) - continue + # try to use the tarball stash + if Fetch.try_mirror(d, tarfn): + continue if date: options.append("-D %s" % date) @@ -194,7 +182,7 @@ class Cvs(Fetch): bb.debug(1, "Running %s" % cvscmd) myret = os.system(cvscmd) - if myret != 0: + if myret != 0 or not os.access(moddir, os.R_OK): try: os.rmdir(moddir) except OSError: diff --git a/bitbake/lib/bb/fetch/git.py b/bitbake/lib/bb/fetch/git.py index 296b926392..439d522188 100644 --- a/bitbake/lib/bb/fetch/git.py +++ b/bitbake/lib/bb/fetch/git.py @@ -58,6 +58,28 @@ def gettag(parm): return tag +def getprotocol(parm): + if 'protocol' in parm: + proto = parm['protocol'] + else: + proto = "" + if not proto: + proto = "rsync" + + return proto + +def localfile(url, d): + """Return the filename to cache the checkout in""" + (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d)) + + #if user sets localpath for file, use it instead. + if "localpath" in parm: + return parm["localpath"] + + tag = gettag(parm) + + return data.expand('git_%s%s_%s.tar.gz' % (host, path.replace('/', '.'), tag), d) + class Git(Fetch): """Class to fetch a module or modules from git repositories""" def supports(url, d): @@ -69,17 +91,8 @@ class Git(Fetch): supports = staticmethod(supports) def localpath(url, d): - (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d)) - - #if user sets localpath for file, use it instead. - if "localpath" in parm: - return parm["localpath"] - tag = gettag(parm) - - localname = data.expand('git_%s%s_%s.tar.gz' % (host, path.replace('/', '.'), tag), d) - - return os.path.join(data.getVar("DL_DIR", d, 1),data.expand('%s' % (localname), d)) + return os.path.join(data.getVar("DL_DIR", d, 1), localfile(url, d)) localpath = staticmethod(localpath) @@ -92,10 +105,12 @@ class Git(Fetch): (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(loc, d)) tag = gettag(parm) + proto = getprotocol(parm) gitsrcname = '%s%s' % (host, path.replace('/', '.')) - repofile = os.path.join(data.getVar("DL_DIR", d, 1), 'git_%s.tar.gz' % (gitsrcname)) + 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' % (tag) @@ -103,63 +118,37 @@ class Git(Fetch): cofile = self.localpath(loc, d) - # Always update to current if tag=="master" - #if os.access(cofile, os.R_OK) and (tag != "master"): - if os.access(cofile, os.R_OK): - bb.debug(1, "%s already exists, skipping git checkout." % cofile) + # tag=="master" must always update + if (tag != "master") and Fetch.try_mirror(d, localfile(loc, d)): + bb.debug(1, "%s already exists (or was stashed). Skipping git checkout." % cofile) continue -# Still Need to add GIT_TARBALL_STASH Support... -# pn = data.getVar('PN', d, 1) -# cvs_tarball_stash = None -# if pn: -# cvs_tarball_stash = data.getVar('CVS_TARBALL_STASH_%s' % pn, d, 1) -# if cvs_tarball_stash == None: -# cvs_tarball_stash = data.getVar('CVS_TARBALL_STASH', d, 1) -# if cvs_tarball_stash: -# fetchcmd = data.getVar("FETCHCOMMAND_wget", d, 1) -# uri = cvs_tarball_stash + tarfn -# bb.note("fetch " + uri) -# fetchcmd = fetchcmd.replace("${URI}", uri) -# ret = os.system(fetchcmd) -# if ret == 0: -# bb.note("Fetched %s from tarball stash, skipping checkout" % tarfn) -# continue - - #if os.path.exists(repodir): - #prunedir(repodir) - - bb.mkdirhier(repodir) - os.chdir(repodir) - - #print("Changing to %s" % repodir) + if not os.path.exists(repodir): + if Fetch.try_mirror(d, repofilename): + bb.mkdirhier(repodir) + os.chdir(repodir) + rungitcmd("tar -xzf %s" % (repofile),d) + else: + rungitcmd("git clone %s://%s%s %s" % (proto, host, path, repodir),d) - if os.access(repofile, os.R_OK): - rungitcmd("tar -xzf %s" % (repofile),d) - else: - rungitcmd("git clone rsync://%s%s %s" % (host, path, repodir),d) - - rungitcmd("rsync -a --verbose --stats --progress rsync://%s%s/ %s" % (host, path, os.path.join(repodir, ".git", "")),d) - - #print("Changing to %s" % repodir) os.chdir(repodir) - rungitcmd("git pull rsync://%s%s" % (host, path),d) + rungitcmd("git pull %s://%s%s" % (proto, host, path),d) + rungitcmd("git pull --tags %s://%s%s" % (proto, host, path),d) + # old method of downloading tags + #rungitcmd("rsync -a --verbose --stats --progress rsync://%s%s/ %s" % (host, path, os.path.join(repodir, ".git", "")),d) - #print("Changing to %s" % repodir) os.chdir(repodir) + bb.note("Creating tarball of git repository") rungitcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ),d) if os.path.exists(codir): prunedir(codir) - #print("Changing to %s" % repodir) bb.mkdirhier(codir) os.chdir(repodir) rungitcmd("git read-tree %s" % (tag),d) - rungitcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")),d) - #print("Changing to %s" % codir) os.chdir(codir) + bb.note("Creating tarball of git checkout") rungitcmd("tar -czf %s %s" % (cofile, os.path.join(".", "*") ),d) - diff --git a/bitbake/lib/bb/fetch/svn.py b/bitbake/lib/bb/fetch/svn.py index ac5eebf5c0..6e3a9277ab 100644 --- a/bitbake/lib/bb/fetch/svn.py +++ b/bitbake/lib/bb/fetch/svn.py @@ -98,20 +98,14 @@ class Svn(Fetch): date = Fetch.getSRCDate(d) - if "method" in parm: - method = parm["method"] - else: - method = "pserver" - if "proto" in parm: proto = parm["proto"] else: proto = "svn" svn_rsh = None - if method == "ext": - if "rsh" in parm: - svn_rsh = parm["rsh"] + if proto == "svn+ssh" and "rsh" in parm: + svn_rsh = parm["rsh"] tarfn = data.expand('%s_%s_%s_%s_%s.tar.gz' % (module.replace('/', '.'), host, path.replace('/', '.'), revision, date), localdata) data.setVar('TARFILES', dlfile, localdata) @@ -122,24 +116,13 @@ class Svn(Fetch): bb.debug(1, "%s already exists, skipping svn checkout." % tarfn) continue - svn_tarball_stash = data.getVar('CVS_TARBALL_STASH', d, 1) - if svn_tarball_stash: - fetchcmd = data.getVar("FETCHCOMMAND_wget", d, 1) - uri = svn_tarball_stash + tarfn - bb.note("fetch " + uri) - fetchcmd = fetchcmd.replace("${URI}", uri) - ret = os.system(fetchcmd) - if ret == 0: - bb.note("Fetched %s from tarball stash, skipping checkout" % tarfn) - continue + # try to use the tarball stash + if Fetch.try_mirror(d, tarfn): + continue olddir = os.path.abspath(os.getcwd()) os.chdir(data.expand(dldir, localdata)) -# setup svnroot -# svnroot = ":" + method + ":" + user -# if pswd: -# svnroot += ":" + pswd svnroot = host + path data.setVar('SVNROOT', svnroot, localdata) diff --git a/bitbake/lib/bb/parse/parse_c/BBHandler.py b/bitbake/lib/bb/parse/parse_c/BBHandler.py new file mode 100644 index 0000000000..300871d9e3 --- /dev/null +++ b/bitbake/lib/bb/parse/parse_c/BBHandler.py @@ -0,0 +1,65 @@ +# 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. +# + +from bb import data +from bb.parse import ParseError + +# +# 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. + + + +# +# internal +# + + +# +# public +# +def supports(fn, data): + return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" + +def init(fn, data): + print "Init" + +def handle(fn, data, include): + print "" + print "fn: %s" % fn + print "data: %s" % data + print "include: %s" % include + + pass + +# 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/README.build b/bitbake/lib/bb/parse/parse_c/README.build new file mode 100644 index 0000000000..eb6ad8c862 --- /dev/null +++ b/bitbake/lib/bb/parse/parse_c/README.build @@ -0,0 +1,12 @@ +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 new file mode 100644 index 0000000000..bbb318e51f --- /dev/null +++ b/bitbake/lib/bb/parse/parse_c/__init__.py @@ -0,0 +1,28 @@ +# 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/bitbakeparser.cc b/bitbake/lib/bb/parse/parse_c/bitbakeparser.cc new file mode 100644 index 0000000000..3a3c53dd46 --- /dev/null +++ b/bitbake/lib/bb/parse/parse_c/bitbakeparser.cc @@ -0,0 +1,1105 @@ +/* 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 +#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 42 +#define YYACTIONTYPE unsigned char +#define bbparseTOKENTYPE token_t +typedef union { + bbparseTOKENTYPE yy0; + int yy83; +} 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 74 +#define YYNRULE 41 +#define YYERRORSYMBOL 28 +#define YYERRSYMDT yy83 +#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 */ 28, 47, 5, 57, 33, 58, 30, 25, 24, 37, + /* 10 */ 45, 14, 2, 29, 41, 3, 16, 4, 23, 39, + /* 20 */ 69, 8, 11, 17, 26, 48, 47, 32, 21, 42, + /* 30 */ 31, 57, 57, 73, 44, 10, 66, 7, 34, 38, + /* 40 */ 57, 51, 72, 116, 1, 62, 6, 49, 52, 35, + /* 50 */ 36, 59, 54, 9, 20, 64, 43, 22, 40, 50, + /* 60 */ 46, 71, 67, 60, 15, 65, 61, 70, 53, 56, + /* 70 */ 27, 12, 68, 63, 84, 55, 18, 84, 13, 84, + /* 80 */ 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, + /* 90 */ 84, 19, +}; +static const YYCODETYPE yy_lookahead[] = { + /* 0 */ 1, 2, 3, 21, 4, 23, 6, 7, 8, 9, + /* 10 */ 31, 32, 13, 14, 1, 16, 39, 18, 19, 20, + /* 20 */ 37, 38, 22, 24, 25, 1, 2, 4, 10, 6, + /* 30 */ 7, 21, 21, 23, 23, 22, 35, 36, 11, 12, + /* 40 */ 21, 5, 23, 29, 30, 33, 34, 5, 5, 10, + /* 50 */ 12, 10, 5, 22, 39, 15, 40, 11, 10, 5, + /* 60 */ 26, 17, 17, 10, 32, 35, 33, 17, 5, 5, + /* 70 */ 1, 22, 37, 1, 41, 5, 39, 41, 27, 41, + /* 80 */ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, + /* 90 */ 41, 39, +}; +#define YY_SHIFT_USE_DFLT (-19) +#define YY_SHIFT_MAX 43 +static const signed char yy_shift_ofst[] = { + /* 0 */ -19, -1, 18, 40, 45, 24, 18, 40, 45, -19, + /* 10 */ -19, -19, -19, -19, 0, 23, -18, 13, 19, 10, + /* 20 */ 11, 27, 53, 50, 63, 64, 69, 49, 51, 72, + /* 30 */ 70, 36, 42, 43, 39, 38, 41, 47, 48, 44, + /* 40 */ 46, 31, 54, 34, +}; +#define YY_REDUCE_USE_DFLT (-24) +#define YY_REDUCE_MAX 13 +static const signed char yy_reduce_ofst[] = { + /* 0 */ 14, -21, 12, 1, -17, 32, 33, 30, 35, 37, + /* 10 */ 52, -23, 15, 16, +}; +static const YYACTIONTYPE yy_default[] = { + /* 0 */ 76, 74, 115, 115, 115, 115, 94, 99, 103, 107, + /* 10 */ 107, 107, 107, 113, 115, 115, 115, 115, 115, 115, + /* 20 */ 115, 89, 115, 115, 115, 115, 115, 115, 77, 115, + /* 30 */ 115, 115, 115, 115, 115, 90, 115, 115, 115, 115, + /* 40 */ 91, 115, 115, 114, 111, 75, 112, 78, 77, 79, + /* 50 */ 80, 81, 82, 83, 84, 85, 86, 106, 108, 87, + /* 60 */ 88, 92, 93, 95, 96, 97, 98, 100, 101, 102, + /* 70 */ 104, 105, 109, 110, +}; +#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 +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: +**
    +**
  • A FILE* to which trace output should be written. +** If NULL, then tracing is turned off. +**
  • A prefix string written at the beginning of every +** line of trace output. If NULL, then tracing is +** turned off. +**
+** +** 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_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_IMMEDIATE STRING", + /* 7 */ "statement ::= EXPORT variable OP_COND STRING", + /* 8 */ "statement ::= variable OP_ASSIGN STRING", + /* 9 */ "statement ::= variable OP_PREPEND STRING", + /* 10 */ "statement ::= variable OP_APPEND STRING", + /* 11 */ "statement ::= variable OP_IMMEDIATE STRING", + /* 12 */ "statement ::= variable OP_COND STRING", + /* 13 */ "task ::= TSYMBOL BEFORE TSYMBOL AFTER TSYMBOL", + /* 14 */ "task ::= TSYMBOL AFTER TSYMBOL BEFORE TSYMBOL", + /* 15 */ "task ::= TSYMBOL", + /* 16 */ "task ::= TSYMBOL BEFORE TSYMBOL", + /* 17 */ "task ::= TSYMBOL AFTER TSYMBOL", + /* 18 */ "tasks ::= tasks task", + /* 19 */ "tasks ::= task", + /* 20 */ "statement ::= ADDTASK tasks", + /* 21 */ "statement ::= ADDHANDLER SYMBOL", + /* 22 */ "func ::= FSYMBOL", + /* 23 */ "funcs ::= funcs func", + /* 24 */ "funcs ::= func", + /* 25 */ "statement ::= EXPORT_FUNC funcs", + /* 26 */ "inherit ::= ISYMBOL", + /* 27 */ "inherits ::= inherits inherit", + /* 28 */ "inherits ::= inherit", + /* 29 */ "statement ::= INHERIT inherits", + /* 30 */ "statement ::= INCLUDE ISYMBOL", + /* 31 */ "statement ::= REQUIRE ISYMBOL", + /* 32 */ "proc_body ::= proc_body PROC_BODY", + /* 33 */ "proc_body ::=", + /* 34 */ "statement ::= variable PROC_OPEN proc_body PROC_CLOSE", + /* 35 */ "statement ::= PYTHON SYMBOL PROC_OPEN proc_body PROC_CLOSE", + /* 36 */ "statement ::= PYTHON PROC_OPEN proc_body PROC_CLOSE", + /* 37 */ "statement ::= FAKEROOT SYMBOL PROC_OPEN proc_body PROC_CLOSE", + /* 38 */ "def_body ::= def_body DEF_BODY", + /* 39 */ "def_body ::=", + /* 40 */ "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 *yypm