* [PATCH v2 1/2] externalsrc.bbclass: Add task buildclean
@ 2017-01-09 16:20 Ola x Nilsson
2017-01-09 16:20 ` [PATCH v2 2/2] oe-selftest: devtool: Add test for externalsrc buildclean Ola x Nilsson
0 siblings, 1 reply; 2+ messages in thread
From: Ola x Nilsson @ 2017-01-09 16:20 UTC (permalink / raw)
To: openembedded-core
The buildclean task should call the package build system clean
command, just implemented for Make for now.
This is meant for recipes where S == B, but can be useful as a
standalone task for other recipes too.
When S == B, set it to run before do_clean which will do what most
developers expect when calling bitbake -c clean. For S != B, do not
add it before clean as it is not needed and may take some time.
Signed-off-by: Ola x Nilsson <olani@axis.com>
---
meta/classes/externalsrc.bbclass | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass
index e115a47..8acd10d 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -108,6 +108,10 @@ python () {
# We don't want the workdir to go away
d.appendVar('RM_WORK_EXCLUDE', ' ' + d.getVar('PN'))
+ bb.build.addtask('do_buildclean',
+ 'do_clean' if d.getVar('S') == d.getVar('B') else None,
+ None, d)
+
# If B=S the same builddir is used even for different architectures.
# Thus, use a shared CONFIGURESTAMPFILE and STAMP directory so that
# change of do_configure task hash is correctly detected and stamps are
@@ -142,6 +146,17 @@ python externalsrc_compile_prefunc() {
bb.plain('NOTE: %s: compiling from external source tree %s' % (d.getVar('PN'), d.getVar('EXTERNALSRC')))
}
+do_buildclean[dirs] = "${S} ${B}"
+do_buildclean[nostamp] = "1"
+do_buildclean[doc] = "Call 'make clean' or equivalent in ${B}"
+externalsrc_do_buildclean() {
+ if [ -e Makefile -o -e makefile -o -e GNUmakefile ]; then
+ oe_runmake clean || die "make failed"
+ else
+ bbnote "nothing to do - no makefile found"
+ fi
+}
+
def srctree_hash_files(d):
import shutil
import subprocess
@@ -188,3 +203,5 @@ def srctree_configure_hash_files(d):
if f in search_files:
out_items.append('%s:True' % os.path.join(root, f))
return ' '.join(out_items)
+
+EXPORT_FUNCTIONS do_buildclean
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH v2 2/2] oe-selftest: devtool: Add test for externalsrc buildclean
2017-01-09 16:20 [PATCH v2 1/2] externalsrc.bbclass: Add task buildclean Ola x Nilsson
@ 2017-01-09 16:20 ` Ola x Nilsson
0 siblings, 0 replies; 2+ messages in thread
From: Ola x Nilsson @ 2017-01-09 16:20 UTC (permalink / raw)
To: openembedded-core
Signed-off-by: Ola x Nilsson <olani@axis.com>
---
meta/lib/oeqa/selftest/devtool.py | 46 +++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index 19c5ccf..c37d194 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -469,6 +469,52 @@ class DevtoolTests(DevtoolBase):
matches = glob.glob(stampprefix + '*')
self.assertFalse(matches, 'Stamp files exist for recipe mdadm that should have been cleaned')
+ def test_devtool_buildclean(self):
+ def assertFile(path, *paths):
+ f = os.path.join(path, *paths)
+ self.assertTrue(os.path.exists(f), "%r does not exist" % f)
+ def assertNoFile(path, *paths):
+ f = os.path.join(path, *paths)
+ self.assertFalse(os.path.exists(os.path.join(f)), "%r exists" % f)
+
+ # Clean up anything in the workdir/sysroot/sstate cache
+ bitbake('mdadm m4 -c cleansstate')
+ # Try modifying a recipe
+ tempdir_mdadm = tempfile.mkdtemp(prefix='devtoolqa')
+ tempdir_m4 = tempfile.mkdtemp(prefix='devtoolqa')
+ builddir_m4 = tempfile.mkdtemp(prefix='devtoolqa')
+ self.track_for_cleanup(tempdir_mdadm)
+ self.track_for_cleanup(tempdir_m4)
+ #self.track_for_cleanup(builddir_m4)
+ self.track_for_cleanup(self.workspacedir)
+ self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+ self.add_command_to_tearDown('bitbake -c clean mdadm m4')
+ self.write_recipeinc('m4', 'EXTERNALSRC_BUILD = "%s"\ndo_clean() {\n\t:\n}\n' % builddir_m4)
+ try:
+ runCmd('devtool modify mdadm -x %s' % tempdir_mdadm)
+ runCmd('devtool modify m4 -x %s' % tempdir_m4)
+ assertNoFile(tempdir_mdadm, 'mdadm')
+ assertNoFile(builddir_m4, 'src/m4')
+ result = bitbake('m4 -e')
+ result = bitbake('mdadm m4 -c compile')
+ self.assertEqual(result.status, 0)
+ assertFile(tempdir_mdadm, 'mdadm')
+ assertFile(builddir_m4, 'src/m4')
+ # Check that buildclean task exists and does call make clean
+ bitbake('mdadm m4 -c buildclean')
+ assertNoFile(tempdir_mdadm, 'mdadm')
+ assertNoFile(builddir_m4, 'src/m4')
+ bitbake('mdadm m4 -c compile')
+ assertFile(tempdir_mdadm, 'mdadm')
+ assertFile(builddir_m4, 'src/m4')
+ bitbake('mdadm m4 -c clean')
+ # Check that buildclean task is run before clean for B == S
+ assertNoFile(tempdir_mdadm, 'mdadm')
+ # Check that buildclean task is not run before clean for B != S
+ assertFile(builddir_m4, 'src/m4')
+ finally:
+ self.delete_recipeinc('m4')
+
@testcase(1166)
def test_devtool_modify_invalid(self):
# Try modifying some recipes
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-09 16:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-09 16:20 [PATCH v2 1/2] externalsrc.bbclass: Add task buildclean Ola x Nilsson
2017-01-09 16:20 ` [PATCH v2 2/2] oe-selftest: devtool: Add test for externalsrc buildclean Ola x Nilsson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox