2 # ex:ts=4:sw=4:sts=4:et
3 # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
5 # Copyright (C) 2003, 2004 Chris Larson
6 # Copyright (C) 2003, 2004 Phil Blundell
7 # Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer
8 # Copyright (C) 2005 Holger Hans Peter Freyther
9 # Copyright (C) 2005 ROAD GmbH
10 # Copyright (C) 2006 Richard Purdie
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License version 2 as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along
22 # with this program; if not, write to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 import sys, os, getopt, re, time, optparse, xmlrpclib
26 sys.path.insert(0,os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
29 from bb import daemonize
31 from bb.ui import uievent
35 #============================================================================#
37 #============================================================================#
38 class BBConfiguration( object ):
40 Manages build options and configurations for one run
42 def __init__( self, options ):
43 for key, val in options.__dict__.items():
44 setattr( self, key, val )
47 #============================================================================#
49 #============================================================================#
53 pythonver = sys.version_info
54 if pythonver[0] < 2 or (pythonver[0] == 2 and pythonver[1] < 5):
55 print "Sorry, bitbake needs python 2.5 or later."
58 parser = optparse.OptionParser( version = "BitBake Build Tool Core version %s, %%prog version %s" % ( bb.__version__, __version__ ),
59 usage = """%prog [options] [package ...]
61 Executes the specified task (default is 'build') for a given set of BitBake files.
62 It expects that BBFILES is defined, which is a space separated list of files to
63 be executed. BBFILES does support wildcards.
64 Default BBFILES are the .bb files in the current directory.""" )
66 parser.add_option( "-b", "--buildfile", help = "execute the task against this .bb file, rather than a package from BBFILES.",
67 action = "store", dest = "buildfile", default = None )
69 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.",
70 action = "store_false", dest = "abort", default = True )
72 parser.add_option( "-f", "--force", help = "force run of specified cmd, regardless of stamp status",
73 action = "store_true", dest = "force", default = False )
75 parser.add_option( "-i", "--interactive", help = "drop into the interactive mode also called the BitBake shell.",
76 action = "store_true", dest = "interactive", default = False )
78 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",
79 action = "store", dest = "cmd" )
81 parser.add_option( "-r", "--read", help = "read the specified file before bitbake.conf",
82 action = "append", dest = "file", default = [] )
84 parser.add_option( "-v", "--verbose", help = "output more chit-chat to the terminal",
85 action = "store_true", dest = "verbose", default = False )
87 parser.add_option( "-D", "--debug", help = "Increase the debug level. You can specify this more than once.",
88 action = "count", dest="debug", default = 0)
90 parser.add_option( "-n", "--dry-run", help = "don't execute, just go through the motions",
91 action = "store_true", dest = "dry_run", default = False )
93 parser.add_option( "-p", "--parse-only", help = "quit after parsing the BB files (developers only)",
94 action = "store_true", dest = "parse_only", default = False )
96 parser.add_option( "-d", "--disable-psyco", help = "disable using the psyco just-in-time compiler (not recommended)",
97 action = "store_true", dest = "disable_psyco", default = False )
99 parser.add_option( "-s", "--show-versions", help = "show current and preferred versions of all packages",
100 action = "store_true", dest = "show_versions", default = False )
102 parser.add_option( "-e", "--environment", help = "show the global or per-package environment (this is what used to be bbread)",
103 action = "store_true", dest = "show_environment", default = False )
105 parser.add_option( "-g", "--graphviz", help = "emit the dependency trees of the specified packages in the dot syntax",
106 action = "store_true", dest = "dot_graph", default = False )
108 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""",
109 action = "append", dest = "extra_assume_provided", default = [] )
111 parser.add_option( "-l", "--log-domains", help = """Show debug logging for the specified logging domains""",
112 action = "append", dest = "debug_domains", default = [] )
114 parser.add_option( "-P", "--profile", help = "profile the command and print a report",
115 action = "store_true", dest = "profile", default = False )
117 parser.add_option( "-u", "--ui", help = "userinterface to use",
118 action = "store", dest = "ui")
120 options, args = parser.parse_args(sys.argv)
122 configuration = BBConfiguration(options)
123 configuration.pkgs_to_build = []
124 configuration.pkgs_to_build.extend(args[1:])
127 # Work out which UI(s) to use
129 depexplorerUI = False
131 if configuration.ui == "ncurses":
133 elif configuration.ui == "knotty" or configuration.ui == "tty" or configuration.ui == "file":
135 elif configuration.ui == "depexp":
138 print "FATAL: Invalid user interface '%s' specified.\nValid interfaces are 'ncurses', 'depexp' or the default, 'knotty'." % configuration.ui
142 cooker = bb.cooker.BBCooker(configuration)
143 host = cooker.server.host
144 port = cooker.server.port
146 # Save a logfile for cooker somewhere
147 t = bb.data.getVar('TMPDIR', cooker.configuration.data, True)
149 bb.msg.fatal(bb.msg.domain.Build, "TMPDIR not set")
150 t = os.path.join(t, "cooker")
152 cooker_logfile = "%s/log.cooker.%s" % (t, str(os.getpid()))
154 daemonize.createDaemon(cooker.serve, cooker_logfile)
157 # Setup a connection to the server (cooker)
158 server = xmlrpclib.Server("http://%s:%s" % (host, port), allow_none=True)
159 # Setup an event receiving queue
160 eventHandler = uievent.BBUIEventQueue(server)
164 # Disable UIs that need a terminal
165 if not os.isatty(sys.stdout.fileno()):
171 except ImportError, details:
175 from bb.ui import ncurses
176 ncurses.init(server, eventHandler)
178 from bb.ui import depexplorer
179 depexplorer.init(server, eventHandler)
181 from bb.ui import knotty
182 return_value = knotty.init(server, eventHandler)
185 # Don't wait for server indefinitely
187 socket.setdefaulttimeout(2)
189 eventHandler.system_quit()
193 server.terminateServer()
198 if __name__ == "__main__":
199 print """WARNING, WARNING, WARNING
200 This is a Bitbake from the Unstable/Development 1.9 Branch. This software contains gaping security holes and is dangerous to use!
201 You might want to use the bitbake-1.8 stable branch (if you are not a BitBake developer or tester). I'm going to sleep 5 seconds now to make sure you see that."""