Update to latest bitbake

git-svn-id: https://svn.o-hand.com/repos/poky/trunk@309 311d38ba-8fff-0310-9ca6-ca027cbcb966
This commit is contained in:
Richard Purdie 2006-03-20 17:45:11 +00:00
parent 3cd47ad235
commit b26a945734
29 changed files with 4868 additions and 410 deletions

View File

@ -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.

View File

@ -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

View File

@ -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()

View File

@ -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 """<table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="g" href="index.html">Home</a></td>
<td><a accesskey="n" href="groups.html">Groups</a></td>
<td><a accesskey="u" href="keys.html">Keys</a></td>
<td><a accesskey="n" href="all_groups.html">Groups</a></td>
<td><a accesskey="u" href="all_keys.html">Keys</a></td>
</tr></table>
"""
@ -89,10 +89,11 @@ class HTMLFormatter:
return ""
txt = "<p><b>See also:</b><br>"
txts = []
for it in item.related():
txt += """<a href="key%s.html">%s</a>, """ % (it, it)
txts.append("""<a href="key%(it)s.html">%(it)s</a>""" % vars() )
return txt
return txt + ",".join(txts)
def groups(self,item):
"""
@ -103,11 +104,12 @@ class HTMLFormatter:
return ""
txt = "<p><b>Seel also:</b><br>"
txt = "<p><b>See also:</b><br>"
txts = []
for group in item.groups():
txt += """<a href="group%s.html">%s</a>, """ % (group,group)
txts.append( """<a href="group%s.html">%s</a> """ % (group,group) )
return txt
return txt + ",".join(txts)
def createKeySite(self,item):
@ -125,23 +127,23 @@ class HTMLFormatter:
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">
<p>
%s
</pre>
</p>
</div>
<div class="refsynopsisdiv">
<h2>Related Keys</h2>
<pre class="synopsis">
<p>
%s
</pre>
</p>
</div>
<div class="refsynopsisdiv">
<h2>Groups</h2>
<pre class="synopsis">
<p>
%s
</pre>
</p>
</div>
@ -181,8 +183,8 @@ class HTMLFormatter:
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
%s
<h2>Documentation Entrance</h2>
<a href="groups.html">All available groups</a><br>
<a href="keys.html">All available keys</a><br>
<a href="all_groups.html">All available groups</a><br>
<a href="all_keys.html">All available keys</a><br>
</body>
""" % self.createNavigator()
@ -206,13 +208,21 @@ class HTMLFormatter:
</body>
""" % (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 += "<h2 Description of Grozp %s</h2>" % gr
description += _description
items.sort(lambda x,y:cmp(x.name(),y.name()))
for group in items:
groups += """<a href="key%s.html">%s</a><br>""" % (group.name(), group.name())
@ -221,6 +231,7 @@ class HTMLFormatter:
<link rel="stylesheet" href="style.css" type="text/css">
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
%s
%s
<div class="refsynopsisdiv">
<h2>Keys in Group %s</h2>
<pre class="synopsis">
@ -228,7 +239,7 @@ class HTMLFormatter:
</pre>
</div>
</body>
""" % (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

View File

@ -12,7 +12,7 @@
<corpauthor>BitBake Team</corpauthor>
</authorgroup>
<copyright>
<year>2004, 2005</year>
<year>2004, 2005, 2006</year>
<holder>Chris Larson</holder>
<holder>Phil Blundell</holder>
</copyright>
@ -111,9 +111,9 @@ share common metadata between many packages.</para></listitem>
<section>
<title>Appending (.=) and prepending (=.) without spaces</title>
<para><screen><varname>B</varname> = "bval"
<varname>B</varname> += "additionaldata"
<varname>B</varname> .= "additionaldata"
<varname>C</varname> = "cval"
<varname>C</varname> =+ "test"</screen></para>
<varname>C</varname> =. "test"</screen></para>
<para>In this example, <varname>B</varname> is now <literal>bvaladditionaldata</literal> and <varname>C</varname> is <literal>testcval</literal>. In contrast to the above Appending and Prepending operators no additional space
will be introduced.</para>
</section>
@ -228,6 +228,86 @@ of the event and the content of the <varname>FILE</varname> variable.</para>
</section>
</section>
</chapter>
<chapter>
<title>File Download support</title>
<section>
<title>Overview</title>
<para>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 <quote>;</quote> 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.
</para>
</section>
<section>
<title>Local File Fetcher</title>
<para>The URN for the Local File Fetcher is <emphasis>file</emphasis>. The filename can be either absolute or relative. If the filename is relative <varname>FILESPATH</varname> and <varname>FILESDIR</varname> will be used to find the appropriate relative file depending on the <varname>OVERRIDES</varname>. Single files and complete directories can be specified.
<screen><varname>SRC_URI</varname>= "file://relativefile.patch"
<varname>SRC_URI</varname>= "file://relativefile.patch;this=ignored"
<varname>SRC_URI</varname>= "file:///Users/ich/very_important_software"
</screen>
</para>
</section>
<section>
<title>CVS File Fetcher</title>
<para>The URN for the CVS Fetcher is <emphasis>cvs</emphasis>. This Fetcher honors the variables <varname>DL_DIR</varname>, <varname>SRCDATE</varname>, <varname>FETCHCOMMAND_cvs</varname>, <varname>UPDATECOMMAND_cvs</varname>. <varname>DL_DIRS</varname> specifies where a temporary checkout is saved, <varname>SRCDATE</varname> specifies which date to use when doing the fetching, <varname>FETCHCOMMAND</varname> and <varname>UPDATECOMMAND</varname> specify which executables should be used when doing the CVS checkout or update.
</para>
<para>The supported Parameters are <varname>module</varname>, <varname>tag</varname>, <varname>date</varname>, <varname>method</varname>, <varname>localdir</varname>, <varname>rsh</varname>. The <varname>module</varname> specifies which module to check out, the <varname>tag</varname> describes which CVS TAG should be used for the checkout by default the TAG is empty. A <varname>date</varname> can be specified to override the SRCDATE of the configuration to checkout a specific date. <varname>method</varname> is by default <emphasis>pserver</emphasis>, if <emphasis>ext</emphasis> is used the <varname>rsh</varname> parameter will be evaluated and <varname>CVS_RSH</varname> will be set. Finally <varname>localdir</varname> is used to checkout into a special directory relative to <varname>CVSDIR></varname>.
<screen><varname>SRC_URI</varname> = "cvs://CVSROOT;module=mymodule;tag=some-version;method=ext"
<varname>SRC_URI</varname> = "cvs://CVSROOT;module=mymodule;date=20060126;localdir=usethat"
</screen>
</para>
</section>
<section>
<title>HTTP/FTP Fetcher</title>
<para>The URNs for the HTTP/FTP are <emphasis>http</emphasis>, <emphasis>https</emphasis> and <emphasis>ftp</emphasis>. This Fetcher honors the variables <varname>DL_DIR</varname>, <varname>FETCHCOMMAND_wget</varname>, <varname>PREMIRRORS</varname>, <varname>MIRRORS</varname>. The <varname>DL_DIR</varname> defines where to store the fetched file, <varname>FETCHCOMMAND</varname> contains the command used for fetching. <quote>${URI}</quote> and <quote>${FILES}</quote> will be replaced by the uri and basename of the to be fetched file. <varname>PREMIRRORS</varname>
will be tried first when fetching a file if that fails the actual file will be tried and finally all <varname>MIRRORS</varname> will be tried.
</para>
<para>The only supported Parameter is <varname>md5sum</varname>. After a fetch the <varname>md5sum</varname> of the file will be calculated and the two sums will be compared.
</para>
<para><screen><varname>SRC_URI</varname> = "http://oe.handhelds.org/not_there.aac;md5sum=12343"
<varname>SRC_URI</varname> = "ftp://oe.handhelds.org/not_there_as_well.aac;md5sum=1234"
<varname>SRC_URI</varname> = "ftp://you@oe.handheld.sorg/home/you/secret.plan;md5sum=1234"
</screen></para>
</section>
<section>
<title>SVK Fetcher</title>
<para>
<emphasis>Currently NOT suppoered</emphasis>
</para>
</section>
<section>
<title>SVN Fetcher</title>
<para>The URN for the SVN Fetcher is <emphasis>svn</emphasis>.
</para>
<para>The Variables <varname>FETCHCOMMAND_svn</varname>, <varname>DL_DIR</varname> are used by the SVN Fetcher. <varname>FETCHCOMMAND</varname> contains the subversion command, <varname>DL_DIR</varname> is the directory where tarballs will be saved.
</para>
<para>The supported Parameters are <varname>proto</varname>, <varname>rev</varname>. <varname>proto</varname> is the subversion prototype, <varname>rev</varname> is the subversions revision.
</para>
<para><screen><varname>SRC_URI</varname> = "svn://svn.oe.handhelds.org/svn;module=vip;proto=http;rev=667"
<varname>SRC_URI</varname> = "svn://svn.oe.handhelds.org/svn/;module=opie;proto=svn+ssh;date=20060126"
</screen></para>
</section>
<section>
<title>GIT Fetcher</title>
<para>The URN for the GIT Fetcher is <emphasis>git</emphasis>.
</para>
<para>The Variables <varname>DL_DIR</varname>, <varname>GITDIR</varname> are used. <varname>DL_DIR</varname> will be used to store the checkedout version. <varname>GITDIR</varname> will be used as the base directory where the git tree is cloned to.
</para>
<para>The Parameters are <emphasis>tag</emphasis>, <emphasis>protocol</emphasis>. <emphasis>tag</emphasis> is a git tag, the default is <quote>master</quote>. <emphasis>protocol</emphasis> is the git protocol to use and defaults to <quote>rsync</quote>.
</para>
<para><screen><varname>SRC_URI</varname> = "git://git.oe.handhelds.org/git/vip.git;tag=version-1"
<varname>SRC_URI</varname> = "git://git.oe.handhelds.org/git/vip.git;protocol=http"
</screen></para>
</section>
</chapter>
<chapter>
<title>Commands</title>
<section>
@ -320,7 +400,7 @@ options:
<title>Depending on another .bb</title>
<para>a.bb:
<screen>PN = "package-a"
DEPENDS += "package-b"</screen>
DEPENDS += "package-b"</screen>
</para>
<para>b.bb:
<screen>PN = "package-b"</screen>

View File

@ -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)

View File

@ -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)

View File

@ -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 = {}

View File

@ -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:

View File

@ -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"""
class MultipleProviders(PkgBase):
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

View File

@ -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())

View File

@ -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)

View File

@ -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:

View File

@ -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)
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)
bb.mkdirhier(repodir)
os.chdir(repodir)
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)
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)
#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)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
#define T_SYMBOL 1
#define T_VARIABLE 2
#define T_EXPORT 3
#define T_OP_ASSIGN 4
#define T_STRING 5
#define T_OP_IMMEDIATE 6
#define T_OP_COND 7
#define T_OP_PREPEND 8
#define T_OP_APPEND 9
#define T_TSYMBOL 10
#define T_BEFORE 11
#define T_AFTER 12
#define T_ADDTASK 13
#define T_ADDHANDLER 14
#define T_FSYMBOL 15
#define T_EXPORT_FUNC 16
#define T_ISYMBOL 17
#define T_INHERIT 18
#define T_INCLUDE 19
#define T_REQUIRE 20
#define T_PROC_BODY 21
#define T_PROC_OPEN 22
#define T_PROC_CLOSE 23
#define T_PYTHON 24
#define T_FAKEROOT 25
#define T_DEF_BODY 26
#define T_DEF_ARGS 27

View File

@ -1,133 +0,0 @@
"""
BitBake C Parser Python Code
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.
"""
__version__ = "0xdeadbeef"
class CParser:
"""
The C-based Parser for Bitbake
"""
def __init__(self, data, type):
"""
Constructor
"""
self._data = data
def _syntax_error(self, file, line):
"""
lemon/flex reports an syntax error to us and we will
raise an exception
"""
pass
def _export(self, data):
"""
EXPORT VAR = "MOO"
we will now export VAR
"""
pass
def _assign(self, key, value):
"""
VAR = "MOO"
we will assign moo to VAR
"""
pass
def _assign(self, key, value):
"""
"""
pass
def _append(self, key, value):
"""
VAR += "MOO"
we will append " MOO" to var
"""
pass
def _prepend(self, key, value):
"""
VAR =+ "MOO"
we will prepend "MOO " to var
"""
pass
def _immediate(self, key, value):
"""
VAR := "MOO ${CVSDATE}"
we will assign immediately and expand vars
"""
pass
def _conditional(self, key, value):
"""
"""
pass
def _add_task(self, task, before = None, after = None):
"""
"""
pass
def _include(self, file):
"""
"""
pass
def _inherit(self, file):
"""
"""
pass
def _shell_procedure(self, name, body):
"""
"""
pass
def _python_procedure(self, name, body):
"""
"""
pass
def _fakeroot_procedure(self, name, body):
"""
"""
pass
def _def_procedure(self, a, b, c):
"""
"""
pass
def _export_func(self, name):
"""
"""
pass
def _add_handler(self, handler):
"""
"""
pass

View File

@ -42,13 +42,14 @@
%include {
#include "token.h"
#include "lexer.h"
#include "python_output.h"
}
%token_destructor { $$.release_this (); }
%syntax_error { printf ("%s:%d: syntax error\n",
lex->filename (), lex->line ()); }
%syntax_error { e_parse_error( lex ); }
program ::= statements.
@ -56,79 +57,82 @@ statements ::= statements statement.
statements ::= .
variable(r) ::= SYMBOL(s).
{ r.assignString( s.string() );
{ r.assignString( (char*)s.string() );
s.assignString( 0 );
s.release_this(); }
variable(r) ::= VARIABLE(v).
{
r.assignString( v.string() );
r.assignString( (char*)v.string() );
v.assignString( 0 );
v.release_this(); }
statement ::= EXPORT variable(s) OP_ASSIGN STRING(v).
{ e_assign( s.string(), v.string() );
e_export( s.string() );
{ e_assign( 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 (s.string(), v.string() );
e_export( s.string() );
{ 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( s.string(), v.string() );
{ e_cond( lex, s.string(), v.string() );
s.release_this(); v.release_this(); }
statement ::= variable(s) OP_ASSIGN STRING(v).
{ e_assign( s.string(), v.string() );
{ e_assign( lex, s.string(), v.string() );
s.release_this(); v.release_this(); }
statement ::= variable(s) OP_PREPEND STRING(v).
{ e_prepend( s.string(), v.string() );
{ e_prepend( lex, s.string(), v.string() );
s.release_this(); v.release_this(); }
statement ::= variable(s) OP_APPEND STRING(v).
{ e_append( s.string() , v.string() );
{ e_append( lex, s.string() , v.string() );
s.release_this(); v.release_this(); }
statement ::= variable(s) OP_IMMEDIATE STRING(v).
{ e_immediate( s.string(), v.string() );
{ e_immediate( lex, s.string(), v.string() );
s.release_this(); v.release_this(); }
statement ::= variable(s) OP_COND STRING(v).
{ e_cond( s.string(), v.string() );
{ e_cond( lex, s.string(), v.string() );
s.release_this(); v.release_this(); }
task ::= TSYMBOL(t) BEFORE TSYMBOL(b) AFTER TSYMBOL(a).
{ e_addtask( t.string(), b.string(), a.string() );
{ 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( t.string(), b.string(), a.string());
{ e_addtask( lex, t.string(), b.string(), a.string());
t.release_this(); a.release_this(); b.release_this(); }
task ::= TSYMBOL(t).
{ e_addtask( t.string(), NULL, NULL);
{ e_addtask( lex, t.string(), NULL, NULL);
t.release_this();}
task ::= TSYMBOL(t) BEFORE TSYMBOL(b).
{ e_addtask( t.string(), b.string(), NULL);
{ e_addtask( lex, t.string(), b.string(), NULL);
t.release_this(); b.release_this(); }
task ::= TSYMBOL(t) AFTER TSYMBOL(a).
{ e_addtask( t.string(), NULL, a.string());
{ 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( s.string()); s.release_this (); }
{ e_addhandler( lex, s.string()); s.release_this (); }
func ::= FSYMBOL(f). { e_export_func(f.string()); f.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(i.string() ); i.release_this (); }
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(i.string() ); i.release_this(); }
{ e_include( lex, i.string() ); i.release_this(); }
proc_body(r) ::= proc_body(l) PROC_BODY(b).
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 ();
@ -136,26 +140,26 @@ proc_body(r) ::= proc_body(l) PROC_BODY(b).
}
proc_body(b) ::= . { b.assignString(0); }
statement ::= variable(p) PROC_OPEN proc_body(b) PROC_CLOSE.
{ e_proc( p.string(), b.string() );
{ 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 (p.string(), b.string() );
{ 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( NULL, b.string());
{ e_proc_python( lex, NULL, b.string());
b.release_this (); }
statement ::= FAKEROOT SYMBOL(p) PROC_OPEN proc_body(b) PROC_CLOSE.
{ e_proc_fakeroot(p.string(), b.string() );
{ 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());
r.assignString( token_t::concatString(l.string(), b.string()) );
l.release_this (); b.release_this ();
}
def_body(b) ::= . { b.sz = 0; }
def_body(b) ::= . { b.assignString( 0 ); }
statement ::= SYMBOL(p) DEF_ARGS(a) def_body(b).
{ e_def( p.string(), a.string(), b.string());
{ e_def( lex, p.string(), a.string(), b.string());
p.release_this(); a.release_this(); b.release_this(); }

File diff suppressed because it is too large Load Diff

View File

@ -71,6 +71,7 @@
#include "token.h"
#include "lexer.h"
#include "bitbakeparser.h"
#include <ctype.h>
extern void *bbparseAlloc(void *(*mallocProc)(size_t));
@ -124,6 +125,7 @@ K_AFTER "after"
K_BEFORE "before"
K_DEF "def"
K_INCLUDE "include"
K_REQUIRE "require"
K_INHERIT "inherit"
K_PYTHON "python"
K_FAKEROOT "fakeroot"
@ -149,6 +151,7 @@ PROC \({C_SP}*\)
%s S_FUNC
%s S_INCLUDE
%s S_INHERIT
%s S_REQUIRE
%s S_PROC
%s S_RVALUE
%s S_TASK
@ -186,6 +189,8 @@ PROC \({C_SP}*\)
{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;
@ -224,7 +229,8 @@ PROC \({C_SP}*\)
<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; }
@ -253,12 +259,7 @@ int lex_t::line ()const
return yyget_lineno (scanner);
}
const char* lex_t::filename ()const
{
return m_fileName;
}
void parse (MappedFile* mf)
void parse (FILE* file, PyObject* data)
{
void* parser = bbparseAlloc (malloc);
yyscan_t scanner;
@ -268,9 +269,8 @@ void parse (MappedFile* mf)
lex.parser = parser;
lex.scanner = scanner;
lex.mf = mf;
lex.rgbInput = mf->m_rgb;
lex.cbInput = mf->m_cb;
lex.file = file;
lex.data = data;
lex.parse = bbparse;
yyset_extra (&lex, scanner);
@ -281,7 +281,7 @@ void parse (MappedFile* mf)
bbparseTrace (NULL, NULL);
if (result != T_EOF)
WARNING ("premature end of file\n");
printf ("premature end of file\n");
yylex_destroy (scanner);
bbparseFree (parser, free);

View File

@ -24,17 +24,29 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef LEXER_H
#define LEXER_H
/*
* The PyObject Token. Likely to be
* a bb.data implementation
*/
struct PyObject;
/**
* This is used by the Parser and Scanner
* of BitBake.
* The implementation and creation is done
* in the scanner.
*/
struct lex_t {
void *parser;
void *scanner;
FILE *file;
PyObject *data;
void* (*parse)(void*, int, token_t, lex_t*);
void accept(int token, const char* string = 0);
void input(char *buf, int *result, int_max_size);
void input(char *buf, int *result, int max_size);
int line()const;
const char* filename()const;
private:
const char* m_fileName;
};

View File

@ -0,0 +1,51 @@
#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.
*/
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_assign(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_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

View File

@ -24,13 +24,24 @@ 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(const char* str);
void assignString(char* str);
void copyString(const char* str);
void release_this();
@ -51,15 +62,17 @@ inline const char* token_t::string()const
inline char* token_t::concatString(const char* l, const char* r)
{
size_t cb = (l ? strlen (l) : 0) + strlen (r) + 1;
r_sz = new char[cb];
char *r_sz = new char[cb];
*r_sz = 0;
if (l) strcat (r_sz, l);
if (l)
strcat (r_sz, l);
strcat (r_sz, r);
return r_sz;
}
inline void token_t::assignString(const char* str)
inline void token_t::assignString(char* str)
{
m_string = str;
m_stringLen = str ? strlen(str) : 0;
@ -70,7 +83,7 @@ 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)
strcpy(m_string, str);
}
}

View File

@ -22,7 +22,7 @@
Place, Suite 330, Boston, MA 02111-1307 USA."""
import re, bb, os, sys
import bb.fetch, bb.build
import bb.fetch, bb.build, bb.utils
from bb import debug, data, fetch, fatal
from ConfHandler import include, localpath, obtain, init
@ -206,8 +206,8 @@ def feeder(lineno, s, fn, d):
return
else:
text = '\n'.join(__body__)
comp = compile(text, "<bb>", "exec")
exec comp in __builtins__
comp = bb.utils.better_compile(text, "<bb>", fn )
bb.utils.better_exec(comp, __builtins__, text, fn)
__body__ = []
__inpython__ = False
funcs = data.getVar('__functions__', d) or ""

View File

@ -86,10 +86,77 @@ def explode_deps(s):
j = []
if flag:
j.append(i)
if i.endswith(')'):
else:
r.append(i)
if flag and i.endswith(')'):
flag = False
# Ignore version
#r[-1] += ' ' + ' '.join(j)
else:
r.append(i)
return r
def _print_trace(body, line):
"""
Print the Environment of a Text Body
"""
import bb
# print the environment of the method
bb.error("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.error("\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.error("Error in compiling: ", realfile)
bb.error("The lines resulting into this error were:")
bb.error("\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.error("Error in executing: ", realfile)
bb.error("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