summaryrefslogtreecommitdiffstats
path: root/scripts/recipetool
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2014-12-19 11:41:53 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-12-23 10:18:15 +0000
commit5638ca2b9483806d991d93071b259769a5f7ec48 (patch)
treea40d3d01188b8fd800252ca6b29e11690a31e619 /scripts/recipetool
parentf176b0c64f53e27c2a3e93e879405ebea007f9f7 (diff)
downloadpoky-5638ca2b9483806d991d93071b259769a5f7ec48.tar.gz
scripts/recipetool: Add a recipe auto-creation script
Add a more maintainable and flexible script for creating at least the skeleton of a recipe based on an examination of the source tree. Commands can be added and the creation process can be extended through plugins. [YOCTO #6406] (From OE-Core rev: fa07ada1cd0750f9aa6bcc31f8236205edf6b4ed) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/recipetool')
-rwxr-xr-xscripts/recipetool99
1 files changed, 99 insertions, 0 deletions
diff --git a/scripts/recipetool b/scripts/recipetool
new file mode 100755
index 0000000000..70e6b6c877
--- /dev/null
+++ b/scripts/recipetool
@@ -0,0 +1,99 @@
1#!/usr/bin/env python
2
3# Recipe creation tool
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
20import sys
21import os
22import argparse
23import glob
24import logging
25
26scripts_path = os.path.dirname(os.path.realpath(__file__))
27lib_path = scripts_path + '/lib'
28sys.path = sys.path + [lib_path]
29import scriptutils
30logger = scriptutils.logger_create('recipetool')
31
32plugins = []
33
34def tinfoil_init():
35 import bb.tinfoil
36 import logging
37 tinfoil = bb.tinfoil.Tinfoil()
38 tinfoil.prepare(True)
39
40 for plugin in plugins:
41 if hasattr(plugin, 'tinfoil_init'):
42 plugin.tinfoil_init(tinfoil)
43 tinfoil.logger.setLevel(logging.WARNING)
44
45def main():
46
47 if not os.environ.get('BUILDDIR', ''):
48 logger.error("This script can only be run after initialising the build environment (e.g. by using oe-init-build-env)")
49 sys.exit(1)
50
51 parser = argparse.ArgumentParser(description="OpenEmbedded recipe tool",
52 epilog="Use %(prog)s <command> --help to get help on a specific command")
53 parser.add_argument('-d', '--debug', help='Enable debug output', action='store_true')
54 parser.add_argument('-q', '--quiet', help='Print only errors', action='store_true')
55 parser.add_argument('--color', help='Colorize output', choices=['auto', 'always', 'never'], default='auto')
56 subparsers = parser.add_subparsers()
57
58 scriptutils.load_plugins(logger, plugins, os.path.join(scripts_path, 'lib', 'recipetool'))
59 registered = False
60 for plugin in plugins:
61 if hasattr(plugin, 'register_command'):
62 registered = True
63 plugin.register_command(subparsers)
64
65 if not registered:
66 logger.error("No commands registered - missing plugins?")
67 sys.exit(1)
68
69 args = parser.parse_args()
70
71 if args.debug:
72 logger.setLevel(logging.DEBUG)
73 elif args.quiet:
74 logger.setLevel(logging.ERROR)
75
76 import scriptpath
77 bitbakepath = scriptpath.add_bitbake_lib_path()
78 if not bitbakepath:
79 logger.error("Unable to find bitbake by searching parent directory of this script or PATH")
80 sys.exit(1)
81 logger.debug('Found bitbake path: %s' % bitbakepath)
82
83 scriptutils.logger_setup_color(logger, args.color)
84
85 tinfoil_init()
86
87 ret = args.func(args)
88
89 return ret
90
91
92if __name__ == "__main__":
93 try:
94 ret = main()
95 except Exception:
96 ret = 1
97 import traceback
98 traceback.print_exc(5)
99 sys.exit(ret)