summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbitbake/bin/bitbake146
-rw-r--r--bitbake/lib/bb/command.py2
-rw-r--r--bitbake/lib/bb/cooker.py11
-rw-r--r--bitbake/lib/bb/cookerdata.py73
4 files changed, 148 insertions, 84 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)
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index 3abdd0c649..8577df6e0c 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -78,7 +78,7 @@ class Command:
78 if command not in CommandsAsync.__dict__: 78 if command not in CommandsAsync.__dict__:
79 return None, "No such command" 79 return None, "No such command"
80 self.currentAsyncCommand = (command, commandline) 80 self.currentAsyncCommand = (command, commandline)
81 self.cooker.server_registration_cb(self.cooker.runCommands, self.cooker) 81 self.cooker.configuration.server_register_idlecallback(self.cooker.runCommands, self.cooker)
82 return True, None 82 return True, None
83 83
84 def runAsyncCommand(self): 84 def runAsyncCommand(self):
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index affe1136c4..1a2c01639e 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -87,12 +87,10 @@ class BBCooker:
87 Manages one bitbake build run 87 Manages one bitbake build run
88 """ 88 """
89 89
90 def __init__(self, configuration, server_registration_cb, savedenv={}): 90 def __init__(self, configuration):
91 self.recipecache = None 91 self.recipecache = None
92 self.skiplist = {} 92 self.skiplist = {}
93 93
94 self.server_registration_cb = server_registration_cb
95
96 self.configuration = configuration 94 self.configuration = configuration
97 95
98 # Keep a datastore of the initial environment variables and their 96 # Keep a datastore of the initial environment variables and their
@@ -100,6 +98,7 @@ class BBCooker:
100 # to use environment variables which have been cleaned from the 98 # to use environment variables which have been cleaned from the
101 # BitBake processes env 99 # BitBake processes env
102 self.savedenv = bb.data.init() 100 self.savedenv = bb.data.init()
101 savedenv = configuration.params.environment
103 for k in savedenv: 102 for k in savedenv:
104 self.savedenv.setVar(k, savedenv[k]) 103 self.savedenv.setVar(k, savedenv[k])
105 104
@@ -179,7 +178,7 @@ class BBCooker:
179 if self.configuration.show_environment: 178 if self.configuration.show_environment:
180 self.configuration.data.enableTracking() 179 self.configuration.data.enableTracking()
181 180
182 if not self.server_registration_cb: 181 if not self.configuration.server_register_idlecallback:
183 self.configuration.data.setVar("BB_WORKERCONTEXT", "1") 182 self.configuration.data.setVar("BB_WORKERCONTEXT", "1")
184 183
185 filtered_keys = bb.utils.approved_variables() 184 filtered_keys = bb.utils.approved_variables()
@@ -1188,7 +1187,7 @@ class BBCooker:
1188 return True 1187 return True
1189 return retval 1188 return retval
1190 1189
1191 self.server_registration_cb(buildFileIdle, rq) 1190 self.configuration.server_register_idlecallback(buildFileIdle, rq)
1192 1191
1193 def buildTargets(self, targets, task): 1192 def buildTargets(self, targets, task):
1194 """ 1193 """
@@ -1246,7 +1245,7 @@ class BBCooker:
1246 if universe: 1245 if universe:
1247 rq.rqdata.warn_multi_bb = True 1246 rq.rqdata.warn_multi_bb = True
1248 1247
1249 self.server_registration_cb(buildTargetsIdle, rq) 1248 self.configuration.server_register_idlecallback(buildTargetsIdle, rq)
1250 1249
1251 def generateNewImage(self, image, base_image, package_queue): 1250 def generateNewImage(self, image, base_image, package_queue):
1252 ''' 1251 '''
diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py
new file mode 100644
index 0000000000..2c3275ac65
--- /dev/null
+++ b/bitbake/lib/bb/cookerdata.py
@@ -0,0 +1,73 @@
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
25import os, sys
26from functools import wraps
27import logging
28from bb import data
29
30logger = logging.getLogger("BitBake")
31parselog = logging.getLogger("BitBake.Parsing")
32
33class ConfigParameters(object):
34 def __init__(self):
35 self.options, targets = self.parseCommandLine()
36 self.environment = self.parseEnvironment()
37
38 self.options.pkgs_to_build = targets or []
39
40 self.options.tracking = False
41 if self.options.show_environment:
42 self.options.tracking = True
43
44 for key, val in self.options.__dict__.items():
45 setattr(self, key, val)
46
47 def parseCommandLine(self):
48 raise Exception("Caller must implement commandline option parsing")
49
50 def parseEnvironment(self):
51 return os.environ.copy()
52
53class CookerConfiguration(object):
54 """
55 Manages build options and configurations for one run
56 """
57
58 def __init__(self):
59 self.debug_domains = []
60 self.extra_assume_provided = []
61 self.prefile = []
62 self.postfile = []
63 self.debug = 0
64 self.pkgs_to_build = []
65
66 def setConfigParameters(self, parameters):
67 self.params = parameters
68 for key, val in parameters.options.__dict__.items():
69 setattr(self, key, val)
70
71 def setServerRegIdleCallback(self, srcb):
72 self.server_register_idlecallback = srcb
73