aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/tinfoil.py
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:34 +0100
commit44a3fb49e817be641090d5d1bce7b586af407d71 (patch)
tree57abf1c04d44be1e6ffd39ac7c485ec9cc4d24ef /lib/bb/tinfoil.py
parent675b237a284dff84e972546774b69e2f89afb360 (diff)
downloadbitbake-contrib-44a3fb49e817be641090d5d1bce7b586af407d71.tar.gz
tinfoil: Add file inadvertently not committed
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/tinfoil.py')
-rw-r--r--lib/bb/tinfoil.py98
1 files changed, 98 insertions, 0 deletions
diff --git a/lib/bb/tinfoil.py b/lib/bb/tinfoil.py
new file mode 100644
index 000000000..73d8fe92a
--- /dev/null
+++ b/lib/bb/tinfoil.py
@@ -0,0 +1,98 @@
+# tinfoil: a simple wrapper around cooker for bitbake-based command-line utilities
+#
+# Copyright (C) 2012 Intel Corporation
+# Copyright (C) 2011 Mentor Graphics Corporation
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+import logging
+import warnings
+import os
+import sys
+
+import bb.cache
+import bb.cooker
+import bb.providers
+import bb.utils
+from bb.cooker import state
+import bb.fetch2
+
+class Tinfoil:
+ def __init__(self):
+ # Needed to avoid deprecation warnings with python 2.6
+ warnings.filterwarnings("ignore", category=DeprecationWarning)
+
+ # Set up logging
+ self.logger = logging.getLogger('BitBake')
+ console = logging.StreamHandler(sys.stdout)
+ format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
+ bb.msg.addDefaultlogFilter(console)
+ console.setFormatter(format)
+ self.logger.addHandler(console)
+
+ initialenv = os.environ.copy()
+ bb.utils.clean_environment()
+ self.config = TinfoilConfig(parse_only=True)
+ self.cooker = bb.cooker.BBCooker(self.config,
+ self.register_idle_function,
+ initialenv)
+ self.config_data = self.cooker.configuration.data
+ bb.providers.logger.setLevel(logging.ERROR)
+ self.cooker_data = None
+
+ def register_idle_function(self, function, data):
+ pass
+
+ def parseRecipes(self):
+ sys.stderr.write("Parsing recipes..")
+ self.logger.setLevel(logging.WARNING)
+
+ try:
+ while self.cooker.state in (state.initial, state.parsing):
+ self.cooker.updateCache()
+ except KeyboardInterrupt:
+ self.cooker.shutdown()
+ self.cooker.updateCache()
+ sys.exit(2)
+
+ self.logger.setLevel(logging.INFO)
+ sys.stderr.write("done.\n")
+
+ self.cooker_data = self.cooker.status
+
+ def prepare(self, config_only = False):
+ if not self.cooker_data:
+ if config_only:
+ self.cooker.parseConfiguration()
+ self.cooker_data = self.cooker.status
+ else:
+ self.parseRecipes()
+
+
+class TinfoilConfig(object):
+ def __init__(self, **options):
+ self.pkgs_to_build = []
+ self.debug_domains = []
+ self.extra_assume_provided = []
+ self.prefile = []
+ self.postfile = []
+ self.debug = 0
+ self.__dict__.update(options)
+
+ def __getattr__(self, attribute):
+ try:
+ return super(TinfoilConfig, self).__getattribute__(attribute)
+ except AttributeError:
+ return None
+