diff options
| author | Richard Purdie <richard@openedhand.com> | 2006-03-20 17:45:11 +0000 |
|---|---|---|
| committer | Richard Purdie <richard@openedhand.com> | 2006-03-20 17:45:11 +0000 |
| commit | b26a945734ce271aa7d443ff9e96fe2851b21138 (patch) | |
| tree | f540b8d58a7411cf0cabe5c8f4ad40f9f597352a /bitbake/lib | |
| parent | 3cd47ad235d54a9c539ae6fe4a5a2b4b5f7e5621 (diff) | |
| download | openembedded-core-b26a945734ce271aa7d443ff9e96fe2851b21138.tar.gz openembedded-core-b26a945734ce271aa7d443ff9e96fe2851b21138.tar.bz2 openembedded-core-b26a945734ce271aa7d443ff9e96fe2851b21138.zip | |
Update to latest bitbake
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@309 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake/lib')
24 files changed, 4720 insertions, 376 deletions
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, "<pickled>", "exec") - exec comp in __builtins__ + comp = utils.better_compile(funcstr, "<pickled>", 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 <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 |
