bitbake 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. #!/usr/bin/env python
  2. # ex:ts=4:sw=4:sts=4:et
  3. # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
  4. #
  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
  11. #
  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.
  15. #
  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.
  20. #
  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.
  24. import sys, os, getopt, re, time, optparse, xmlrpclib
  25. sys.path.insert(0,os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
  26. import bb
  27. from bb import cooker
  28. from bb import daemonize
  29. from bb import ui
  30. from bb.ui import uievent
  31. __version__ = "1.9.0"
  32. #============================================================================#
  33. # BBOptions
  34. #============================================================================#
  35. class BBConfiguration( object ):
  36. """
  37. Manages build options and configurations for one run
  38. """
  39. def __init__( self, options ):
  40. for key, val in options.__dict__.items():
  41. setattr( self, key, val )
  42. #============================================================================#
  43. # main
  44. #============================================================================#
  45. def main():
  46. return_value = 0
  47. pythonver = sys.version_info
  48. if pythonver[0] < 2 or (pythonver[0] == 2 and pythonver[1] < 5):
  49. print "Sorry, bitbake needs python 2.5 or later."
  50. sys.exit(1)
  51. parser = optparse.OptionParser( version = "BitBake Build Tool Core version %s, %%prog version %s" % ( bb.__version__, __version__ ),
  52. usage = """%prog [options] [package ...]
  53. Executes the specified task (default is 'build') for a given set of BitBake files.
  54. It expects that BBFILES is defined, which is a space separated list of files to
  55. be executed. BBFILES does support wildcards.
  56. Default BBFILES are the .bb files in the current directory.""" )
  57. parser.add_option( "-b", "--buildfile", help = "execute the task against this .bb file, rather than a package from BBFILES.",
  58. action = "store", dest = "buildfile", default = None )
  59. 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.",
  60. action = "store_false", dest = "abort", default = True )
  61. parser.add_option( "-f", "--force", help = "force run of specified cmd, regardless of stamp status",
  62. action = "store_true", dest = "force", default = False )
  63. parser.add_option( "-i", "--interactive", help = "drop into the interactive mode also called the BitBake shell.",
  64. action = "store_true", dest = "interactive", default = False )
  65. 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",
  66. action = "store", dest = "cmd" )
  67. parser.add_option( "-r", "--read", help = "read the specified file before bitbake.conf",
  68. action = "append", dest = "file", default = [] )
  69. parser.add_option( "-v", "--verbose", help = "output more chit-chat to the terminal",
  70. action = "store_true", dest = "verbose", default = False )
  71. parser.add_option( "-D", "--debug", help = "Increase the debug level. You can specify this more than once.",
  72. action = "count", dest="debug", default = 0)
  73. parser.add_option( "-n", "--dry-run", help = "don't execute, just go through the motions",
  74. action = "store_true", dest = "dry_run", default = False )
  75. parser.add_option( "-p", "--parse-only", help = "quit after parsing the BB files (developers only)",
  76. action = "store_true", dest = "parse_only", default = False )
  77. parser.add_option( "-d", "--disable-psyco", help = "disable using the psyco just-in-time compiler (not recommended)",
  78. action = "store_true", dest = "disable_psyco", default = False )
  79. parser.add_option( "-s", "--show-versions", help = "show current and preferred versions of all packages",
  80. action = "store_true", dest = "show_versions", default = False )
  81. parser.add_option( "-e", "--environment", help = "show the global or per-package environment (this is what used to be bbread)",
  82. action = "store_true", dest = "show_environment", default = False )
  83. parser.add_option( "-g", "--graphviz", help = "emit the dependency trees of the specified packages in the dot syntax",
  84. action = "store_true", dest = "dot_graph", default = False )
  85. 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""",
  86. action = "append", dest = "extra_assume_provided", default = [] )
  87. parser.add_option( "-l", "--log-domains", help = """Show debug logging for the specified logging domains""",
  88. action = "append", dest = "debug_domains", default = [] )
  89. parser.add_option( "-P", "--profile", help = "profile the command and print a report",
  90. action = "store_true", dest = "profile", default = False )
  91. parser.add_option( "-u", "--ui", help = "userinterface to use",
  92. action = "store", dest = "ui")
  93. options, args = parser.parse_args(sys.argv)
  94. configuration = BBConfiguration(options)
  95. configuration.pkgs_to_build = []
  96. configuration.pkgs_to_build.extend(args[1:])
  97. # Work out which UI(s) to use
  98. curseUI = False
  99. depexplorerUI = False
  100. if configuration.ui:
  101. if configuration.ui == "ncurses":
  102. curseUI = True
  103. elif configuration.ui == "knotty" or configuration.ui == "tty" or configuration.ui == "file":
  104. curseUI = False
  105. elif configuration.ui == "depexp":
  106. depexplorerUI = True
  107. else:
  108. print "FATAL: Invalid user interface '%s' specified.\nValid interfaces are 'ncurses', 'depexp' or the default, 'knotty'." % configuration.ui
  109. sys.exit(1)
  110. cooker = bb.cooker.BBCooker(configuration)
  111. # Optionally clean up the environment
  112. if 'BB_PRESERVE_ENV' not in os.environ:
  113. if 'BB_ENV_WHITELIST' in os.environ:
  114. good_vars = os.environ['BB_ENV_WHITELIST'].split()
  115. else:
  116. good_vars = bb.utils.preserved_envvars_list()
  117. if 'BB_ENV_EXTRAWHITE' in os.environ:
  118. good_vars.extend(os.environ['BB_ENV_EXTRAWHITE'].split())
  119. bb.utils.filter_environment(good_vars)
  120. cooker.parseConfiguration()
  121. host = cooker.server.host
  122. port = cooker.server.port
  123. # Save a logfile for cooker somewhere
  124. t = bb.data.getVar('TMPDIR', cooker.configuration.data, True)
  125. if not t:
  126. bb.msg.fatal(bb.msg.domain.Build, "TMPDIR not set")
  127. t = os.path.join(t, "cooker")
  128. bb.mkdirhier(t)
  129. cooker_logfile = "%s/log.cooker.%s" % (t, str(os.getpid()))
  130. daemonize.createDaemon(cooker.serve, cooker_logfile)
  131. del cooker
  132. # Setup a connection to the server (cooker)
  133. server = xmlrpclib.Server("http://%s:%s" % (host, port), allow_none=True)
  134. # Setup an event receiving queue
  135. eventHandler = uievent.BBUIEventQueue(server)
  136. # Launch the UI
  137. try:
  138. # Disable UIs that need a terminal
  139. if not os.isatty(sys.stdout.fileno()):
  140. curseUI = False
  141. if curseUI:
  142. try:
  143. import curses
  144. except ImportError, details:
  145. curseUI = False
  146. if curseUI:
  147. from bb.ui import ncurses
  148. ncurses.init(server, eventHandler)
  149. elif depexplorerUI:
  150. from bb.ui import depexplorer
  151. depexplorer.init(server, eventHandler)
  152. else:
  153. from bb.ui import knotty
  154. return_value = knotty.init(server, eventHandler)
  155. finally:
  156. # Don't wait for server indefinitely
  157. import socket
  158. socket.setdefaulttimeout(2)
  159. try:
  160. eventHandler.system_quit()
  161. except:
  162. pass
  163. try:
  164. server.terminateServer()
  165. except:
  166. pass
  167. return return_value
  168. if __name__ == "__main__":
  169. print """WARNING, WARNING, WARNING
  170. This is a Bitbake from the Unstable/Development 1.9 Branch. This software contains gaping security holes and is dangerous to use!
  171. 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."""
  172. import time
  173. time.sleep(5)
  174. ret = main()
  175. sys.exit(ret)