summaryrefslogtreecommitdiff
path: root/bitbake/lib/bb/parse
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2011-02-23 10:48:51 -0800
committerKhem Raj <raj.khem@gmail.com>2011-02-23 10:48:51 -0800
commit951cbf3f65f347c7a7bbcae193218f9187a15fbf (patch)
tree96e9c74551e6931804992f8f49af05f732eb0fff /bitbake/lib/bb/parse
parentadbaae2179a6c3746e53f7fbb2ca0939e85a7ea9 (diff)
downloadopenembedded-core-951cbf3f65f347c7a7bbcae193218f9187a15fbf.tar.gz
openembedded-core-951cbf3f65f347c7a7bbcae193218f9187a15fbf.tar.bz2
openembedded-core-951cbf3f65f347c7a7bbcae193218f9187a15fbf.tar.xz
openembedded-core-951cbf3f65f347c7a7bbcae193218f9187a15fbf.zip
bitbake: Remove in-tree version
Bitbake should be used by checking it out from its own repo Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'bitbake/lib/bb/parse')
-rw-r--r--bitbake/lib/bb/parse/__init__.py123
-rw-r--r--bitbake/lib/bb/parse/ast.py446
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py254
-rw-r--r--bitbake/lib/bb/parse/parse_py/ConfHandler.py139
-rw-r--r--bitbake/lib/bb/parse/parse_py/__init__.py33
5 files changed, 0 insertions, 995 deletions
diff --git a/bitbake/lib/bb/parse/__init__.py b/bitbake/lib/bb/parse/__init__.py
deleted file mode 100644
index eee8d9cdd..000000000
--- a/bitbake/lib/bb/parse/__init__.py
+++ /dev/null
@@ -1,123 +0,0 @@
-"""
-BitBake Parsers
-
-File parsers for the BitBake build tools.
-
-"""
-
-
-# Copyright (C) 2003, 2004 Chris Larson
-# Copyright (C) 2003, 2004 Phil Blundell
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Based on functions from the base bb module, Copyright 2003 Holger Schurig
-
-handlers = []
-
-import os
-import stat
-import logging
-import bb
-import bb.utils
-import bb.siggen
-
-logger = logging.getLogger("BitBake.Parsing")
-
-class ParseError(Exception):
- """Exception raised when parsing fails"""
-
-class SkipPackage(Exception):
- """Exception raised to skip this package"""
-
-__mtime_cache = {}
-def cached_mtime(f):
- if f not in __mtime_cache:
- __mtime_cache[f] = os.stat(f)[stat.ST_MTIME]
- return __mtime_cache[f]
-
-def cached_mtime_noerror(f):
- if f not in __mtime_cache:
- try:
- __mtime_cache[f] = os.stat(f)[stat.ST_MTIME]
- except OSError:
- return 0
- return __mtime_cache[f]
-
-def update_mtime(f):
- __mtime_cache[f] = os.stat(f)[stat.ST_MTIME]
- return __mtime_cache[f]
-
-def mark_dependency(d, f):
- if f.startswith('./'):
- f = "%s/%s" % (os.getcwd(), f[2:])
- deps = bb.data.getVar('__depends', d) or set()
- deps.update([(f, cached_mtime(f))])
- bb.data.setVar('__depends', deps, d)
-
-def supports(fn, data):
- """Returns true if we have a handler for this file, false otherwise"""
- for h in handlers:
- if h['supports'](fn, data):
- return 1
- return 0
-
-def handle(fn, data, include = 0):
- """Call the handler that is appropriate for this file"""
- for h in handlers:
- if h['supports'](fn, data):
- return h['handle'](fn, data, include)
- raise ParseError("%s is not a BitBake file" % fn)
-
-def init(fn, data):
- for h in handlers:
- if h['supports'](fn):
- return h['init'](data)
-
-def init_parser(d):
- bb.parse.siggen = bb.siggen.init(d)
-
-def resolve_file(fn, d):
- if not os.path.isabs(fn):
- bbpath = bb.data.getVar("BBPATH", d, True)
- newfn = bb.utils.which(bbpath, fn)
- if not newfn:
- raise IOError("file %s not found in %s" % (fn, bbpath))
- fn = newfn
-
- logger.debug(2, "LOAD %s", fn)
- return fn
-
-# Used by OpenEmbedded metadata
-__pkgsplit_cache__={}
-def vars_from_file(mypkg, d):
- if not mypkg:
- return (None, None, None)
- if mypkg in __pkgsplit_cache__:
- return __pkgsplit_cache__[mypkg]
-
- myfile = os.path.splitext(os.path.basename(mypkg))
- parts = myfile[0].split('_')
- __pkgsplit_cache__[mypkg] = parts
- if len(parts) > 3:
- raise ParseError("Unable to generate default variables from the filename: %s (too many underscores)" % mypkg)
- exp = 3 - len(parts)
- tmplist = []
- while exp != 0:
- exp -= 1
- tmplist.append(None)
- parts.extend(tmplist)
- return parts
-
-from bb.parse.parse_py import __version__, ConfHandler, BBHandler
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py
deleted file mode 100644
index b968db40b..000000000
--- a/bitbake/lib/bb/parse/ast.py
+++ /dev/null
@@ -1,446 +0,0 @@
-# ex:ts=4:sw=4:sts=4:et
-# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-"""
- AbstractSyntaxTree classes for the Bitbake language
-"""
-
-# Copyright (C) 2003, 2004 Chris Larson
-# Copyright (C) 2003, 2004 Phil Blundell
-# Copyright (C) 2009 Holger Hans Peter Freyther
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-from __future__ import absolute_import
-from future_builtins import filter
-import re
-import string
-import logging
-import bb
-import itertools
-from bb import methodpool
-from bb.parse import logger
-
-__parsed_methods__ = bb.methodpool.get_parsed_dict()
-_bbversions_re = re.compile(r"\[(?P<from>[0-9]+)-(?P<to>[0-9]+)\]")
-
-class StatementGroup(list):
- def eval(self, data):
- for statement in self:
- statement.eval(data)
-
-class AstNode(object):
- def __init__(self, filename, lineno):
- self.filename = filename
- self.lineno = lineno
-
-class IncludeNode(AstNode):
- def __init__(self, filename, lineno, what_file, force):
- AstNode.__init__(self, filename, lineno)
- self.what_file = what_file
- self.force = force
-
- def eval(self, data):
- """
- Include the file and evaluate the statements
- """
- s = bb.data.expand(self.what_file, data)
- logger.debug(2, "CONF %s:%s: including %s", self.filename, self.lineno, s)
-
- # TODO: Cache those includes... maybe not here though
- if self.force:
- bb.parse.ConfHandler.include(self.filename, s, data, "include required")
- else:
- bb.parse.ConfHandler.include(self.filename, s, data, False)
-
-class ExportNode(AstNode):
- def __init__(self, filename, lineno, var):
- AstNode.__init__(self, filename, lineno)
- self.var = var
-
- def eval(self, data):
- bb.data.setVarFlag(self.var, "export", 1, data)
-
-class DataNode(AstNode):
- """
- Various data related updates. For the sake of sanity
- we have one class doing all this. This means that all
- this need to be re-evaluated... we might be able to do
- that faster with multiple classes.
- """
- def __init__(self, filename, lineno, groupd):
- AstNode.__init__(self, filename, lineno)
- self.groupd = groupd
-
- def getFunc(self, key, data):
- if 'flag' in self.groupd and self.groupd['flag'] != None:
- return bb.data.getVarFlag(key, self.groupd['flag'], data)
- else:
- return bb.data.getVar(key, data)
-
- def eval(self, data):
- groupd = self.groupd
- key = groupd["var"]
- if "exp" in groupd and groupd["exp"] != None:
- bb.data.setVarFlag(key, "export", 1, data)
- if "ques" in groupd and groupd["ques"] != None:
- val = self.getFunc(key, data)
- if val == None:
- val = groupd["value"]
- elif "colon" in groupd and groupd["colon"] != None:
- e = data.createCopy()
- bb.data.update_data(e)
- val = bb.data.expand(groupd["value"], e)
- elif "append" in groupd and groupd["append"] != None:
- val = "%s %s" % ((self.getFunc(key, data) or ""), groupd["value"])
- elif "prepend" in groupd and groupd["prepend"] != None:
- val = "%s %s" % (groupd["value"], (self.getFunc(key, data) or ""))
- elif "postdot" in groupd and groupd["postdot"] != None:
- val = "%s%s" % ((self.getFunc(key, data) or ""), groupd["value"])
- elif "predot" in groupd and groupd["predot"] != None:
- val = "%s%s" % (groupd["value"], (self.getFunc(key, data) or ""))
- else:
- val = groupd["value"]
-
- if 'flag' in groupd and groupd['flag'] != None:
- bb.data.setVarFlag(key, groupd['flag'], val, data)
- elif groupd["lazyques"]:
- bb.data.setVarFlag(key, "defaultval", val, data)
- else:
- bb.data.setVar(key, val, data)
-
-class MethodNode(AstNode):
- def __init__(self, filename, lineno, func_name, body):
- AstNode.__init__(self, filename, lineno)
- self.func_name = func_name
- self.body = body
-
- def eval(self, data):
- if self.func_name == "__anonymous":
- funcname = ("__anon_%s_%s" % (self.lineno, self.filename.translate(string.maketrans('/.+-', '____'))))
- if not funcname in bb.methodpool._parsed_fns:
- text = "def %s(d):\n" % (funcname) + '\n'.join(self.body)
- bb.methodpool.insert_method(funcname, text, self.filename)
- anonfuncs = bb.data.getVar('__BBANONFUNCS', data) or []
- anonfuncs.append(funcname)
- bb.data.setVar('__BBANONFUNCS', anonfuncs, data)
- else:
- bb.data.setVarFlag(self.func_name, "func", 1, data)
- bb.data.setVar(self.func_name, '\n'.join(self.body), data)
-
-class PythonMethodNode(AstNode):
- def __init__(self, filename, lineno, function, define, body):
- AstNode.__init__(self, filename, lineno)
- self.function = function
- self.define = define
- self.body = body
-
- def eval(self, data):
- # Note we will add root to parsedmethods after having parse
- # 'this' file. This means we will not parse methods from
- # bb classes twice
- text = '\n'.join(self.body)
- if not bb.methodpool.parsed_module(self.define):
- bb.methodpool.insert_method(self.define, text, self.filename)
- bb.data.setVarFlag(self.function, "func", 1, data)
- bb.data.setVarFlag(self.function, "python", 1, data)
- bb.data.setVar(self.function, text, data)
-
-class MethodFlagsNode(AstNode):
- def __init__(self, filename, lineno, key, m):
- AstNode.__init__(self, filename, lineno)
- self.key = key
- self.m = m
-
- def eval(self, data):
- if bb.data.getVar(self.key, data):
- # clean up old version of this piece of metadata, as its
- # flags could cause problems
- bb.data.setVarFlag(self.key, 'python', None, data)
- bb.data.setVarFlag(self.key, 'fakeroot', None, data)
- if self.m.group("py") is not None:
- bb.data.setVarFlag(self.key, "python", "1", data)
- else:
- bb.data.delVarFlag(self.key, "python", data)
- if self.m.group("fr") is not None:
- bb.data.setVarFlag(self.key, "fakeroot", "1", data)
- else:
- bb.data.delVarFlag(self.key, "fakeroot", data)
-
-class ExportFuncsNode(AstNode):
- def __init__(self, filename, lineno, fns, classes):
- AstNode.__init__(self, filename, lineno)
- self.n = fns.split()
- self.classes = classes
-
- def eval(self, data):
- for f in self.n:
- allvars = []
- allvars.append(f)
- allvars.append(self.classes[-1] + "_" + f)
-
- vars = [[ allvars[0], allvars[1] ]]
- if len(self.classes) > 1 and self.classes[-2] is not None:
- allvars.append(self.classes[-2] + "_" + f)
- vars = []
- vars.append([allvars[2], allvars[1]])
- vars.append([allvars[0], allvars[2]])
-
- for (var, calledvar) in vars:
- if bb.data.getVar(var, data) and not bb.data.getVarFlag(var, 'export_func', data):
- continue
-
- if bb.data.getVar(var, data):
- bb.data.setVarFlag(var, 'python', None, data)
- bb.data.setVarFlag(var, 'func', None, data)
-
- for flag in [ "func", "python" ]:
- if bb.data.getVarFlag(calledvar, flag, data):
- bb.data.setVarFlag(var, flag, bb.data.getVarFlag(calledvar, flag, data), data)
- for flag in [ "dirs" ]:
- if bb.data.getVarFlag(var, flag, data):
- bb.data.setVarFlag(calledvar, flag, bb.data.getVarFlag(var, flag, data), data)
-
- if bb.data.getVarFlag(calledvar, "python", data):
- bb.data.setVar(var, "\tbb.build.exec_func('" + calledvar + "', d)\n", data)
- else:
- bb.data.setVar(var, "\t" + calledvar + "\n", data)
- bb.data.setVarFlag(var, 'export_func', '1', data)
-
-class AddTaskNode(AstNode):
- def __init__(self, filename, lineno, func, before, after):
- AstNode.__init__(self, filename, lineno)
- self.func = func
- self.before = before
- self.after = after
-
- def eval(self, data):
- var = self.func
- if self.func[:3] != "do_":
- var = "do_" + self.func
-
- bb.data.setVarFlag(var, "task", 1, data)
- bbtasks = bb.data.getVar('__BBTASKS', data) or []
- if not var in bbtasks:
- bbtasks.append(var)
- bb.data.setVar('__BBTASKS', bbtasks, data)
-
- existing = bb.data.getVarFlag(var, "deps", data) or []
- if self.after is not None:
- # set up deps for function
- for entry in self.after.split():
- if entry not in existing:
- existing.append(entry)
- bb.data.setVarFlag(var, "deps", existing, data)
- if self.before is not None:
- # set up things that depend on this func
- for entry in self.before.split():
- existing = bb.data.getVarFlag(entry, "deps", data) or []
- if var not in existing:
- bb.data.setVarFlag(entry, "deps", [var] + existing, data)
-
-class BBHandlerNode(AstNode):
- def __init__(self, filename, lineno, fns):
- AstNode.__init__(self, filename, lineno)
- self.hs = fns.split()
-
- def eval(self, data):
- bbhands = bb.data.getVar('__BBHANDLERS', data) or []
- for h in self.hs:
- bbhands.append(h)
- bb.data.setVarFlag(h, "handler", 1, data)
- bb.data.setVar('__BBHANDLERS', bbhands, data)
-
-class InheritNode(AstNode):
- def __init__(self, filename, lineno, classes):
- AstNode.__init__(self, filename, lineno)
- self.classes = classes
-
- def eval(self, data):
- bb.parse.BBHandler.inherit(self.classes, data)
-
-def handleInclude(statements, filename, lineno, m, force):
- statements.append(IncludeNode(filename, lineno, m.group(1), force))
-
-def handleExport(statements, filename, lineno, m):
- statements.append(ExportNode(filename, lineno, m.group(1)))
-
-def handleData(statements, filename, lineno, groupd):
- statements.append(DataNode(filename, lineno, groupd))
-
-def handleMethod(statements, filename, lineno, func_name, body):
- statements.append(MethodNode(filename, lineno, func_name, body))
-
-def handlePythonMethod(statements, filename, lineno, funcname, root, body):
- statements.append(PythonMethodNode(filename, lineno, funcname, root, body))
-
-def handleMethodFlags(statements, filename, lineno, key, m):
- statements.append(MethodFlagsNode(filename, lineno, key, m))
-
-def handleExportFuncs(statements, filename, lineno, m, classes):
- statements.append(ExportFuncsNode(filename, lineno, m.group(1), classes))
-
-def handleAddTask(statements, filename, lineno, m):
- func = m.group("func")
- before = m.group("before")
- after = m.group("after")
- if func is None:
- return
-
- statements.append(AddTaskNode(filename, lineno, func, before, after))
-
-def handleBBHandlers(statements, filename, lineno, m):
- statements.append(BBHandlerNode(filename, lineno, m.group(1)))
-
-def handleInherit(statements, filename, lineno, m):
- classes = m.group(1)
- statements.append(InheritNode(filename, lineno, classes.split()))
-
-def finalize(fn, d, variant = None):
- bb.data.expandKeys(d)
- bb.data.update_data(d)
- code = []
- for funcname in bb.data.getVar("__BBANONFUNCS", d) or []:
- code.append("%s(d)" % funcname)
- bb.utils.simple_exec("\n".join(code), {"d": d})
- bb.data.update_data(d)
-
- all_handlers = {}
- for var in bb.data.getVar('__BBHANDLERS', d) or []:
- # try to add the handler
- handler = bb.data.getVar(var, d)
- bb.event.register(var, handler)
-
- tasklist = bb.data.getVar('__BBTASKS', d) or []
- bb.build.add_tasks(tasklist, d)
-
- bb.parse.siggen.finalise(fn, d, variant)
-
- bb.event.fire(bb.event.RecipeParsed(fn), d)
-
-def _create_variants(datastores, names, function):
- def create_variant(name, orig_d, arg = None):
- new_d = bb.data.createCopy(orig_d)
- function(arg or name, new_d)
- datastores[name] = new_d
-
- for variant, variant_d in datastores.items():
- for name in names:
- if not variant:
- # Based on main recipe
- create_variant(name, variant_d)
- else:
- create_variant("%s-%s" % (variant, name), variant_d, name)
-
-def _expand_versions(versions):
- def expand_one(version, start, end):
- for i in xrange(start, end + 1):
- ver = _bbversions_re.sub(str(i), version, 1)
- yield ver
-
- versions = iter(versions)
- while True:
- try:
- version = next(versions)
- except StopIteration:
- break
-
- range_ver = _bbversions_re.search(version)
- if not range_ver:
- yield version
- else:
- newversions = expand_one(version, int(range_ver.group("from")),
- int(range_ver.group("to")))
- versions = itertools.chain(newversions, versions)
-
-def multi_finalize(fn, d):
- appends = (d.getVar("__BBAPPEND", True) or "").split()
- for append in appends:
- logger.debug(2, "Appending .bbappend file %s to %s", append, fn)
- bb.parse.BBHandler.handle(append, d, True)
-
- safe_d = d
- d = bb.data.createCopy(safe_d)
- try:
- finalize(fn, d)
- except bb.parse.SkipPackage:
- bb.data.setVar("__SKIPPED", True, d)
- datastores = {"": safe_d}
-
- versions = (d.getVar("BBVERSIONS", True) or "").split()
- if versions:
- pv = orig_pv = d.getVar("PV", True)
- baseversions = {}
-
- def verfunc(ver, d, pv_d = None):
- if pv_d is None:
- pv_d = d
-
- overrides = d.getVar("OVERRIDES", True).split(":")
- pv_d.setVar("PV", ver)
- overrides.append(ver)
- bpv = baseversions.get(ver) or orig_pv
- pv_d.setVar("BPV", bpv)
- overrides.append(bpv)
- d.setVar("OVERRIDES", ":".join(overrides))
-
- versions = list(_expand_versions(versions))
- for pos, version in enumerate(list(versions)):
- try:
- pv, bpv = version.split(":", 2)
- except ValueError:
- pass
- else:
- versions[pos] = pv
- baseversions[pv] = bpv
-
- if pv in versions and not baseversions.get(pv):
- versions.remove(pv)
- else:
- pv = versions.pop()
-
- # This is necessary because our existing main datastore
- # has already been finalized with the old PV, we need one
- # that's been finalized with the new PV.
- d = bb.data.createCopy(safe_d)
- verfunc(pv, d, safe_d)
- try:
- finalize(fn, d)
- except bb.parse.SkipPackage:
- bb.data.setVar("__SKIPPED", True, d)
-
- _create_variants(datastores, versions, verfunc)
-
- extended = d.getVar("BBCLASSEXTEND", True) or ""
- if extended:
- pn = d.getVar("PN", True)
- def extendfunc(name, d):
- d.setVar("PN", "%s-%s" % (pn, name))
- bb.parse.BBHandler.inherit([name], d)
-
- safe_d.setVar("BBCLASSEXTEND", extended)
- _create_variants(datastores, extended.split(), extendfunc)
-
- for variant, variant_d in datastores.iteritems():
- if variant:
- try:
- finalize(fn, variant_d, variant)
- except bb.parse.SkipPackage:
- bb.data.setVar("__SKIPPED", True, variant_d)
-
- if len(datastores) > 1:
- variants = filter(None, datastores.iterkeys())
- safe_d.setVar("__VARIANTS", " ".join(variants))
-
- datastores[""] = d
- return datastores
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
deleted file mode 100644
index 402cd07e2..000000000
--- a/bitbake/lib/bb/parse/parse_py/BBHandler.py
+++ /dev/null
@@ -1,254 +0,0 @@
-#!/usr/bin/env python
-# ex:ts=4:sw=4:sts=4:et
-# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-"""
- class for handling .bb files
-
- Reads a .bb file and obtains its metadata
-
-"""
-
-
-# Copyright (C) 2003, 2004 Chris Larson
-# Copyright (C) 2003, 2004 Phil Blundell
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-from __future__ import absolute_import
-import re, bb, os
-import logging
-import bb.build, bb.utils
-from bb import data
-
-from . import ConfHandler
-from .. import resolve_file, ast, logger
-from .ConfHandler import include, init
-
-# For compatibility
-bb.deprecate_import(__name__, "bb.parse", ["vars_from_file"])
-
-__func_start_regexp__ = re.compile( r"(((?P<py>python)|(?P<fr>fakeroot))\s*)*(?P<func>[\w\.\-\+\{\}\$]+)?\s*\(\s*\)\s*{$" )
-__inherit_regexp__ = re.compile( r"inherit\s+(.+)" )
-__export_func_regexp__ = re.compile( r"EXPORT_FUNCTIONS\s+(.+)" )
-__addtask_regexp__ = re.compile("addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*")
-__addhandler_regexp__ = re.compile( r"addhandler\s+(.+)" )
-__def_regexp__ = re.compile( r"def\s+(\w+).*:" )
-__python_func_regexp__ = re.compile( r"(\s+.*)|(^$)" )
-
-
-__infunc__ = ""
-__inpython__ = False
-__body__ = []
-__classname__ = ""
-classes = [ None, ]
-
-cached_statements = {}
-
-# 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
-
-
-
-def supports(fn, d):
- """Return True if fn has a supported extension"""
- return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"]
-
-def inherit(files, d):
- __inherit_cache = data.getVar('__inherit_cache', d) or []
- fn = ""
- lineno = 0
- for file in files:
- file = data.expand(file, d)
- if not os.path.isabs(file) and not file.endswith(".bbclass"):
- file = os.path.join('classes', '%s.bbclass' % file)
-
- if not file in __inherit_cache:
- logger.log(logging.DEBUG -1, "BB %s:%d: inheriting %s", fn, lineno, file)
- __inherit_cache.append( file )
- data.setVar('__inherit_cache', __inherit_cache, d)
- include(fn, file, d, "inherit")
- __inherit_cache = data.getVar('__inherit_cache', d) or []
-
-def get_statements(filename, absolute_filename, base_name):
- global cached_statements
-
- try:
- return cached_statements[absolute_filename]
- except KeyError:
- file = open(absolute_filename, 'r')
- statements = ast.StatementGroup()
-
- lineno = 0
- while True:
- lineno = lineno + 1
- s = file.readline()
- if not s: break
- s = s.rstrip()
- feeder(lineno, s, filename, base_name, statements)
- if __inpython__:
- # add a blank line to close out any python definition
- feeder(IN_PYTHON_EOF, "", filename, base_name, statements)
-
- if filename.endswith(".bbclass") or filename.endswith(".inc"):
- cached_statements[absolute_filename] = statements
- return statements
-
-def handle(fn, d, include):
- global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__
- __body__ = []
- __infunc__ = ""
- __classname__ = ""
- __residue__ = []
-
-
- if include == 0:
- logger.debug(2, "BB %s: handle(data)", fn)
- else:
- logger.debug(2, "BB %s: handle(data, include)", fn)
-
- base_name = os.path.basename(fn)
- (root, ext) = os.path.splitext(base_name)
- init(d)
-
- if ext == ".bbclass":
- __classname__ = root
- classes.append(__classname__)
- __inherit_cache = data.getVar('__inherit_cache', d) or []
- if not fn in __inherit_cache:
- __inherit_cache.append(fn)
- data.setVar('__inherit_cache', __inherit_cache, d)
-
- if include != 0:
- oldfile = data.getVar('FILE', d)
- else:
- oldfile = None
-
- abs_fn = resolve_file(fn, d)
-
- if include:
- bb.parse.mark_dependency(d, abs_fn)
-
- # actual loading
- statements = get_statements(fn, abs_fn, base_name)
-
- # DONE WITH PARSING... time to evaluate
- if ext != ".bbclass":
- data.setVar('FILE', fn, d)
-
- statements.eval(d)
-
- if ext == ".bbclass":
- classes.remove(__classname__)
- else:
- if include == 0:
- return ast.multi_finalize(fn, d)
-
- if oldfile:
- bb.data.setVar("FILE", oldfile, d)
-
- # we have parsed the bb class now
- if ext == ".bbclass" or ext == ".inc":
- bb.methodpool.get_parsed_dict()[base_name] = 1
-
- return d
-
-def feeder(lineno, s, fn, root, statements):
- global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__, __infunc__, __body__, classes, bb, __residue__
- if __infunc__:
- if s == '}':
- __body__.append('')
- ast.handleMethod(statements, fn, lineno, __infunc__, __body__)
- __infunc__ = ""
- __body__ = []
- else:
- __body__.append(s)
- return
-
- if __inpython__:
- m = __python_func_regexp__.match(s)
- if m and lineno != IN_PYTHON_EOF:
- __body__.append(s)
- return
- else:
- ast.handlePythonMethod(statements, fn, lineno, __inpython__,
- root, __body__)
- __body__ = []
- __inpython__ = False
-
- if lineno == IN_PYTHON_EOF:
- return
-
-
- # Skip empty lines
- if s == '':
- return
-
- if s[0] == '#':
- if len(__residue__) != 0 and __residue__[0][0] != "#":
- bb.error("There is a comment on line %s of file %s (%s) which is in the middle of a multiline expression.\nBitbake used to ignore these but no longer does so, please fix your metadata as errors are likely as a result of this change." % (lineno, fn, s))
-
- if s[-1] == '\\':
- __residue__.append(s[:-1])
- return
-
- s = "".join(__residue__) + s
- __residue__ = []
-
- # Skip comments
- if s[0] == '#':
- return
-
- m = __func_start_regexp__.match(s)
- if m:
- __infunc__ = m.group("func") or "__anonymous"
- ast.handleMethodFlags(statements, fn, lineno, __infunc__, m)
- return
-
- m = __def_regexp__.match(s)
- if m:
- __body__.append(s)
- __inpython__ = m.group(1)
-
- return
-
- m = __export_func_regexp__.match(s)
- if m:
- ast.handleExportFuncs(statements, fn, lineno, m, classes)
- return
-
- m = __addtask_regexp__.match(s)
- if m:
- ast.handleAddTask(statements, fn, lineno, m)
- return
-
- m = __addhandler_regexp__.match(s)
- if m:
- ast.handleBBHandlers(statements, fn, lineno, m)
- return
-
- m = __inherit_regexp__.match(s)
- if m:
- ast.handleInherit(statements, fn, lineno, m)
- return
-
- return ConfHandler.feeder(lineno, s, fn, statements)
-
-# Add us to the handlers list
-from .. import handlers
-handlers.append({'supports': supports, 'handle': handle, 'init': init})
-del handlers
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py
deleted file mode 100644
index fc239a354..000000000
--- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/usr/bin/env python
-# ex:ts=4:sw=4:sts=4:et
-# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-"""
- class for handling configuration data files
-
- Reads a .conf file and obtains its metadata
-
-"""
-
-# Copyright (C) 2003, 2004 Chris Larson
-# Copyright (C) 2003, 2004 Phil Blundell
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-import re, bb.data, os
-import logging
-import bb.utils
-from bb.parse import ParseError, resolve_file, ast, logger
-
-#__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}]+)\s*(?P<colon>:)?(?P<ques>\?)?=\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$")
-__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<lazyques>\?\?=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$")
-__include_regexp__ = re.compile( r"include\s+(.+)" )
-__require_regexp__ = re.compile( r"require\s+(.+)" )
-__export_regexp__ = re.compile( r"export\s+(.+)" )
-
-def init(data):
- topdir = bb.data.getVar('TOPDIR', data)
- if not topdir:
- bb.data.setVar('TOPDIR', os.getcwd(), data)
-
-
-def supports(fn, d):
- return fn[-5:] == ".conf"
-
-def include(oldfn, fn, data, error_out):
- """
- error_out If True a ParseError will be raised if the to be included
- config-files could not be included.
- """
- if oldfn == fn: # prevent infinite recursion
- return None
-
- import bb
- fn = bb.data.expand(fn, data)
- oldfn = bb.data.expand(oldfn, data)
-
- if not os.path.isabs(fn):
- dname = os.path.dirname(oldfn)
- bbpath = "%s:%s" % (dname, bb.data.getVar("BBPATH", data, 1))
- abs_fn = bb.utils.which(bbpath, fn)
- if abs_fn:
- fn = abs_fn
-
- from bb.parse import handle
- try:
- ret = handle(fn, data, True)
- except IOError:
- if error_out:
- raise ParseError("Could not %(error_out)s file %(fn)s" % vars() )
- logger.debug(2, "CONF file '%s' not found", fn)
-
-def handle(fn, data, include):
- init(data)
-
- if include == 0:
- oldfile = None
- else:
- oldfile = bb.data.getVar('FILE', data)
-
- abs_fn = resolve_file(fn, data)
- f = open(abs_fn, 'r')
-
- if include:
- bb.parse.mark_dependency(data, abs_fn)
-
- statements = ast.StatementGroup()
- lineno = 0
- while True:
- lineno = lineno + 1
- s = f.readline()
- if not s: break
- w = s.strip()
- if not w: continue # skip empty lines
- s = s.rstrip()
- if s[0] == '#': continue # skip comments
- while s[-1] == '\\':
- s2 = f.readline()[:-1].strip()
- lineno = lineno + 1
- s = s[:-1] + s2
- feeder(lineno, s, fn, statements)
-
- # DONE WITH PARSING... time to evaluate
- bb.data.setVar('FILE', fn, data)
- statements.eval(data)
- if oldfile:
- bb.data.setVar('FILE', oldfile, data)
-
- return data
-
-def feeder(lineno, s, fn, statements):
- m = __config_regexp__.match(s)
- if m:
- groupd = m.groupdict()
- ast.handleData(statements, fn, lineno, groupd)
- return
-
- m = __include_regexp__.match(s)
- if m:
- ast.handleInclude(statements, fn, lineno, m, False)
- return
-
- m = __require_regexp__.match(s)
- if m:
- ast.handleInclude(statements, fn, lineno, m, True)
- return
-
- m = __export_regexp__.match(s)
- if m:
- ast.handleExport(statements, fn, lineno, m)
- return
-
- raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s));
-
-# Add us to the handlers list
-from bb.parse import handlers
-handlers.append({'supports': supports, 'handle': handle, 'init': init})
-del handlers
diff --git a/bitbake/lib/bb/parse/parse_py/__init__.py b/bitbake/lib/bb/parse/parse_py/__init__.py
deleted file mode 100644
index 3e658d0de..000000000
--- a/bitbake/lib/bb/parse/parse_py/__init__.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-# ex:ts=4:sw=4:sts=4:et
-# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-"""
-BitBake Parsers
-
-File parsers for the BitBake build tools.
-
-"""
-
-# Copyright (C) 2003, 2004 Chris Larson
-# Copyright (C) 2003, 2004 Phil Blundell
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Based on functions from the base bb module, Copyright 2003 Holger Schurig
-
-from __future__ import absolute_import
-from . import ConfHandler
-from . import BBHandler
-
-__version__ = '1.0'