Skip to contentSkip to conversation

Fixes for addtask and deltask

PATCH New Robert Yang 1 participant 4 messages Apr 29, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover Fixes for addtask and deltask

* V2:
- Fix RP's comments on V1
- Add testcase for addtask and deltask

* V1:
- Initial version

The following changes since commit 244cbcce0ecc4691a9ddfb0a44dc487ff7af0670:

utils/multiprocess_launch: Improve failing subprocess output (2019-04-26 10:09:08 +0100)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib rbt/addtask
http://git.pokylinux.org/cgit.cgi//log/?h=rbt/addtask

Robert Yang (3):
bitbake: BBHandler: Fix addtask and deltask
bitbake: build.py: check dependendent task for addtask
bitbake: tests/parse.py: Add testcase for addtask and deltask

 bitbake/lib/bb/build.py                    |  3 +++
 bitbake/lib/bb/parse/parse_py/BBHandler.py | 18 +++++++++++++++++-
 bitbake/lib/bb/tests/parse.py              | 18 ++++++++++++++++++
 3 files changed, 38 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/3 bitbake: BBHandler: Fix addtask and deltask

The following commands are not supported, but they were ignored silently, that may suprise users:

* addtask task1 task2
task2 is ignored

* addtask task1 before task2 before task3
Should be: addtask task1 before task2 task3

* addtask task1 after task2 after task3
Should be: addtask task1 after task2 task3

* deltask task1 task2
task2 is ignore

This patch can check and warn for them.

[YOCTO #13282]

---
 bitbake/lib/bb/parse/parse_py/BBHandler.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
bitbake/lib/bb/parse/parse_py/BBHandler.py +17 -1
index 9dba5f2..314e802 100644
@@ -42,7 +42,7 @@ __func_start_regexp__    = re.compile(r"(((?P<py>python)|(?P<fr>fakeroot))\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+)")
+__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+.*)|(^$)|(^#)" )
@@ -236,11 +236,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
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 2/3 bitbake: build.py: check dependendent task for addtask

In reply to Robert Yang

The following command is incorrect, but was ignored silently, that may suprise users:

addtask task after task_not_existed

This patch can check and warn for it. It would be better to also check "before" tasks, but there is no easier way to do it.

[YOCTO #13282]

---
 bitbake/lib/bb/build.py | 3 +++
 1 file changed, 3 insertions(+)
bitbake/lib/bb/build.py +3 -0
index 7571421..a83de8d 100644
@@ -815,6 +815,9 @@ def add_tasks(tasklist, d):
         task_deps['parents'][task] = []
         if 'deps' in flags:
             for dep in flags['deps']:
+                # Check and warn for "addtask task after foo" while foo does not exist
+                if not dep in tasklist:
+                    bb.warn('%s: dependent task %s does not exist' % (d.getVar('PN'), dep))
                 dep = d.expand(dep)
                 task_deps['parents'][task].append(dep)
 
Signature · 1 line
2.7.4
#3 lore raw

PATCH v2 3/3 bitbake: tests/parse.py: Add testcase for addtask and deltask

In reply to Robert Yang
---
 bitbake/lib/bb/tests/parse.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
bitbake/lib/bb/tests/parse.py +18 -0
index 1bc4740..4467d17 100644
@@ -187,3 +187,21 @@ python () {
         self.assertEqual(d1.getVar("VAR_var"), "B")
         self.assertEqual(d2.getVar("VAR_var"), None)
 
+    addtask_deltask = """
+addtask do_patch after do_foo after do_unpack before do_configure before do_compile
+addtask do_fetch do_patch
+
+deltask do_fetch do_patch
+"""
+    def test_parse_addtask_deltask(self):
+        import sys
+        f = self.parsehelper(self.addtask_deltask)
+        d = bb.parse.handle(f.name, self.d)['']
+
+        stdout = sys.stdout.getvalue()
+        self.assertTrue("addtask contained multiple 'before' keywords" in stdout)
+        self.assertTrue("addtask contained multiple 'after' keywords" in stdout)
+        self.assertTrue('addtask ignored: " do_patch"' in stdout)
+        self.assertTrue('deltask ignored: " do_patch"' in stdout)
+        self.assertTrue('dependent task do_foo does not exist' in stdout)
+
Signature · 1 line
2.7.4