summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/__init__.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2014-12-19 11:41:55 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-12-23 10:18:16 +0000
commitcd5ca4a11daff2089ba3031103b9b9dab5b3c94e (patch)
tree2c80f6f2c4a07ce9d88b47c17ca7a424665e2283 /scripts/lib/devtool/__init__.py
parentb7d53f2ebb3219e205ab6b368f7f41b57a5cf89a (diff)
downloadpoky-cd5ca4a11daff2089ba3031103b9b9dab5b3c94e.tar.gz
scripts/devtool: add development helper tool
Provides an easy means to work on developing applications and system components with the build system. For example to "modify" the source for an existing recipe: $ devtool modify -x pango /home/projects/pango Parsing recipes..done. NOTE: Fetching pango... NOTE: Unpacking... NOTE: Patching... NOTE: Source tree extracted to /home/projects/pango NOTE: Recipe pango now set up to build from /home/paul/projects/pango The pango source is now extracted to /home/paul/projects/pango, managed in git, with each patch as a commit, and a bbappend is created in the workspace layer to use the source in /home/paul/projects/pango when building. Additionally, you can add a new piece of software: $ devtool add pv /home/projects/pv NOTE: Recipe /path/to/workspace/recipes/pv/pv.bb has been automatically created; further editing may be required to make it fully functional The latter uses recipetool to create a skeleton recipe and again sets up a bbappend to use the source in /home/projects/pv when building. Having done a "devtool modify", can also write any changes to the external git repository back as patches next to the recipe: $ devtool update-recipe mdadm Parsing recipes..done. NOTE: Removing patch mdadm-3.2.2_fix_for_x32.patch NOTE: Removing patch gcc-4.9.patch NOTE: Updating recipe mdadm_3.3.1.bb [YOCTO #6561] [YOCTO #6653] [YOCTO #6656] (From OE-Core rev: 716d9b1f304a12bab61b15e3ce526977c055f074) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool/__init__.py')
-rw-r--r--scripts/lib/devtool/__init__.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py
new file mode 100644
index 0000000000..3f8158e24a
--- /dev/null
+++ b/scripts/lib/devtool/__init__.py
@@ -0,0 +1,78 @@
1#!/usr/bin/env python
2
3# Development tool - utility functions for plugins
4#
5# Copyright (C) 2014 Intel Corporation
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 2 as
9# published by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
21import os
22import sys
23import subprocess
24import logging
25
26logger = logging.getLogger('devtool')
27
28def exec_build_env_command(init_path, builddir, cmd, watch=False, **options):
29 import bb
30 if not 'cwd' in options:
31 options["cwd"] = builddir
32 if init_path:
33 logger.debug('Executing command: "%s" using init path %s' % (cmd, init_path))
34 init_prefix = '. %s %s > /dev/null && ' % (init_path, builddir)
35 else:
36 logger.debug('Executing command "%s"' % cmd)
37 init_prefix = ''
38 if watch:
39 if sys.stdout.isatty():
40 # Fool bitbake into thinking it's outputting to a terminal (because it is, indirectly)
41 cmd = 'script -q -c "%s" /dev/null' % cmd
42 return exec_watch('%s%s' % (init_prefix, cmd), **options)
43 else:
44 return bb.process.run('%s%s' % (init_prefix, cmd), **options)
45
46def exec_watch(cmd, **options):
47 if isinstance(cmd, basestring) and not "shell" in options:
48 options["shell"] = True
49
50 process = subprocess.Popen(
51 cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **options
52 )
53
54 buf = ''
55 while True:
56 out = process.stdout.read(1)
57 if out:
58 sys.stdout.write(out)
59 sys.stdout.flush()
60 buf += out
61 elif out == '' and process.poll() != None:
62 break
63 return buf
64
65def setup_tinfoil():
66 import scriptpath
67 bitbakepath = scriptpath.add_bitbake_lib_path()
68 if not bitbakepath:
69 logger.error("Unable to find bitbake by searching parent directory of this script or PATH")
70 sys.exit(1)
71
72 import bb.tinfoil
73 import logging
74 tinfoil = bb.tinfoil.Tinfoil()
75 tinfoil.prepare(False)
76 tinfoil.logger.setLevel(logging.WARNING)
77 return tinfoil
78