summaryrefslogtreecommitdiffstats
path: root/bitbake/bin
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-20 22:54:30 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-22 12:10:13 +0100
commitf242f5060bbc62815b6d5a245c1a9bf18f23675f (patch)
tree61aa4d66293ea4a4ea703e10499b13209affbbb1 /bitbake/bin
parent308ae9210067da0348f2cf2b6d56a7dce5b45936 (diff)
downloadpoky-f242f5060bbc62815b6d5a245c1a9bf18f23675f.tar.gz
bitbake: bitbake: Create cookerdata splitting config from cooker and bin/bitbake
Currently the UI and server configuration is one big incestuous mess. To start to untangle this we creater cookerdata, a new module which contains various confiuration modules and the code for building the base datastore. To start with we add a ConfigParameters() class which contains information about both the commandline configuration and the original environment. The CookerConfiguration class is created to contain the cooker.configuration options. This means we can transfer new paramters to the server over something like XMLRPC and then build a new configuration from these on the server. Based on a patch from Alexandru Damian <alexandru.damian@intel.com> (Bitbake rev: 35bd5997e8d8e74bc36019030cc10c560a8134f9) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-xbitbake/bin/bitbake146
1 files changed, 69 insertions, 77 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index 5b9294bf4e..7087d2d94b 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -39,6 +39,7 @@ import bb.msg
39from bb import cooker 39from bb import cooker
40from bb import ui 40from bb import ui
41from bb import server 41from bb import server
42from bb import cookerdata
42 43
43__version__ = "1.19.0" 44__version__ = "1.19.0"
44logger = logging.getLogger("BitBake") 45logger = logging.getLogger("BitBake")
@@ -56,16 +57,6 @@ try:
56except: 57except:
57 pass 58 pass
58 59
59class BBConfiguration(object):
60 """
61 Manages build options and configurations for one run
62 """
63
64 def __init__(self, options):
65 for key, val in options.__dict__.items():
66 setattr(self, key, val)
67 self.pkgs_to_build = []
68
69 60
70def get_ui(config): 61def get_ui(config):
71 if not config.ui: 62 if not config.ui:
@@ -104,94 +95,99 @@ warnings.filterwarnings("ignore", category=ImportWarning)
104warnings.filterwarnings("ignore", category=DeprecationWarning, module="<string>$") 95warnings.filterwarnings("ignore", category=DeprecationWarning, module="<string>$")
105warnings.filterwarnings("ignore", message="With-statements now directly support multiple context managers") 96warnings.filterwarnings("ignore", message="With-statements now directly support multiple context managers")
106 97
98class BitBakeConfigParameters(cookerdata.ConfigParameters):
107 99
108def main(): 100 def parseCommandLine(self):
109 parser = optparse.OptionParser( 101 parser = optparse.OptionParser(
110 version = "BitBake Build Tool Core version %s, %%prog version %s" % (bb.__version__, __version__), 102 version = "BitBake Build Tool Core version %s, %%prog version %s" % (bb.__version__, __version__),
111 usage = """%prog [options] [package ...] 103 usage = """%prog [options] [package ...]
112 104
113Executes the specified task (default is 'build') for a given set of BitBake files. 105 Executes the specified task (default is 'build') for a given set of BitBake files.
114It expects that BBFILES is defined, which is a space separated list of files to 106 It expects that BBFILES is defined, which is a space separated list of files to
115be executed. BBFILES does support wildcards. 107 be executed. BBFILES does support wildcards.
116Default BBFILES are the .bb files in the current directory.""") 108 Default BBFILES are the .bb files in the current directory.""")
117 109
118 parser.add_option("-b", "--buildfile", help = "execute the task against this .bb file, rather than a package from BBFILES. Does not handle any dependencies.", 110 parser.add_option("-b", "--buildfile", help = "execute the task against this .bb file, rather than a package from BBFILES. Does not handle any dependencies.",
119 action = "store", dest = "buildfile", default = None) 111 action = "store", dest = "buildfile", default = None)
120 112
121 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.", 113 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.",
122 action = "store_false", dest = "abort", default = True) 114 action = "store_false", dest = "abort", default = True)
123 115
124 parser.add_option("-a", "--tryaltconfigs", help = "continue with builds by trying to use alternative providers where possible.", 116 parser.add_option("-a", "--tryaltconfigs", help = "continue with builds by trying to use alternative providers where possible.",
125 action = "store_true", dest = "tryaltconfigs", default = False) 117 action = "store_true", dest = "tryaltconfigs", default = False)
126 118
127 parser.add_option("-f", "--force", help = "force run of specified cmd, regardless of stamp status", 119 parser.add_option("-f", "--force", help = "force run of specified cmd, regardless of stamp status",
128 action = "store_true", dest = "force", default = False) 120 action = "store_true", dest = "force", default = False)
129 121
130 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", 122 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",
131 action = "store", dest = "cmd") 123 action = "store", dest = "cmd")
132 124
133 parser.add_option("-C", "--clear-stamp", help = "Invalidate the stamp for the specified cmd such as 'compile' and run the default task for the specified target(s)", 125 parser.add_option("-C", "--clear-stamp", help = "Invalidate the stamp for the specified cmd such as 'compile' and run the default task for the specified target(s)",
134 action = "store", dest = "invalidate_stamp") 126 action = "store", dest = "invalidate_stamp")
135 127
136 parser.add_option("-r", "--read", help = "read the specified file before bitbake.conf", 128 parser.add_option("-r", "--read", help = "read the specified file before bitbake.conf",
137 action = "append", dest = "prefile", default = []) 129 action = "append", dest = "prefile", default = [])
138 130
139 parser.add_option("-R", "--postread", help = "read the specified file after bitbake.conf", 131 parser.add_option("-R", "--postread", help = "read the specified file after bitbake.conf",
140 action = "append", dest = "postfile", default = []) 132 action = "append", dest = "postfile", default = [])
141 133
142 parser.add_option("-v", "--verbose", help = "output more chit-chat to the terminal", 134 parser.add_option("-v", "--verbose", help = "output more chit-chat to the terminal",
143 action = "store_true", dest = "verbose", default = False) 135 action = "store_true", dest = "verbose", default = False)
144 136
145 parser.add_option("-D", "--debug", help = "Increase the debug level. You can specify this more than once.", 137 parser.add_option("-D", "--debug", help = "Increase the debug level. You can specify this more than once.",
146 action = "count", dest="debug", default = 0) 138 action = "count", dest="debug", default = 0)
147 139
148 parser.add_option("-n", "--dry-run", help = "don't execute, just go through the motions", 140 parser.add_option("-n", "--dry-run", help = "don't execute, just go through the motions",
149 action = "store_true", dest = "dry_run", default = False) 141 action = "store_true", dest = "dry_run", default = False)
150 142
151 parser.add_option("-S", "--dump-signatures", help = "don't execute, just dump out the signature construction information", 143 parser.add_option("-S", "--dump-signatures", help = "don't execute, just dump out the signature construction information",
152 action = "store_true", dest = "dump_signatures", default = False) 144 action = "store_true", dest = "dump_signatures", default = False)
153 145
154 parser.add_option("-p", "--parse-only", help = "quit after parsing the BB files (developers only)", 146 parser.add_option("-p", "--parse-only", help = "quit after parsing the BB files (developers only)",
155 action = "store_true", dest = "parse_only", default = False) 147 action = "store_true", dest = "parse_only", default = False)
156 148
157 parser.add_option("-s", "--show-versions", help = "show current and preferred versions of all recipes", 149 parser.add_option("-s", "--show-versions", help = "show current and preferred versions of all recipes",
158 action = "store_true", dest = "show_versions", default = False) 150 action = "store_true", dest = "show_versions", default = False)
159 151
160 parser.add_option("-e", "--environment", help = "show the global or per-package environment (this is what used to be bbread)", 152 parser.add_option("-e", "--environment", help = "show the global or per-package environment (this is what used to be bbread)",
161 action = "store_true", dest = "show_environment", default = False) 153 action = "store_true", dest = "show_environment", default = False)
162 154
163 parser.add_option("-g", "--graphviz", help = "emit the dependency trees of the specified packages in the dot syntax, and the pn-buildlist to show the build list", 155 parser.add_option("-g", "--graphviz", help = "emit the dependency trees of the specified packages in the dot syntax, and the pn-buildlist to show the build list",
164 action = "store_true", dest = "dot_graph", default = False) 156 action = "store_true", dest = "dot_graph", default = False)
165 157
166 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""", 158 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""",
167 action = "append", dest = "extra_assume_provided", default = []) 159 action = "append", dest = "extra_assume_provided", default = [])
168 160
169 parser.add_option("-l", "--log-domains", help = """Show debug logging for the specified logging domains""", 161 parser.add_option("-l", "--log-domains", help = """Show debug logging for the specified logging domains""",
170 action = "append", dest = "debug_domains", default = []) 162 action = "append", dest = "debug_domains", default = [])
171 163
172 parser.add_option("-P", "--profile", help = "profile the command and print a report", 164 parser.add_option("-P", "--profile", help = "profile the command and print a report",
173 action = "store_true", dest = "profile", default = False) 165 action = "store_true", dest = "profile", default = False)
174 166
175 parser.add_option("-u", "--ui", help = "userinterface to use", 167 parser.add_option("-u", "--ui", help = "userinterface to use",
176 action = "store", dest = "ui") 168 action = "store", dest = "ui")
177 169
178 parser.add_option("-t", "--servertype", help = "Choose which server to use, none, process or xmlrpc", 170 parser.add_option("-t", "--servertype", help = "Choose which server to use, none, process or xmlrpc",
179 action = "store", dest = "servertype") 171 action = "store", dest = "servertype")
180 172
181 parser.add_option("", "--revisions-changed", help = "Set the exit code depending on whether upstream floating revisions have changed or not", 173 parser.add_option("", "--revisions-changed", help = "Set the exit code depending on whether upstream floating revisions have changed or not",
182 action = "store_true", dest = "revisions_changed", default = False) 174 action = "store_true", dest = "revisions_changed", default = False)
183 175
184 parser.add_option("", "--server-only", help = "Run bitbake without UI, the frontend can connect with bitbake server itself", 176 parser.add_option("", "--server-only", help = "Run bitbake without UI, the frontend can connect with bitbake server itself",
185 action = "store_true", dest = "server_only", default = False) 177 action = "store_true", dest = "server_only", default = False)
186 178
187 parser.add_option("-B", "--bind", help = "The name/address for the bitbake server to bind to", 179 parser.add_option("-B", "--bind", help = "The name/address for the bitbake server to bind to",
188 action = "store", dest = "bind", default = False) 180 action = "store", dest = "bind", default = False)
189 parser.add_option("", "--no-setscene", help = "Do not run any setscene tasks, forces builds", 181 parser.add_option("", "--no-setscene", help = "Do not run any setscene tasks, forces builds",
190 action = "store_true", dest = "nosetscene", default = False) 182 action = "store_true", dest = "nosetscene", default = False)
191 options, args = parser.parse_args(sys.argv) 183 options, targets = parser.parse_args(sys.argv)
184 return options, targets[1:]
192 185
193 configuration = BBConfiguration(options) 186def main():
194 configuration.pkgs_to_build.extend(args[1:]) 187
188 configParams = BitBakeConfigParameters()
189 configuration = cookerdata.CookerConfiguration()
190 configuration.setConfigParameters(configParams)
195 191
196 ui_main = get_ui(configuration) 192 ui_main = get_ui(configuration)
197 193
@@ -230,9 +226,6 @@ Default BBFILES are the .bb files in the current directory.""")
230 handler = bb.event.LogHandler() 226 handler = bb.event.LogHandler()
231 logger.addHandler(handler) 227 logger.addHandler(handler)
232 228
233 # Before we start modifying the environment we should take a pristine
234 # copy for possible later use
235 initialenv = os.environ.copy()
236 # Clear away any spurious environment variables while we stoke up the cooker 229 # Clear away any spurious environment variables while we stoke up the cooker
237 cleanedvars = bb.utils.clean_environment() 230 cleanedvars = bb.utils.clean_environment()
238 231
@@ -242,10 +235,9 @@ Default BBFILES are the .bb files in the current directory.""")
242 else: 235 else:
243 server.initServer() 236 server.initServer()
244 237
245 idle = server.getServerIdleCB()
246
247 try: 238 try:
248 cooker = bb.cooker.BBCooker(configuration, idle, initialenv) 239 configuration.setServerRegIdleCallback(server.getServerIdleCB())
240 cooker = bb.cooker.BBCooker(configuration)
249 cooker.parseCommandLine() 241 cooker.parseCommandLine()
250 242
251 server.addcooker(cooker) 243 server.addcooker(cooker)