From 306b7c7a9757ead077363074e7bbac2e5c03e7c5 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 16 Nov 2006 15:02:15 +0000 Subject: bitbake: Upgrade from 1.4 -> 1.7.4ish git-svn-id: https://svn.o-hand.com/repos/poky/trunk@863 311d38ba-8fff-0310-9ca6-ca027cbcb966 --- bitbake/lib/bb/parse/parse_py/BBHandler.py | 28 +++++++++++++++-------- bitbake/lib/bb/parse/parse_py/ConfHandler.py | 33 ++++++++++++++-------------- 2 files changed, 35 insertions(+), 26 deletions(-) (limited to 'bitbake/lib/bb/parse/parse_py') diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index c82090fec0..34f4d25996 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py @@ -23,7 +23,7 @@ import re, bb, os, sys, time import bb.fetch, bb.build, bb.utils -from bb import debug, data, fetch, fatal, methodpool +from bb import data, fetch, methodpool from ConfHandler import include, localpath, obtain, init from bb.parse import ParseError @@ -44,6 +44,13 @@ __bbpath_found__ = 0 __classname__ = "" classes = [ None, ] +# We need to indicate EOF to the feeder. This code is so messy that +# factoring it out to a close_parse_file method is out of question. +# We will use the IN_PYTHON_EOF as an indicator to just close the method +# +# The two parts using it are tightly integrated anyway +IN_PYTHON_EOF = -9999999999999 + __parsed_methods__ = methodpool.get_parsed_dict() def supports(fn, d): @@ -60,9 +67,9 @@ def inherit(files, d): file = os.path.join('classes', '%s.bbclass' % file) if not file in __inherit_cache.split(): - debug(2, "BB %s:%d: inheriting %s" % (fn, lineno, file)) + bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file)) __inherit_cache += " %s" % file - include(fn, file, d) + include(fn, file, d, "inherit") data.setVar('__inherit_cache', __inherit_cache, d) @@ -75,9 +82,9 @@ def handle(fn, d, include = 0): __residue__ = [] if include == 0: - debug(2, "BB " + fn + ": handle(data)") + bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data)") else: - debug(2, "BB " + fn + ": handle(data, include)") + bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data, include)") (root, ext) = os.path.splitext(os.path.basename(fn)) base_name = "%s%s" % (root,ext) @@ -132,7 +139,7 @@ def handle(fn, d, include = 0): feeder(lineno, s, fn, base_name, d) if __inpython__: # add a blank line to close out any python definition - feeder(lineno + 1, "", fn, base_name, d) + feeder(IN_PYTHON_EOF, "", fn, base_name, d) if ext == ".bbclass": classes.remove(__classname__) else: @@ -152,7 +159,7 @@ def handle(fn, d, include = 0): if t: data.setVar('T', t, d) except Exception, e: - bb.debug(1, "executing anonymous function: %s" % e) + bb.msg.debug(1, bb.msg.domain.Parsing, "executing anonymous function: %s" % e) raise data.delVar("__anonqueue", d) data.delVar("__anonfunc", d) @@ -220,7 +227,7 @@ def feeder(lineno, s, fn, root, d): if __inpython__: m = __python_func_regexp__.match(s) - if m: + if m and lineno != IN_PYTHON_EOF: __body__.append(s) return else: @@ -240,6 +247,9 @@ def feeder(lineno, s, fn, root, d): __body__ = [] __inpython__ = False + if lineno == IN_PYTHON_EOF: + return + # fall through if s == '' or s[0] == '#': return # skip comments and empty lines @@ -374,7 +384,7 @@ def vars_from_file(mypkg, d): def set_additional_vars(file, d, include): """Deduce rest of variables, e.g. ${A} out of ${SRC_URI}""" - debug(2,"BB %s: set_additional_vars" % file) + bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s: set_additional_vars" % file) src_uri = data.getVar('SRC_URI', d) if not src_uri: diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index 90978300af..4bc2bbc2b7 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py @@ -22,7 +22,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA.""" import re, bb.data, os, sys -from bb import debug, fatal from bb.parse import ParseError #__config_regexp__ = re.compile( r"(?Pexport\s*)?(?P[a-zA-Z0-9\-_+.${}]+)\s*(?P:)?(?P\?)?=\s*(?P['\"]?)(?P.*)(?P=apo)$") @@ -53,7 +52,7 @@ def localpath(fn, d): localfn = fn return localfn -def obtain(fn, data = bb.data.init()): +def obtain(fn, data): import sys, bb fn = bb.data.expand(fn, data) localfn = bb.data.expand(localpath(fn, data), data) @@ -61,30 +60,30 @@ def obtain(fn, data = bb.data.init()): if localfn != fn: dldir = bb.data.getVar('DL_DIR', data, 1) if not dldir: - debug(1, "obtain: DL_DIR not defined") + bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: DL_DIR not defined") return localfn bb.mkdirhier(dldir) try: bb.fetch.init([fn]) except bb.fetch.NoMethodError: (type, value, traceback) = sys.exc_info() - debug(1, "obtain: no method: %s" % value) + bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: no method: %s" % value) return localfn try: bb.fetch.go(data) except bb.fetch.MissingParameterError: (type, value, traceback) = sys.exc_info() - debug(1, "obtain: missing parameters: %s" % value) + bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: missing parameters: %s" % value) return localfn except bb.fetch.FetchError: (type, value, traceback) = sys.exc_info() - debug(1, "obtain: failed: %s" % value) + bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: failed: %s" % value) return localfn return localfn -def include(oldfn, fn, data = bb.data.init(), error_out = False): +def include(oldfn, fn, data, error_out): """ error_out If True a ParseError will be reaised if the to be included @@ -101,10 +100,10 @@ def include(oldfn, fn, data = bb.data.init(), error_out = False): ret = handle(fn, data, True) except IOError: if error_out: - raise ParseError("Could not include required file %(fn)s" % vars() ) - debug(2, "CONF file '%s' not found" % fn) + raise ParseError("Could not %(error_out)s file %(fn)s" % vars() ) + bb.msg.debug(2, bb.msg.domain.Parsing, "CONF file '%s' not found" % fn) -def handle(fn, data = bb.data.init(), include = 0): +def handle(fn, data, include = 0): if include: inc_string = "including" else: @@ -129,13 +128,13 @@ def handle(fn, data = bb.data.init(), include = 0): if os.access(currname, os.R_OK): f = open(currname, 'r') abs_fn = currname - debug(1, "CONF %s %s" % (inc_string, currname)) + bb.msg.debug(2, bb.msg.domain.Parsing, "CONF %s %s" % (inc_string, currname)) break if f is None: raise IOError("file '%s' not found" % fn) else: f = open(fn,'r') - debug(1, "CONF %s %s" % (inc_string,fn)) + bb.msg.debug(1, bb.msg.domain.Parsing, "CONF %s %s" % (inc_string,fn)) abs_fn = fn if include: @@ -161,7 +160,7 @@ def handle(fn, data = bb.data.init(), include = 0): bb.data.setVar('FILE', oldfile, data) return data -def feeder(lineno, s, fn, data = bb.data.init()): +def feeder(lineno, s, fn, data): m = __config_regexp__.match(s) if m: groupd = m.groupdict() @@ -185,7 +184,7 @@ def feeder(lineno, s, fn, data = bb.data.init()): else: val = groupd["value"] if 'flag' in groupd and groupd['flag'] != None: -# bb.note("setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val)) + bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val)) bb.data.setVarFlag(key, groupd['flag'], val, data) else: bb.data.setVar(key, val, data) @@ -194,14 +193,14 @@ def feeder(lineno, s, fn, data = bb.data.init()): m = __include_regexp__.match(s) if m: s = bb.data.expand(m.group(1), data) -# debug(2, "CONF %s:%d: including %s" % (fn, lineno, s)) - include(fn, s, data) + bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s)) + include(fn, s, data, False) return m = __require_regexp__.match(s) if m: s = bb.data.expand(m.group(1), data) - include(fn, s, data, True) + include(fn, s, data, "include required") return raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); -- cgit v1.2.3