summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2012-09-10 21:50:34 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-09-10 21:50:41 +0100
commitfb44773f61795a7f3f9aaefe5e84a5d275aac771 (patch)
treec092fc35bbaf4a40b17ab7b8558df3ccdad30123 /bitbake
parent440fba4db701952e968dec3e0f31ba989a7ddfc3 (diff)
downloadpoky-fb44773f61795a7f3f9aaefe5e84a5d275aac771.tar.gz
bitbake: tinfoil: Add file inadvertently not committed
(Bitbake rev: 44a3fb49e817be641090d5d1bce7b586af407d71) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/tinfoil.py98
1 files changed, 98 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py
new file mode 100644
index 0000000000..73d8fe92a8
--- /dev/null
+++ b/bitbake/lib/bb/tinfoil.py
@@ -0,0 +1,98 @@
1# tinfoil: a simple wrapper around cooker for bitbake-based command-line utilities
2#
3# Copyright (C) 2012 Intel Corporation
4# Copyright (C) 2011 Mentor Graphics Corporation
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 2 as
8# published by the Free Software Foundation.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19import logging
20import warnings
21import os
22import sys
23
24import bb.cache
25import bb.cooker
26import bb.providers
27import bb.utils
28from bb.cooker import state
29import bb.fetch2
30
31class Tinfoil:
32 def __init__(self):
33 # Needed to avoid deprecation warnings with python 2.6
34 warnings.filterwarnings("ignore", category=DeprecationWarning)
35
36 # Set up logging
37 self.logger = logging.getLogger('BitBake')
38 console = logging.StreamHandler(sys.stdout)
39 format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
40 bb.msg.addDefaultlogFilter(console)
41 console.setFormatter(format)
42 self.logger.addHandler(console)
43
44 initialenv = os.environ.copy()
45 bb.utils.clean_environment()
46 self.config = TinfoilConfig(parse_only=True)
47 self.cooker = bb.cooker.BBCooker(self.config,
48 self.register_idle_function,
49 initialenv)
50 self.config_data = self.cooker.configuration.data
51 bb.providers.logger.setLevel(logging.ERROR)
52 self.cooker_data = None
53
54 def register_idle_function(self, function, data):
55 pass
56
57 def parseRecipes(self):
58 sys.stderr.write("Parsing recipes..")
59 self.logger.setLevel(logging.WARNING)
60
61 try:
62 while self.cooker.state in (state.initial, state.parsing):
63 self.cooker.updateCache()
64 except KeyboardInterrupt:
65 self.cooker.shutdown()
66 self.cooker.updateCache()
67 sys.exit(2)
68
69 self.logger.setLevel(logging.INFO)
70 sys.stderr.write("done.\n")
71
72 self.cooker_data = self.cooker.status
73
74 def prepare(self, config_only = False):
75 if not self.cooker_data:
76 if config_only:
77 self.cooker.parseConfiguration()
78 self.cooker_data = self.cooker.status
79 else:
80 self.parseRecipes()
81
82
83class TinfoilConfig(object):
84 def __init__(self, **options):
85 self.pkgs_to_build = []
86 self.debug_domains = []
87 self.extra_assume_provided = []
88 self.prefile = []
89 self.postfile = []
90 self.debug = 0
91 self.__dict__.update(options)
92
93 def __getattr__(self, attribute):
94 try:
95 return super(TinfoilConfig, self).__getattribute__(attribute)
96 except AttributeError:
97 return None
98