diff options
author | Khem Raj <raj.khem@gmail.com> | 2011-02-23 10:48:51 -0800 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2011-02-23 10:48:51 -0800 |
commit | 951cbf3f65f347c7a7bbcae193218f9187a15fbf (patch) | |
tree | 96e9c74551e6931804992f8f49af05f732eb0fff /bitbake/bin | |
parent | adbaae2179a6c3746e53f7fbb2ca0939e85a7ea9 (diff) | |
download | openembedded-core-951cbf3f65f347c7a7bbcae193218f9187a15fbf.tar.gz openembedded-core-951cbf3f65f347c7a7bbcae193218f9187a15fbf.tar.bz2 openembedded-core-951cbf3f65f347c7a7bbcae193218f9187a15fbf.zip |
bitbake: Remove in-tree version
Bitbake should be used by checking it out from its own repo
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-x | bitbake/bin/bitbake | 224 | ||||
-rwxr-xr-x | bitbake/bin/bitbake-diffsigs | 12 | ||||
-rw-r--r-- | bitbake/bin/bitbake-layers | 154 | ||||
-rwxr-xr-x | bitbake/bin/bitbake-runtask | 120 | ||||
-rwxr-xr-x | bitbake/bin/bitdoc | 532 |
5 files changed, 0 insertions, 1042 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake deleted file mode 100755 index 6d0528953c..0000000000 --- a/bitbake/bin/bitbake +++ /dev/null @@ -1,224 +0,0 @@ -#!/usr/bin/env python -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -# -# Copyright (C) 2003, 2004 Chris Larson -# Copyright (C) 2003, 2004 Phil Blundell -# Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer -# Copyright (C) 2005 Holger Hans Peter Freyther -# Copyright (C) 2005 ROAD GmbH -# Copyright (C) 2006 Richard Purdie -# -# 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 os -import sys, logging -sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), - 'lib')) - -import optparse -import warnings -from traceback import format_exception -try: - import bb -except RuntimeError, exc: - sys.exit(str(exc)) -from bb import event -import bb.msg -from bb import cooker -from bb import ui -from bb import server -from bb.server import none -#from bb.server import xmlrpc - -__version__ = "1.11.0" -logger = logging.getLogger("BitBake") - - -class BBConfiguration(object): - """ - Manages build options and configurations for one run - """ - - def __init__(self, options): - for key, val in options.__dict__.items(): - setattr(self, key, val) - self.pkgs_to_build = [] - - -def get_ui(config): - if config.ui: - interface = config.ui - else: - interface = 'knotty' - - try: - # Dynamically load the UI based on the ui name. Although we - # suggest a fixed set this allows you to have flexibility in which - # ones are available. - module = __import__("bb.ui", fromlist = [interface]) - return getattr(module, interface).main - except AttributeError: - sys.exit("FATAL: Invalid user interface '%s' specified.\n" - "Valid interfaces: depexp, goggle, ncurses, knotty [default]." % interface) - - -# Display bitbake/OE warnings via the BitBake.Warnings logger, ignoring others""" -warnlog = logging.getLogger("BitBake.Warnings") -_warnings_showwarning = warnings.showwarning -def _showwarning(message, category, filename, lineno, file=None, line=None): - if file is not None: - if _warnings_showwarning is not None: - _warnings_showwarning(message, category, filename, lineno, file, line) - else: - s = warnings.formatwarning(message, category, filename, lineno) - warnlog.warn(s) - -warnings.showwarning = _showwarning -warnings.filterwarnings("ignore") -warnings.filterwarnings("default", module="(<string>$|(oe|bb)\.)") -warnings.filterwarnings("ignore", category=PendingDeprecationWarning) -warnings.filterwarnings("ignore", category=ImportWarning) -warnings.filterwarnings("ignore", category=DeprecationWarning, module="<string>$") -warnings.filterwarnings("ignore", message="With-statements now directly support multiple context managers") - - -def main(): - parser = optparse.OptionParser( - version = "BitBake Build Tool Core version %s, %%prog version %s" % (bb.__version__, __version__), - usage = """%prog [options] [package ...] - -Executes the specified task (default is 'build') for a given set of BitBake files. -It expects that BBFILES is defined, which is a space separated list of files to -be executed. BBFILES does support wildcards. -Default BBFILES are the .bb files in the current directory.""") - - parser.add_option("-b", "--buildfile", help = "execute the task against this .bb file, rather than a package from BBFILES.", - action = "store", dest = "buildfile", default = None) - - parser.add_option("-k", "--continue", help = "continue as much as possible after an error. While the target that failed, and those that depend on it, cannot be remade, the other dependencies of these targets can be processed all the same.", - action = "store_false", dest = "abort", default = True) - - parser.add_option("-a", "--tryaltconfigs", help = "continue with builds by trying to use alternative providers where possible.", - action = "store_true", dest = "tryaltconfigs", default = False) - - parser.add_option("-f", "--force", help = "force run of specified cmd, regardless of stamp status", - action = "store_true", dest = "force", default = False) - - parser.add_option("-c", "--cmd", help = "Specify task to execute. Note that this only executes the specified task for the providee and the packages it depends on, i.e. 'compile' does not implicitly call stage for the dependencies (IOW: use only if you know what you are doing). Depending on the base.bbclass a listtasks tasks is defined and will show available tasks", - action = "store", dest = "cmd") - - parser.add_option("-r", "--read", help = "read the specified file before bitbake.conf", - action = "append", dest = "file", default = []) - - parser.add_option("-v", "--verbose", help = "output more chit-chat to the terminal", - action = "store_true", dest = "verbose", default = False) - - parser.add_option("-D", "--debug", help = "Increase the debug level. You can specify this more than once.", - action = "count", dest="debug", default = 0) - - parser.add_option("-n", "--dry-run", help = "don't execute, just go through the motions", - action = "store_true", dest = "dry_run", default = False) - - parser.add_option("-S", "--dump-signatures", help = "don't execute, just dump out the signature construction information", - action = "store_true", dest = "dump_signatures", default = False) - - parser.add_option("-p", "--parse-only", help = "quit after parsing the BB files (developers only)", - action = "store_true", dest = "parse_only", default = False) - - parser.add_option("-d", "--disable-psyco", help = "disable using the psyco just-in-time compiler (not recommended)", - action = "store_true", dest = "disable_psyco", default = False) - - parser.add_option("-s", "--show-versions", help = "show current and preferred versions of all packages", - action = "store_true", dest = "show_versions", default = False) - - parser.add_option("-e", "--environment", help = "show the global or per-package environment (this is what used to be bbread)", - action = "store_true", dest = "show_environment", default = False) - - parser.add_option("-g", "--graphviz", help = "emit the dependency trees of the specified packages in the dot syntax", - action = "store_true", dest = "dot_graph", default = False) - - parser.add_option("-I", "--ignore-deps", help = """Assume these dependencies don't exist and are already provided (equivalent to ASSUME_PROVIDED). Useful to make dependency graphs more appealing""", - action = "append", dest = "extra_assume_provided", default = []) - - parser.add_option("-l", "--log-domains", help = """Show debug logging for the specified logging domains""", - action = "append", dest = "debug_domains", default = []) - - parser.add_option("-P", "--profile", help = "profile the command and print a report", - action = "store_true", dest = "profile", default = False) - - parser.add_option("-u", "--ui", help = "userinterface to use", - action = "store", dest = "ui") - - parser.add_option("", "--revisions-changed", help = "Set the exit code depending on whether upstream floating revisions have changed or not", - action = "store_true", dest = "revisions_changed", default = False) - - options, args = parser.parse_args(sys.argv) - - configuration = BBConfiguration(options) - configuration.pkgs_to_build.extend(args[1:]) - configuration.initial_path = os.environ['PATH'] - - ui_main = get_ui(configuration) - - loghandler = event.LogHandler() - logger.addHandler(loghandler) - - #server = bb.server.xmlrpc - server = bb.server.none - - # Save a logfile for cooker into the current working directory. When the - # server is daemonized this logfile will be truncated. - cooker_logfile = os.path.join(os.getcwd(), "cooker.log") - - bb.utils.init_logger(bb.msg, configuration.verbose, configuration.debug, - configuration.debug_domains) - - # Clear away any spurious environment variables. But don't wipe the - # environment totally. This is necessary to ensure the correct operation - # of the UIs (e.g. for DISPLAY, etc.) - bb.utils.clean_environment() - - cooker = bb.cooker.BBCooker(configuration, server) - cooker.parseCommandLine() - - serverinfo = server.BitbakeServerInfo(cooker.server) - - server.BitBakeServerFork(cooker, cooker.server, serverinfo, cooker_logfile) - del cooker - - logger.removeHandler(loghandler) - - # Setup a connection to the server (cooker) - server_connection = server.BitBakeServerConnection(serverinfo) - - # Launch the UI - if configuration.ui: - ui = configuration.ui - else: - ui = "knotty" - - try: - return server.BitbakeUILauch().launch(serverinfo, ui_main, server_connection.connection, server_connection.events) - finally: - server_connection.terminate() - -if __name__ == "__main__": - try: - ret = main() - except Exception: - ret = 1 - import traceback - traceback.print_exc(5) - sys.exit(ret) diff --git a/bitbake/bin/bitbake-diffsigs b/bitbake/bin/bitbake-diffsigs deleted file mode 100755 index 5eb77ce59d..0000000000 --- a/bitbake/bin/bitbake-diffsigs +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python -import os -import sys -import warnings -sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) - -import bb.siggen - -if len(sys.argv) > 2: - bb.siggen.compare_sigfiles(sys.argv[1], sys.argv[2]) -else: - bb.siggen.dump_sigfile(sys.argv[1]) diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers deleted file mode 100644 index ed11e5a386..0000000000 --- a/bitbake/bin/bitbake-layers +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/env python2.6 - -import cmd -import logging -import os.path -import sys - -bindir = os.path.dirname(__file__) -topdir = os.path.dirname(bindir) -sys.path[0:0] = [os.path.join(topdir, 'lib')] - -import bb.cache -import bb.cooker -import bb.providers -from bb.cooker import state - - -logger = logging.getLogger('BitBake') -default_cmd = 'show_appends' - - -def main(args): - logging.basicConfig(format='%(levelname)s: %(message)s') - bb.utils.clean_environment() - - cmds = Commands() - if args: - cmds.onecmd(' '.join(args)) - else: - cmds.onecmd(default_cmd) - return cmds.returncode - - -class Commands(cmd.Cmd): - def __init__(self): - cmd.Cmd.__init__(self) - - self.returncode = 0 - self.config = Config(parse_only=True) - self.cooker = bb.cooker.BBCooker(self.config, - self.register_idle_function) - self.config_data = self.cooker.configuration.data - bb.providers.logger.setLevel(logging.ERROR) - self.prepare_cooker() - - def register_idle_function(self, function, data): - pass - - def prepare_cooker(self): - sys.stderr.write("Parsing recipes..") - logger.setLevel(logging.ERROR) - - try: - while self.cooker.state in (state.initial, state.parsing): - self.cooker.updateCache() - except KeyboardInterrupt: - self.cooker.shutdown() - self.cooker.updateCache() - sys.exit(2) - - logger.setLevel(logging.INFO) - sys.stderr.write("done.\n") - - self.cooker_data = self.cooker.status - self.cooker_data.appends = self.cooker.appendlist - - def do_show_layers(self, args): - logger.info(str(self.config_data.getVar('BBLAYERS', True))) - - def do_show_appends(self, args): - if not self.cooker_data.appends: - logger.info('No append files found') - return - - logger.info('State of append files:') - - for pn in self.cooker_data.pkg_pn: - self.show_appends_for_pn(pn) - - self.show_appends_with_no_recipes() - - def show_appends_for_pn(self, pn): - filenames = self.cooker_data.pkg_pn[pn] - - best = bb.providers.findBestProvider(pn, - self.cooker.configuration.data, - self.cooker_data, - self.cooker_data.pkg_pn) - best_filename = os.path.basename(best[3]) - - appended, missing = self.get_appends_for_files(filenames) - if appended: - for basename, appends in appended: - logger.info('%s:', basename) - for append in appends: - logger.info(' %s', append) - - if best_filename in missing: - logger.warn('%s: missing append for preferred version', - best_filename) - self.returncode |= 1 - - def get_appends_for_files(self, filenames): - appended, notappended = set(), set() - for filename in filenames: - _, cls = bb.cache.Cache.virtualfn2realfn(filename) - if cls: - continue - - basename = os.path.basename(filename) - appends = self.cooker_data.appends.get(basename) - if appends: - appended.add((basename, frozenset(appends))) - else: - notappended.add(basename) - return appended, notappended - - def show_appends_with_no_recipes(self): - recipes = set(os.path.basename(f) - for f in self.cooker_data.pkg_fn.iterkeys()) - appended_recipes = self.cooker_data.appends.iterkeys() - appends_without_recipes = [self.cooker_data.appends[recipe] - for recipe in appended_recipes - if recipe not in recipes] - if appends_without_recipes: - appendlines = (' %s' % append - for appends in appends_without_recipes - for append in appends) - logger.warn('No recipes available for:\n%s', - '\n'.join(appendlines)) - self.returncode |= 4 - - def do_EOF(self, line): - return True - - -class Config(object): - def __init__(self, **options): - self.pkgs_to_build = [] - self.debug_domains = [] - self.extra_assume_provided = [] - self.file = [] - self.debug = 0 - self.__dict__.update(options) - - def __getattr__(self, attribute): - try: - return super(Config, self).__getattribute__(attribute) - except AttributeError: - return None - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:]) or 0) diff --git a/bitbake/bin/bitbake-runtask b/bitbake/bin/bitbake-runtask deleted file mode 100755 index bee0f429ff..0000000000 --- a/bitbake/bin/bitbake-runtask +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env python - -import os -import sys -import warnings -sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) - -try: - import cPickle as pickle -except ImportError: - import pickle - bb.msg.note(1, bb.msg.domain.Cache, "Importing cPickle failed. Falling back to a very slow implementation.") - -class BBConfiguration(object): - """ - Manages build options and configurations for one run - """ - - def __init__(self, debug, debug_domains): - setattr(self, "data", {}) - setattr(self, "file", []) - setattr(self, "cmd", None) - setattr(self, "dump_signatures", True) - setattr(self, "debug", debug) - setattr(self, "debug_domains", debug_domains) - -_warnings_showwarning = warnings.showwarning -def _showwarning(message, category, filename, lineno, file=None, line=None): - """Display python warning messages using bb.msg""" - if file is not None: - if _warnings_showwarning is not None: - _warnings_showwarning(message, category, filename, lineno, file, line) - else: - s = warnings.formatwarning(message, category, filename, lineno) - s = s.split("\n")[0] - bb.msg.warn(None, s) - -warnings.showwarning = _showwarning -warnings.simplefilter("ignore", DeprecationWarning) - -import bb.event - -# Need to map our I/O correctly. stdout is a pipe to the server expecting -# events. We save this and then map stdout to stderr. - -eventfd = os.dup(sys.stdout.fileno()) -bb.event.worker_pipe = os.fdopen(eventfd, 'w', 0) - -# map stdout to stderr -os.dup2(sys.stderr.fileno(), sys.stdout.fileno()) - -# Replace those fds with our own -#logout = data.expand("${TMPDIR}/log/stdout.%s" % os.getpid(), self.cfgData, True) -#mkdirhier(os.path.dirname(logout)) -#newso = open("/tmp/stdout.%s" % os.getpid(), 'w') -#os.dup2(newso.fileno(), sys.stdout.fileno()) -#os.dup2(newso.fileno(), sys.stderr.fileno()) - -# Don't read from stdin from the parent -si = file("/dev/null", 'r') -os.dup2(si.fileno( ), sys.stdin.fileno( )) - -# We don't want to see signals to our parent, e.g. Ctrl+C -os.setpgrp() - -# Save out the PID so that the event can include it the -# events -bb.event.worker_pid = os.getpid() -bb.event.useStdout = False - -hashfile = sys.argv[1] -buildfile = sys.argv[2] -taskname = sys.argv[3] - -import bb.cooker - -p = pickle.Unpickler(file(hashfile, "rb")) -hashdata = p.load() - -debug = hashdata["msg-debug"] -debug_domains = hashdata["msg-debug-domains"] -verbose = hashdata["verbose"] - -bb.utils.init_logger(bb.msg, verbose, debug, debug_domains) - -cooker = bb.cooker.BBCooker(BBConfiguration(debug, debug_domains), None) -cooker.parseConfiguration() - -cooker.bb_cache = bb.cache.init(cooker) -cooker.status = bb.cache.CacheData() - -(fn, cls) = cooker.bb_cache.virtualfn2realfn(buildfile) -buildfile = cooker.matchFile(fn) -fn = cooker.bb_cache.realfn2virtual(buildfile, cls) - -cooker.buildSetVars() - -# Load data into the cache for fn and parse the loaded cache data -the_data = cooker.bb_cache.loadDataFull(fn, cooker.get_file_appends(fn), cooker.configuration.data) -cooker.bb_cache.setData(fn, buildfile, the_data) -cooker.bb_cache.handle_data(fn, cooker.status) - -#exportlist = bb.utils.preserved_envvars_export_list() -#bb.utils.filter_environment(exportlist) - -if taskname.endswith("_setscene"): - the_data.setVarFlag(taskname, "quieterrors", "1") - -bb.parse.siggen.set_taskdata(hashdata["hashes"], hashdata["deps"]) - -for h in hashdata["hashes"]: - bb.data.setVar("BBHASH_%s" % h, hashdata["hashes"][h], the_data) -for h in hashdata["deps"]: - bb.data.setVar("BBHASHDEPS_%s" % h, hashdata["deps"][h], the_data) - -ret = 0 -if sys.argv[4] != "True": - ret = bb.build.exec_task(fn, taskname, the_data) -sys.exit(ret) - diff --git a/bitbake/bin/bitdoc b/bitbake/bin/bitdoc deleted file mode 100755 index c2a7061d1b..0000000000 --- a/bitbake/bin/bitdoc +++ /dev/null @@ -1,532 +0,0 @@ -#!/usr/bin/env python -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -# -# Copyright (C) 2005 Holger Hans Peter Freyther -# -# 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 optparse, os, sys - -# bitbake -sys.path.append(os.path.join(os.path.dirname(os.path.dirname(__file__), 'lib')) -import bb -import bb.parse -from string import split, join - -__version__ = "0.0.2" - -class HTMLFormatter: - """ - Simple class to help to generate some sort of HTML files. It is - quite inferior solution compared to docbook, gtkdoc, doxygen but it - should work for now. - We've a global introduction site (index.html) and then one site for - the list of keys (alphabetical sorted) and one for the list of groups, - one site for each key with links to the relations and groups. - - index.html - all_keys.html - all_groups.html - groupNAME.html - keyNAME.html - """ - - def replace(self, text, *pairs): - """ - From pydoc... almost identical at least - """ - while pairs: - (a, b) = pairs[0] - text = join(split(text, a), b) - pairs = pairs[1:] - return text - def escape(self, text): - """ - Escape string to be conform HTML - """ - return self.replace(text, - ('&', '&'), - ('<', '<' ), - ('>', '>' ) ) - def createNavigator(self): - """ - Create the navgiator - """ - return """<table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"> -<tr valign="middle"> -<td><a accesskey="g" href="index.html">Home</a></td> -<td><a accesskey="n" href="all_groups.html">Groups</a></td> -<td><a accesskey="u" href="all_keys.html">Keys</a></td> -</tr></table> -""" - - def relatedKeys(self, item): - """ - Create HTML to link to foreign keys - """ - - if len(item.related()) == 0: - return "" - - txt = "<p><b>See also:</b><br>" - txts = [] - for it in item.related(): - txts.append("""<a href="key%(it)s.html">%(it)s</a>""" % vars() ) - - return txt + ",".join(txts) - - def groups(self, item): - """ - Create HTML to link to related groups - """ - - if len(item.groups()) == 0: - return "" - - - txt = "<p><b>See also:</b><br>" - txts = [] - for group in item.groups(): - txts.append( """<a href="group%s.html">%s</a> """ % (group, group) ) - - return txt + ",".join(txts) - - - def createKeySite(self, item): - """ - Create a site for a key. It contains the header/navigator, a heading, - the description, links to related keys and to the groups. - """ - - return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> -<html><head><title>Key %s</title></head> -<link rel="stylesheet" href="style.css" type="text/css"> -<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> -%s -<h2><span class="refentrytitle">%s</span></h2> - -<div class="refsynopsisdiv"> -<h2>Synopsis</h2> -<p> -%s -</p> -</div> - -<div class="refsynopsisdiv"> -<h2>Related Keys</h2> -<p> -%s -</p> -</div> - -<div class="refsynopsisdiv"> -<h2>Groups</h2> -<p> -%s -</p> -</div> - - -</body> -""" % (item.name(), self.createNavigator(), item.name(), - self.escape(item.description()), self.relatedKeys(item), self.groups(item)) - - def createGroupsSite(self, doc): - """ - Create the Group Overview site - """ - - groups = "" - sorted_groups = sorted(doc.groups()) - for group in sorted_groups: - groups += """<a href="group%s.html">%s</a><br>""" % (group, group) - - return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> -<html><head><title>Group overview</title></head> -<link rel="stylesheet" href="style.css" type="text/css"> -<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> -%s -<h2>Available Groups</h2> -%s -</body> -""" % (self.createNavigator(), groups) - - def createIndex(self): - """ - Create the index file - """ - - return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> -<html><head><title>Bitbake Documentation</title></head> -<link rel="stylesheet" href="style.css" type="text/css"> -<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> -%s -<h2>Documentation Entrance</h2> -<a href="all_groups.html">All available groups</a><br> -<a href="all_keys.html">All available keys</a><br> -</body> -""" % self.createNavigator() - - def createKeysSite(self, doc): - """ - Create Overview of all avilable keys - """ - keys = "" - sorted_keys = sorted(doc.doc_keys()) - for key in sorted_keys: - keys += """<a href="key%s.html">%s</a><br>""" % (key, key) - - return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> -<html><head><title>Key overview</title></head> -<link rel="stylesheet" href="style.css" type="text/css"> -<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> -%s -<h2>Available Keys</h2> -%s -</body> -""" % (self.createNavigator(), keys) - - def createGroupSite(self, gr, items, _description = None): - """ - Create a site for a group: - Group the name of the group, items contain the name of the keys - inside this group - """ - groups = "" - description = "" - - # create a section with the group descriptions - if _description: - description += "<h2 Description of Grozp %s</h2>" % gr - description += _description - - items.sort(lambda x, y:cmp(x.name(), y.name())) - for group in items: - groups += """<a href="key%s.html">%s</a><br>""" % (group.name(), group.name()) - - return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> -<html><head><title>Group %s</title></head> -<link rel="stylesheet" href="style.css" type="text/css"> -<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> -%s -%s -<div class="refsynopsisdiv"> -<h2>Keys in Group %s</h2> -<pre class="synopsis"> -%s -</pre> -</div> -</body> -""" % (gr, self.createNavigator(), description, gr, groups) - - - - def createCSS(self): - """ - Create the CSS file - """ - return """.synopsis, .classsynopsis -{ - background: #eeeeee; - border: solid 1px #aaaaaa; - padding: 0.5em; -} -.programlisting -{ - background: #eeeeff; - border: solid 1px #aaaaff; - padding: 0.5em; -} -.variablelist -{ - padding: 4px; - margin-left: 3em; -} -.variablelist td:first-child -{ - vertical-align: top; -} -table.navigation -{ - background: #ffeeee; - border: solid 1px #ffaaaa; - margin-top: 0.5em; - margin-bottom: 0.5em; -} -.navigation a -{ - color: #770000; -} -.navigation a:visited -{ - color: #550000; -} -.navigation .title -{ - font-size: 200%; -} -div.refnamediv -{ - margin-top: 2em; -} -div.gallery-float -{ - float: left; - padding: 10px; -} -div.gallery-float img -{ - border-style: none; -} -div.gallery-spacer -{ - clear: both; -} -a -{ - text-decoration: none; -} -a:hover -{ - text-decoration: underline; - color: #FF0000; -} -""" - - - -class DocumentationItem: - """ - A class to hold information about a configuration - item. It contains the key name, description, a list of related names, - and the group this item is contained in. - """ - - def __init__(self): - self._groups = [] - self._related = [] - self._name = "" - self._desc = "" - - def groups(self): - return self._groups - - def name(self): - return self._name - - def description(self): - return self._desc - - def related(self): - return self._related - - def setName(self, name): - self._name = name - - def setDescription(self, desc): - self._desc = desc - - def addGroup(self, group): - self._groups.append(group) - - def addRelation(self, relation): - self._related.append(relation) - - def sort(self): - self._related.sort() - self._groups.sort() - - -class Documentation: - """ - Holds the documentation... with mappings from key to items... - """ - - def __init__(self): - self.__keys = {} - self.__groups = {} - - def insert_doc_item(self, item): - """ - Insert the Doc Item into the internal list - of representation - """ - item.sort() - self.__keys[item.name()] = item - - for group in item.groups(): - if not group in self.__groups: - self.__groups[group] = [] - self.__groups[group].append(item) - self.__groups[group].sort() - - - def doc_item(self, key): - """ - Return the DocumentationInstance describing the key - """ - try: - return self.__keys[key] - except KeyError: - return None - - def doc_keys(self): - """ - Return the documented KEYS (names) - """ - return self.__keys.keys() - - def groups(self): - """ - Return the names of available groups - """ - return self.__groups.keys() - - def group_content(self, group_name): - """ - Return a list of keys/names that are in a specefic - group or the empty list - """ - try: - return self.__groups[group_name] - except KeyError: - return [] - - -def parse_cmdline(args): - """ - Parse the CMD line and return the result as a n-tuple - """ - - parser = optparse.OptionParser( version = "Bitbake Documentation Tool Core version %s, %%prog version %s" % (bb.__version__, __version__)) - usage = """%prog [options] - -Create a set of html pages (documentation) for a bitbake.conf.... -""" - - # Add the needed options - parser.add_option( "-c", "--config", help = "Use the specified configuration file as source", - action = "store", dest = "config", default = os.path.join("conf", "documentation.conf") ) - - parser.add_option( "-o", "--output", help = "Output directory for html files", - action = "store", dest = "output", default = "html/" ) - - parser.add_option( "-D", "--debug", help = "Increase the debug level", - action = "count", dest = "debug", default = 0 ) - - parser.add_option( "-v", "--verbose", help = "output more chit-char to the terminal", - action = "store_true", dest = "verbose", default = False ) - - options, args = parser.parse_args( sys.argv ) - - if options.debug: - bb.msg.set_debug_level(options.debug) - - return options.config, options.output - -def main(): - """ - The main Method - """ - - (config_file, output_dir) = parse_cmdline( sys.argv ) - - # right to let us load the file now - try: - documentation = bb.parse.handle( config_file, bb.data.init() ) - except IOError: - bb.fatal( "Unable to open %s" % config_file ) - except bb.parse.ParseError: - bb.fatal( "Unable to parse %s" % config_file ) - - if isinstance(documentation, dict): - documentation = documentation[""] - - # Assuming we've the file loaded now, we will initialize the 'tree' - doc = Documentation() - - # defined states - state_begin = 0 - state_see = 1 - state_group = 2 - - for key in bb.data.keys(documentation): - data = bb.data.getVarFlag(key, "doc", documentation) - if not data: - continue - - # The Documentation now starts - doc_ins = DocumentationItem() - doc_ins.setName(key) - - - tokens = data.split(' ') - state = state_begin - string= "" - for token in tokens: - token = token.strip(',') - - if not state == state_see and token == "@see": - state = state_see - continue - elif not state == state_group and token == "@group": - state = state_group - continue - - if state == state_begin: - string += " %s" % token - elif state == state_see: - doc_ins.addRelation(token) - elif state == state_group: - doc_ins.addGroup(token) - - # set the description - doc_ins.setDescription(string) - doc.insert_doc_item(doc_ins) - - # let us create the HTML now - bb.mkdirhier(output_dir) - os.chdir(output_dir) - - # Let us create the sites now. We do it in the following order - # Start with the index.html. It will point to sites explaining all - # keys and groups - html_slave = HTMLFormatter() - - f = file('style.css', 'w') - print >> f, html_slave.createCSS() - - f = file('index.html', 'w') - print >> f, html_slave.createIndex() - - f = file('all_groups.html', 'w') - print >> f, html_slave.createGroupsSite(doc) - - f = file('all_keys.html', 'w') - print >> f, html_slave.createKeysSite(doc) - - # now for each group create the site - for group in doc.groups(): - f = file('group%s.html' % group, 'w') - print >> f, html_slave.createGroupSite(group, doc.group_content(group)) - - # now for the keys - for key in doc.doc_keys(): - f = file('key%s.html' % doc.doc_item(key).name(), 'w') - print >> f, html_slave.createKeySite(doc.doc_item(key)) - - -if __name__ == "__main__": - main() |