summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cookerdata.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-20 22:54:41 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-22 12:10:13 +0100
commitf0930c8d63cc9fd8ead759b3230ab708fffa6ed4 (patch)
treed589dce4ac5f1fb34ee6d21fc9889a9d6a48b81d /bitbake/lib/bb/cookerdata.py
parentf242f5060bbc62815b6d5a245c1a9bf18f23675f (diff)
downloadpoky-f0930c8d63cc9fd8ead759b3230ab708fffa6ed4.tar.gz
bitbake: cooker: Move commandline parsing back into the UI/cookerdata
Building up a set of actions for the server is tricky since we depend upon the commandline but fall back to values from the datastore. We should be able to build a datastore without a commandline and vice versa. Ultimately the UI should send the commands to the server. This patch amounts to code rearranging, moving the heavy lifting to the UI, though a helper in the configuration option. This will need further cleanup/tweaking but this should be the only update needed to the UIs. The code now queries the server for any missing data should it need to. This code allows various knowledge of configuration variables to move to the UI side only, partcularly pkgs_to_build but also all the command specifiers. It should also be possible to move cmd eventually, I'm just unsure if any callers call the commands expecting this to default to something sane right now. (Bitbake rev: 2dbbb1d51dafd4451fef8fe16f095bcd4b8f1177) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/cookerdata.py')
-rw-r--r--bitbake/lib/bb/cookerdata.py57
1 files changed, 56 insertions, 1 deletions
diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py
index 2c3275ac65..3c2469ef87 100644
--- a/bitbake/lib/bb/cookerdata.py
+++ b/bitbake/lib/bb/cookerdata.py
@@ -50,6 +50,61 @@ class ConfigParameters(object):
50 def parseEnvironment(self): 50 def parseEnvironment(self):
51 return os.environ.copy() 51 return os.environ.copy()
52 52
53 def updateFromServer(self, server):
54 if not self.options.cmd:
55 defaulttask, error = server.runCommand(["getVariable", "BB_DEFAULT_TASK"])
56 if error:
57 raise Exception("Unable to get the value of BB_DEFAULT_TASK from the server: %s" % error)
58 self.options.cmd = defaulttask or "build"
59 _, error = server.runCommand(["setConfig", "cmd", self.options.cmd])
60 if error:
61 raise Exception("Unable to set configuration option 'cmd' on the server: %s" % error)
62
63 if not self.options.pkgs_to_build:
64 bbpkgs, error = server.runCommand(["getVariable", "BBPKGS"])
65 if error:
66 raise Exception("Unable to get the value of BBPKGS from the server: %s" % error)
67 if bbpkgs:
68 self.options.pkgs_to_build.extend(bbpkgs.split())
69
70 def parseActions(self):
71 # Parse any commandline into actions
72 action = {'action':None, 'msg':None}
73 if self.options.show_environment:
74 if 'world' in self.options.pkgs_to_build:
75 action['msg'] = "'world' is not a valid target for --environment."
76 elif 'universe' in self.options.pkgs_to_build:
77 action['msg'] = "'universe' is not a valid target for --environment."
78 elif len(self.options.pkgs_to_build) > 1:
79 action['msg'] = "Only one target can be used with the --environment option."
80 elif self.options.buildfile and len(self.options.pkgs_to_build) > 0:
81 action['msg'] = "No target should be used with the --environment and --buildfile options."
82 elif len(self.options.pkgs_to_build) > 0:
83 action['action'] = ["showEnvironmentTarget", self.options.pkgs_to_build]
84 else:
85 action['action'] = ["showEnvironment", self.options.buildfile]
86 elif self.options.buildfile is not None:
87 action['action'] = ["buildFile", self.options.buildfile, self.options.cmd]
88 elif self.options.revisions_changed:
89 action['action'] = ["compareRevisions"]
90 elif self.options.show_versions:
91 action['action'] = ["showVersions"]
92 elif self.options.parse_only:
93 action['action'] = ["parseFiles"]
94 elif self.options.dot_graph:
95 if self.options.pkgs_to_build:
96 action['action'] = ["generateDotGraph", self.options.pkgs_to_build, self.options.cmd]
97 else:
98 action['msg'] = "Please specify a package name for dependency graph generation."
99 else:
100 if self.options.pkgs_to_build:
101 action['action'] = ["buildTargets", self.options.pkgs_to_build, self.options.cmd]
102 else:
103 #action['msg'] = "Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information."
104 action = None
105 self.options.initialaction = action
106 return action
107
53class CookerConfiguration(object): 108class CookerConfiguration(object):
54 """ 109 """
55 Manages build options and configurations for one run 110 Manages build options and configurations for one run
@@ -61,7 +116,7 @@ class CookerConfiguration(object):
61 self.prefile = [] 116 self.prefile = []
62 self.postfile = [] 117 self.postfile = []
63 self.debug = 0 118 self.debug = 0
64 self.pkgs_to_build = [] 119 self.cmd = None
65 120
66 def setConfigParameters(self, parameters): 121 def setConfigParameters(self, parameters):
67 self.params = parameters 122 self.params = parameters