Add tryaltconfigs option to control whether bitbake trys using alternative providers...
[vuplus_bitbake] / bin / bitbake
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
25 import sys, os, getopt, re, time, optparse
26 sys.path.insert(0,os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
27 import bb
28 from bb import cooker
29
30 __version__ = "1.8.11"
31
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
44 #============================================================================#
45 # main
46 #============================================================================#
47
48 def main():
49     parser = optparse.OptionParser( version = "BitBake Build Tool Core version %s, %%prog version %s" % ( bb.__version__, __version__ ),
50     usage = """%prog [options] [package ...]
51
52 Executes the specified task (default is 'build') for a given set of BitBake files.
53 It expects that BBFILES is defined, which is a space separated list of files to
54 be executed.  BBFILES does support wildcards.
55 Default BBFILES are the .bb files in the current directory.""" )
56
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
60     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.",
61                action = "store_false", dest = "abort", default = True )
62
63     parser.add_option( "-a", "--tryaltconfigs", help = "continue with builds by trying to use alternative providers where possible.",
64                action = "store_true", dest = "tryaltconfigs", default = False )
65
66     parser.add_option( "-f", "--force", help = "force run of specified cmd, regardless of stamp status",
67                action = "store_true", dest = "force", default = False )
68
69     parser.add_option( "-i", "--interactive", help = "drop into the interactive mode also called the BitBake shell.",
70                action = "store_true", dest = "interactive", default = False )
71
72     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",
73                action = "store", dest = "cmd" )
74
75     parser.add_option( "-r", "--read", help = "read the specified file before bitbake.conf",
76                action = "append", dest = "file", default = [] )
77
78     parser.add_option( "-v", "--verbose", help = "output more chit-chat to the terminal",
79                action = "store_true", dest = "verbose", default = False )
80
81     parser.add_option( "-D", "--debug", help = "Increase the debug level. You can specify this more than once.",
82                action = "count", dest="debug", default = 0)
83
84     parser.add_option( "-n", "--dry-run", help = "don't execute, just go through the motions",
85                action = "store_true", dest = "dry_run", default = False )
86
87     parser.add_option( "-p", "--parse-only", help = "quit after parsing the BB files (developers only)",
88                action = "store_true", dest = "parse_only", default = False )
89
90     parser.add_option( "-d", "--disable-psyco", help = "disable using the psyco just-in-time compiler (not recommended)",
91                action = "store_true", dest = "disable_psyco", default = False )
92
93     parser.add_option( "-s", "--show-versions", help = "show current and preferred versions of all packages",
94                action = "store_true", dest = "show_versions", default = False )
95
96     parser.add_option( "-e", "--environment", help = "show the global or per-package environment (this is what used to be bbread)",
97                action = "store_true", dest = "show_environment", default = False )
98
99     parser.add_option( "-g", "--graphviz", help = "emit the dependency trees of the specified packages in the dot syntax",
100                 action = "store_true", dest = "dot_graph", default = False )
101
102     parser.add_option( "-I", "--ignore-deps", help = """Stop processing at the given list of dependencies when generating dependency graphs. This can help to make the graph more appealing""",
103                 action = "append", dest = "ignored_dot_deps", default = [] )
104
105     parser.add_option( "-l", "--log-domains", help = """Show debug logging for the specified logging domains""",
106                 action = "append", dest = "debug_domains", default = [] )
107
108     parser.add_option( "-P", "--profile", help = "profile the command and print a report",
109                action = "store_true", dest = "profile", default = False )
110
111     options, args = parser.parse_args(sys.argv)
112
113     configuration = BBConfiguration(options)
114     configuration.pkgs_to_build = []
115     configuration.pkgs_to_build.extend(args[1:])
116
117     cooker = bb.cooker.BBCooker(configuration)
118
119     # Optionally clean up the environment
120     if 'BB_PRESERVE_ENV' not in os.environ:
121         if 'BB_ENV_WHITELIST' in os.environ:
122             good_vars = os.environ['BB_ENV_WHITELIST'].split()
123         else:
124             good_vars = bb.utils.preserved_envvars_list()
125         if 'BB_ENV_EXTRAWHITE' in os.environ:
126             good_vars.extend(os.environ['BB_ENV_EXTRAWHITE'].split())
127         bb.utils.filter_environment(good_vars)
128
129     cooker.parseConfiguration()
130
131     if configuration.profile:
132         try:
133             import cProfile as profile
134         except:
135             import profile
136
137         profile.runctx("cooker.cook()", globals(), locals(), "profile.log")
138         import pstats
139         p = pstats.Stats('profile.log')
140         p.sort_stats('time')
141         p.print_stats()
142         p.print_callers()
143         p.sort_stats('cumulative')
144         p.print_stats()
145     else:
146         cooker.cook()
147
148 if __name__ == "__main__":
149     main()