summaryrefslogtreecommitdiffstats
path: root/external/poky/bitbake/lib/bb/parse
diff options
context:
space:
mode:
authortakeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp>2020-11-02 11:07:33 +0900
committertakeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp>2020-11-02 11:07:33 +0900
commit1c7d6584a7811b7785ae5c1e378f14b5ba0971cf (patch)
treecd70a267a5ef105ba32f200aa088e281fbd85747 /external/poky/bitbake/lib/bb/parse
parent4204309872da5cb401cbb2729d9e2d4869a87f42 (diff)
recipes
Diffstat (limited to 'external/poky/bitbake/lib/bb/parse')
-rw-r--r--external/poky/bitbake/lib/bb/parse/__init__.py14
-rw-r--r--external/poky/bitbake/lib/bb/parse/ast.py41
-rw-r--r--external/poky/bitbake/lib/bb/parse/parse_py/BBHandler.py61
-rw-r--r--external/poky/bitbake/lib/bb/parse/parse_py/ConfHandler.py61
-rw-r--r--external/poky/bitbake/lib/bb/parse/parse_py/__init__.py17
5 files changed, 76 insertions, 118 deletions
diff --git a/external/poky/bitbake/lib/bb/parse/__init__.py b/external/poky/bitbake/lib/bb/parse/__init__.py
index 5397d57a..76e180b4 100644
--- a/external/poky/bitbake/lib/bb/parse/__init__.py
+++ b/external/poky/bitbake/lib/bb/parse/__init__.py
@@ -9,20 +9,10 @@ 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.
+# SPDX-License-Identifier: GPL-2.0-only
#
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
+#
handlers = []
diff --git a/external/poky/bitbake/lib/bb/parse/ast.py b/external/poky/bitbake/lib/bb/parse/ast.py
index 9d20c323..eb8cfa21 100644
--- a/external/poky/bitbake/lib/bb/parse/ast.py
+++ b/external/poky/bitbake/lib/bb/parse/ast.py
@@ -1,5 +1,3 @@
-# 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
"""
@@ -8,25 +6,10 @@
# 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.
+# SPDX-License-Identifier: GPL-2.0-only
#
-# 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
-import string
-import logging
import bb
-import itertools
from bb import methodpool
from bb.parse import logger
@@ -106,7 +89,7 @@ class DataNode(AstNode):
self.groupd = groupd
def getFunc(self, key, data):
- if 'flag' in self.groupd and self.groupd['flag'] != None:
+ if 'flag' in self.groupd and self.groupd['flag'] is not None:
return data.getVarFlag(key, self.groupd['flag'], expand=False, noweakdefault=True)
else:
return data.getVar(key, False, noweakdefault=True, parsing=True)
@@ -119,36 +102,36 @@ class DataNode(AstNode):
'file': self.filename,
'line': self.lineno,
}
- if "exp" in groupd and groupd["exp"] != None:
+ if "exp" in groupd and groupd["exp"] is not None:
data.setVarFlag(key, "export", 1, op = 'exported', **loginfo)
op = "set"
- if "ques" in groupd and groupd["ques"] != None:
+ if "ques" in groupd and groupd["ques"] is not None:
val = self.getFunc(key, data)
op = "set?"
- if val == None:
+ if val is None:
val = groupd["value"]
- elif "colon" in groupd and groupd["colon"] != None:
+ elif "colon" in groupd and groupd["colon"] is not None:
e = data.createCopy()
op = "immediate"
val = e.expand(groupd["value"], key + "[:=]")
- elif "append" in groupd and groupd["append"] != None:
+ elif "append" in groupd and groupd["append"] is not None:
op = "append"
val = "%s %s" % ((self.getFunc(key, data) or ""), groupd["value"])
- elif "prepend" in groupd and groupd["prepend"] != None:
+ elif "prepend" in groupd and groupd["prepend"] is not None:
op = "prepend"
val = "%s %s" % (groupd["value"], (self.getFunc(key, data) or ""))
- elif "postdot" in groupd and groupd["postdot"] != None:
+ elif "postdot" in groupd and groupd["postdot"] is not None:
op = "postdot"
val = "%s%s" % ((self.getFunc(key, data) or ""), groupd["value"])
- elif "predot" in groupd and groupd["predot"] != None:
+ elif "predot" in groupd and groupd["predot"] is not None:
op = "predot"
val = "%s%s" % (groupd["value"], (self.getFunc(key, data) or ""))
else:
val = groupd["value"]
flag = None
- if 'flag' in groupd and groupd['flag'] != None:
+ if 'flag' in groupd and groupd['flag'] is not None:
flag = groupd['flag']
elif groupd["lazyques"]:
flag = "_defaultval"
@@ -178,7 +161,7 @@ class MethodNode(AstNode):
funcname = ("__anon_%s_%s" % (self.lineno, self.filename.translate(MethodNode.tr_tbl)))
self.python = True
text = "def %s(d):\n" % (funcname) + text
- bb.methodpool.insert_method(funcname, text, self.filename, self.lineno - len(self.body))
+ bb.methodpool.insert_method(funcname, text, self.filename, self.lineno - len(self.body) - 1)
anonfuncs = data.getVar('__BBANONFUNCS', False) or []
anonfuncs.append(funcname)
data.setVar('__BBANONFUNCS', anonfuncs)
diff --git a/external/poky/bitbake/lib/bb/parse/parse_py/BBHandler.py b/external/poky/bitbake/lib/bb/parse/parse_py/BBHandler.py
index e5039e3b..6e216eff 100644
--- a/external/poky/bitbake/lib/bb/parse/parse_py/BBHandler.py
+++ b/external/poky/bitbake/lib/bb/parse/parse_py/BBHandler.py
@@ -1,6 +1,3 @@
-#!/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
@@ -12,24 +9,11 @@
# 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.
+# SPDX-License-Identifier: GPL-2.0-only
#
-# 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, os
-import logging
import bb.build, bb.utils
-from bb import data
from . import ConfHandler
from .. import resolve_file, ast, logger, ParseError
@@ -38,14 +22,15 @@ 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))|(.*)))))*")
-__deltask_regexp__ = re.compile("deltask\s+(?P<func>\w+)")
-__addhandler_regexp__ = re.compile( r"addhandler\s+(.+)" )
-__def_regexp__ = re.compile( r"def\s+(\w+).*:" )
-__python_func_regexp__ = re.compile( r"(\s+.*)|(^$)" )
+__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(r"addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*")
+__deltask_regexp__ = re.compile(r"deltask\s+(?P<func>\w+)(?P<ignores>.*)")
+__addhandler_regexp__ = re.compile(r"addhandler\s+(.+)" )
+__def_regexp__ = re.compile(r"def\s+(\w+).*:" )
+__python_func_regexp__ = re.compile(r"(\s+.*)|(^$)|(^#)" )
+__python_tab_regexp__ = re.compile(r" *\t")
__infunc__ = []
__inpython__ = False
@@ -160,6 +145,16 @@ def handle(fn, d, include):
def feeder(lineno, s, fn, root, statements, eof=False):
global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__, __infunc__, __body__, bb, __residue__, __classname__
+
+ # Check tabs in python functions:
+ # - def py_funcname(): covered by __inpython__
+ # - python(): covered by '__anonymous' == __infunc__[0]
+ # - python funcname(): covered by __infunc__[3]
+ if __inpython__ or (__infunc__ and ('__anonymous' == __infunc__[0] or __infunc__[3])):
+ tab = __python_tab_regexp__.match(s)
+ if tab:
+ bb.warn('python should use 4 spaces indentation, but found tabs in %s, line %s' % (root, lineno))
+
if __infunc__:
if s == '}':
__body__.append('')
@@ -225,11 +220,27 @@ def feeder(lineno, s, fn, root, statements, eof=False):
m = __addtask_regexp__.match(s)
if m:
+ if len(m.group().split()) == 2:
+ # Check and warn for "addtask task1 task2"
+ m2 = re.match(r"addtask\s+(?P<func>\w+)(?P<ignores>.*)", s)
+ if m2 and m2.group('ignores'):
+ logger.warning('addtask ignored: "%s"' % m2.group('ignores'))
+
+ # Check and warn for "addtask task1 before task2 before task3", the
+ # similar to "after"
+ taskexpression = s.split()
+ for word in ('before', 'after'):
+ if taskexpression.count(word) > 1:
+ logger.warning("addtask contained multiple '%s' keywords, only one is supported" % word)
+
ast.handleAddTask(statements, fn, lineno, m)
return
m = __deltask_regexp__.match(s)
if m:
+ # Check and warn "for deltask task1 task2"
+ if m.group('ignores'):
+ logger.warning('deltask ignored: "%s"' % m.group('ignores'))
ast.handleDelTask(statements, fn, lineno, m)
return
diff --git a/external/poky/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/external/poky/bitbake/lib/bb/parse/parse_py/ConfHandler.py
index 9d3ebe16..af64d344 100644
--- a/external/poky/bitbake/lib/bb/parse/parse_py/ConfHandler.py
+++ b/external/poky/bitbake/lib/bb/parse/parse_py/ConfHandler.py
@@ -1,6 +1,3 @@
-#!/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
@@ -11,18 +8,8 @@
# 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.
+# SPDX-License-Identifier: GPL-2.0-only
#
-# 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 errno
import re
@@ -132,30 +119,30 @@ def handle(fn, data, include):
oldfile = data.getVar('FILE', False)
abs_fn = resolve_file(fn, data)
- f = open(abs_fn, 'r')
-
- statements = ast.StatementGroup()
- lineno = 0
- while True:
- lineno = lineno + 1
- s = f.readline()
- if not s:
- break
- w = s.strip()
- # skip empty lines
- if not w:
- continue
- s = s.rstrip()
- while s[-1] == '\\':
- s2 = f.readline().strip()
+ with open(abs_fn, 'r') as f:
+
+ statements = ast.StatementGroup()
+ lineno = 0
+ while True:
lineno = lineno + 1
- if (not s2 or s2 and s2[0] != "#") and s[0] == "#" :
- bb.fatal("There is a confusing multiline, partially commented expression on line %s of file %s (%s).\nPlease clarify whether this is all a comment or should be parsed." % (lineno, fn, s))
- s = s[:-1] + s2
- # skip comments
- if s[0] == '#':
- continue
- feeder(lineno, s, abs_fn, statements)
+ s = f.readline()
+ if not s:
+ break
+ w = s.strip()
+ # skip empty lines
+ if not w:
+ continue
+ s = s.rstrip()
+ while s[-1] == '\\':
+ s2 = f.readline().rstrip()
+ lineno = lineno + 1
+ if (not s2 or s2 and s2[0] != "#") and s[0] == "#" :
+ bb.fatal("There is a confusing multiline, partially commented expression on line %s of file %s (%s).\nPlease clarify whether this is all a comment or should be parsed." % (lineno, fn, s))
+ s = s[:-1] + s2
+ # skip comments
+ if s[0] == '#':
+ continue
+ feeder(lineno, s, abs_fn, statements)
# DONE WITH PARSING... time to evaluate
data.setVar('FILE', abs_fn)
diff --git a/external/poky/bitbake/lib/bb/parse/parse_py/__init__.py b/external/poky/bitbake/lib/bb/parse/parse_py/__init__.py
index 3e658d0d..f508afa1 100644
--- a/external/poky/bitbake/lib/bb/parse/parse_py/__init__.py
+++ b/external/poky/bitbake/lib/bb/parse/parse_py/__init__.py
@@ -1,6 +1,3 @@
-#!/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
@@ -11,20 +8,10 @@ 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.
+# SPDX-License-Identifier: GPL-2.0-only
#
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
+#
from __future__ import absolute_import
from . import ConfHandler