summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorLianhao Lu <lianhao.lu@intel.com>2011-06-14 15:12:16 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-07-08 17:38:42 +0100
commit4fadc30b92d42523fee013c168d47bc93dfe4fbd (patch)
treee37df0b79a8d6e20fd8b93bf065c9cd7bb033a5a /bitbake/lib
parent18ce7e2ef3a3b65bc0abca4f0135005249e6d2ca (diff)
downloadpoky-4fadc30b92d42523fee013c168d47bc93dfe4fbd.tar.gz
bitbake cooker/ui: handle cmd line parsing result by individual UI.
Changed the return result of "getCmdLineAction" to a dictionary {'action', 'msg'} to allow the individual UI decide how to handle the cmd line parsing result. (Bitbake rev: 521909d1350a415d19516aa1710041e30950c7cc) Signed-off-by: Lianhao Lu <lianhao.lu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/cooker.py34
-rw-r--r--bitbake/lib/bb/ui/depexp.py7
-rw-r--r--bitbake/lib/bb/ui/goggle.py6
-rw-r--r--bitbake/lib/bb/ui/knotty.py6
-rw-r--r--bitbake/lib/bb/ui/ncurses.py6
5 files changed, 36 insertions, 23 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index ecf20dcf68..1f6e093efb 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -178,41 +178,39 @@ class BBCooker:
178 178
179 def parseCommandLine(self): 179 def parseCommandLine(self):
180 # Parse any commandline into actions 180 # Parse any commandline into actions
181 self.commandlineAction = {'action':None, 'msg':None}
181 if self.configuration.show_environment: 182 if self.configuration.show_environment:
182 self.commandlineAction = None
183
184 if 'world' in self.configuration.pkgs_to_build: 183 if 'world' in self.configuration.pkgs_to_build:
185 buildlog.error("'world' is not a valid target for --environment.") 184 self.commandlineAction['msg'] = "'world' is not a valid target for --environment."
186 if 'universe' in self.configuration.pkgs_to_build: 185 elif 'universe' in self.configuration.pkgs_to_build:
187 buildlog.error("'universe' is not a valid target for --environment.") 186 self.commandlineAction['msg'] = "'universe' is not a valid target for --environment."
188 elif len(self.configuration.pkgs_to_build) > 1: 187 elif len(self.configuration.pkgs_to_build) > 1:
189 buildlog.error("Only one target can be used with the --environment option.") 188 self.commandlineAction['msg'] = "Only one target can be used with the --environment option."
190 elif self.configuration.buildfile and len(self.configuration.pkgs_to_build) > 0: 189 elif self.configuration.buildfile and len(self.configuration.pkgs_to_build) > 0:
191 buildlog.error("No target should be used with the --environment and --buildfile options.") 190 self.commandlineAction['msg'] = "No target should be used with the --environment and --buildfile options."
192 elif len(self.configuration.pkgs_to_build) > 0: 191 elif len(self.configuration.pkgs_to_build) > 0:
193 self.commandlineAction = ["showEnvironmentTarget", self.configuration.pkgs_to_build] 192 self.commandlineAction['action'] = ["showEnvironmentTarget", self.configuration.pkgs_to_build]
194 else: 193 else:
195 self.commandlineAction = ["showEnvironment", self.configuration.buildfile] 194 self.commandlineAction['action'] = ["showEnvironment", self.configuration.buildfile]
196 elif self.configuration.buildfile is not None: 195 elif self.configuration.buildfile is not None:
197 self.commandlineAction = ["buildFile", self.configuration.buildfile, self.configuration.cmd] 196 self.commandlineAction['action'] = ["buildFile", self.configuration.buildfile, self.configuration.cmd]
198 elif self.configuration.revisions_changed: 197 elif self.configuration.revisions_changed:
199 self.commandlineAction = ["compareRevisions"] 198 self.commandlineAction['action'] = ["compareRevisions"]
200 elif self.configuration.show_versions: 199 elif self.configuration.show_versions:
201 self.commandlineAction = ["showVersions"] 200 self.commandlineAction['action'] = ["showVersions"]
202 elif self.configuration.parse_only: 201 elif self.configuration.parse_only:
203 self.commandlineAction = ["parseFiles"] 202 self.commandlineAction['action'] = ["parseFiles"]
204 elif self.configuration.dot_graph: 203 elif self.configuration.dot_graph:
205 if self.configuration.pkgs_to_build: 204 if self.configuration.pkgs_to_build:
206 self.commandlineAction = ["generateDotGraph", self.configuration.pkgs_to_build, self.configuration.cmd] 205 self.commandlineAction['action'] = ["generateDotGraph", self.configuration.pkgs_to_build, self.configuration.cmd]
207 else: 206 else:
208 self.commandlineAction = None 207 self.commandlineAction['msg'] = "Please specify a package name for dependency graph generation."
209 buildlog.error("Please specify a package name for dependency graph generation.")
210 else: 208 else:
211 if self.configuration.pkgs_to_build: 209 if self.configuration.pkgs_to_build:
212 self.commandlineAction = ["buildTargets", self.configuration.pkgs_to_build, self.configuration.cmd] 210 self.commandlineAction['action'] = ["buildTargets", self.configuration.pkgs_to_build, self.configuration.cmd]
213 else: 211 else:
212 #self.commandlineAction['msg'] = "Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information."
214 self.commandlineAction = None 213 self.commandlineAction = None
215 buildlog.error("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
216 214
217 def runCommands(self, server, data, abort): 215 def runCommands(self, server, data, abort):
218 """ 216 """
diff --git a/bitbake/lib/bb/ui/depexp.py b/bitbake/lib/bb/ui/depexp.py
index dcf7e6e2f3..b62adbf851 100644
--- a/bitbake/lib/bb/ui/depexp.py
+++ b/bitbake/lib/bb/ui/depexp.py
@@ -199,10 +199,13 @@ class gtkthread(threading.Thread):
199def main(server, eventHandler): 199def main(server, eventHandler):
200 try: 200 try:
201 cmdline = server.runCommand(["getCmdLineAction"]) 201 cmdline = server.runCommand(["getCmdLineAction"])
202 if not cmdline or cmdline[0] != "generateDotGraph": 202 if cmdline and not cmdline['action']:
203 print(cmdline['msg'])
204 return
205 elif not cmdline or (cmdline['action'] and cmdline['action'][0] != "generateDotGraph"):
203 print("This UI is only compatible with the -g option") 206 print("This UI is only compatible with the -g option")
204 return 207 return
205 ret = server.runCommand(["generateDepTreeEvent", cmdline[1], cmdline[2]]) 208 ret = server.runCommand(["generateDepTreeEvent", cmdline['action'][1], cmdline['action'][2]])
206 if ret != True: 209 if ret != True:
207 print("Couldn't run command! %s" % ret) 210 print("Couldn't run command! %s" % ret)
208 return 211 return
diff --git a/bitbake/lib/bb/ui/goggle.py b/bitbake/lib/bb/ui/goggle.py
index bd03d31983..b2fd2741aa 100644
--- a/bitbake/lib/bb/ui/goggle.py
+++ b/bitbake/lib/bb/ui/goggle.py
@@ -82,8 +82,12 @@ def main (server, eventHandler):
82 try: 82 try:
83 cmdline = server.runCommand(["getCmdLineAction"]) 83 cmdline = server.runCommand(["getCmdLineAction"])
84 if not cmdline: 84 if not cmdline:
85 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
85 return 1 86 return 1
86 ret = server.runCommand(cmdline) 87 elif not cmdline['action']:
88 print(cmdline['msg'])
89 return 1
90 ret = server.runCommand(cmdline['action'])
87 if ret != True: 91 if ret != True:
88 print("Couldn't get default commandline! %s" % ret) 92 print("Couldn't get default commandline! %s" % ret)
89 return 1 93 return 1
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 997eb3fe89..a4deb468bb 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -80,8 +80,12 @@ def main(server, eventHandler):
80 try: 80 try:
81 cmdline = server.runCommand(["getCmdLineAction"]) 81 cmdline = server.runCommand(["getCmdLineAction"])
82 if not cmdline: 82 if not cmdline:
83 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
83 return 1 84 return 1
84 ret = server.runCommand(cmdline) 85 elif not cmdline['action']:
86 print(cmdline['msg'])
87 return 1
88 ret = server.runCommand(cmdline['action'])
85 if ret != True: 89 if ret != True:
86 print("Couldn't get default commandline! %s" % ret) 90 print("Couldn't get default commandline! %s" % ret)
87 return 1 91 return 1
diff --git a/bitbake/lib/bb/ui/ncurses.py b/bitbake/lib/bb/ui/ncurses.py
index 469f1b7309..8684697aa2 100644
--- a/bitbake/lib/bb/ui/ncurses.py
+++ b/bitbake/lib/bb/ui/ncurses.py
@@ -232,8 +232,12 @@ class NCursesUI:
232 try: 232 try:
233 cmdline = server.runCommand(["getCmdLineAction"]) 233 cmdline = server.runCommand(["getCmdLineAction"])
234 if not cmdline: 234 if not cmdline:
235 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
235 return 236 return
236 ret = server.runCommand(cmdline) 237 elif not cmdline['action']:
238 print(cmdline['msg'])
239 return
240 ret = server.runCommand(cmdline['action'])
237 if ret != True: 241 if ret != True:
238 print("Couldn't get default commandlind! %s" % ret) 242 print("Couldn't get default commandlind! %s" % ret)
239 return 243 return