summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
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/lib
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/lib')
-rw-r--r--bitbake/lib/bb/command.py2
-rw-r--r--bitbake/lib/bb/cooker.py11
-rw-r--r--bitbake/lib/bb/cookerdata.py73
3 files changed, 79 insertions, 7 deletions
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