command.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. """
  2. BitBake 'Command' module
  3. Provide an interface to interact with the bitbake server through 'commands'
  4. """
  5. # Copyright (C) 2006-2007 Richard Purdie
  6. #
  7. # SPDX-License-Identifier: GPL-2.0-only
  8. #
  9. """
  10. The bitbake server takes 'commands' from its UI/commandline.
  11. Commands are either synchronous or asynchronous.
  12. Async commands return data to the client in the form of events.
  13. Sync commands must only return data through the function return value
  14. and must not trigger events, directly or indirectly.
  15. Commands are queued in a CommandQueue
  16. """
  17. from collections import OrderedDict, defaultdict
  18. import bb.event
  19. import bb.cooker
  20. import bb.remotedata
  21. class DataStoreConnectionHandle(object):
  22. def __init__(self, dsindex=0):
  23. self.dsindex = dsindex
  24. class CommandCompleted(bb.event.Event):
  25. pass
  26. class CommandExit(bb.event.Event):
  27. def __init__(self, exitcode):
  28. bb.event.Event.__init__(self)
  29. self.exitcode = int(exitcode)
  30. class CommandFailed(CommandExit):
  31. def __init__(self, message):
  32. self.error = message
  33. CommandExit.__init__(self, 1)
  34. def __str__(self):
  35. return "Command execution failed: %s" % self.error
  36. class CommandError(Exception):
  37. pass
  38. class Command:
  39. """
  40. A queue of asynchronous commands for bitbake
  41. """
  42. def __init__(self, cooker):
  43. self.cooker = cooker
  44. self.cmds_sync = CommandsSync()
  45. self.cmds_async = CommandsAsync()
  46. self.remotedatastores = bb.remotedata.RemoteDatastores(cooker)
  47. # FIXME Add lock for this
  48. self.currentAsyncCommand = None
  49. def runCommand(self, commandline, ro_only = False):
  50. command = commandline.pop(0)
  51. if hasattr(CommandsSync, command):
  52. # Can run synchronous commands straight away
  53. command_method = getattr(self.cmds_sync, command)
  54. if ro_only:
  55. if not hasattr(command_method, 'readonly') or not getattr(command_method, 'readonly'):
  56. return None, "Not able to execute not readonly commands in readonly mode"
  57. try:
  58. self.cooker.process_inotify_updates()
  59. if getattr(command_method, 'needconfig', True):
  60. self.cooker.updateCacheSync()
  61. result = command_method(self, commandline)
  62. except CommandError as exc:
  63. return None, exc.args[0]
  64. except (Exception, SystemExit):
  65. import traceback
  66. return None, traceback.format_exc()
  67. else:
  68. return result, None
  69. if self.currentAsyncCommand is not None:
  70. return None, "Busy (%s in progress)" % self.currentAsyncCommand[0]
  71. if command not in CommandsAsync.__dict__:
  72. return None, "No such command"
  73. self.currentAsyncCommand = (command, commandline)
  74. self.cooker.configuration.server_register_idlecallback(self.cooker.runCommands, self.cooker)
  75. return True, None
  76. def runAsyncCommand(self):
  77. try:
  78. self.cooker.process_inotify_updates()
  79. if self.cooker.state in (bb.cooker.state.error, bb.cooker.state.shutdown, bb.cooker.state.forceshutdown):
  80. # updateCache will trigger a shutdown of the parser
  81. # and then raise BBHandledException triggering an exit
  82. self.cooker.updateCache()
  83. return False
  84. if self.currentAsyncCommand is not None:
  85. (command, options) = self.currentAsyncCommand
  86. commandmethod = getattr(CommandsAsync, command)
  87. needcache = getattr( commandmethod, "needcache" )
  88. if needcache and self.cooker.state != bb.cooker.state.running:
  89. self.cooker.updateCache()
  90. return True
  91. else:
  92. commandmethod(self.cmds_async, self, options)
  93. return False
  94. else:
  95. return False
  96. except KeyboardInterrupt as exc:
  97. self.finishAsyncCommand("Interrupted")
  98. return False
  99. except SystemExit as exc:
  100. arg = exc.args[0]
  101. if isinstance(arg, str):
  102. self.finishAsyncCommand(arg)
  103. else:
  104. self.finishAsyncCommand("Exited with %s" % arg)
  105. return False
  106. except Exception as exc:
  107. import traceback
  108. if isinstance(exc, bb.BBHandledException):
  109. self.finishAsyncCommand("")
  110. else:
  111. self.finishAsyncCommand(traceback.format_exc())
  112. return False
  113. def finishAsyncCommand(self, msg=None, code=None):
  114. if msg or msg == "":
  115. bb.event.fire(CommandFailed(msg), self.cooker.data)
  116. elif code:
  117. bb.event.fire(CommandExit(code), self.cooker.data)
  118. else:
  119. bb.event.fire(CommandCompleted(), self.cooker.data)
  120. self.currentAsyncCommand = None
  121. self.cooker.finishcommand()
  122. def reset(self):
  123. self.remotedatastores = bb.remotedata.RemoteDatastores(self.cooker)
  124. def split_mc_pn(pn):
  125. if pn.startswith("multiconfig:"):
  126. _, mc, pn = pn.split(":", 2)
  127. return (mc, pn)
  128. return ('', pn)
  129. class CommandsSync:
  130. """
  131. A class of synchronous commands
  132. These should run quickly so as not to hurt interactive performance.
  133. These must not influence any running synchronous command.
  134. """
  135. def stateShutdown(self, command, params):
  136. """
  137. Trigger cooker 'shutdown' mode
  138. """
  139. command.cooker.shutdown(False)
  140. def stateForceShutdown(self, command, params):
  141. """
  142. Stop the cooker
  143. """
  144. command.cooker.shutdown(True)
  145. def getAllKeysWithFlags(self, command, params):
  146. """
  147. Returns a dump of the global state. Call with
  148. variable flags to be retrieved as params.
  149. """
  150. flaglist = params[0]
  151. return command.cooker.getAllKeysWithFlags(flaglist)
  152. getAllKeysWithFlags.readonly = True
  153. def getVariable(self, command, params):
  154. """
  155. Read the value of a variable from data
  156. """
  157. varname = params[0]
  158. expand = True
  159. if len(params) > 1:
  160. expand = (params[1] == "True")
  161. return command.cooker.data.getVar(varname, expand)
  162. getVariable.readonly = True
  163. def setVariable(self, command, params):
  164. """
  165. Set the value of variable in data
  166. """
  167. varname = params[0]
  168. value = str(params[1])
  169. command.cooker.extraconfigdata[varname] = value
  170. command.cooker.data.setVar(varname, value)
  171. def getSetVariable(self, command, params):
  172. """
  173. Read the value of a variable from data and set it into the datastore
  174. which effectively expands and locks the value.
  175. """
  176. varname = params[0]
  177. result = self.getVariable(command, params)
  178. command.cooker.data.setVar(varname, result)
  179. return result
  180. def setConfig(self, command, params):
  181. """
  182. Set the value of variable in configuration
  183. """
  184. varname = params[0]
  185. value = str(params[1])
  186. setattr(command.cooker.configuration, varname, value)
  187. def enableDataTracking(self, command, params):
  188. """
  189. Enable history tracking for variables
  190. """
  191. command.cooker.enableDataTracking()
  192. def disableDataTracking(self, command, params):
  193. """
  194. Disable history tracking for variables
  195. """
  196. command.cooker.disableDataTracking()
  197. def setPrePostConfFiles(self, command, params):
  198. prefiles = params[0].split()
  199. postfiles = params[1].split()
  200. command.cooker.configuration.prefile = prefiles
  201. command.cooker.configuration.postfile = postfiles
  202. setPrePostConfFiles.needconfig = False
  203. def matchFile(self, command, params):
  204. fMatch = params[0]
  205. return command.cooker.matchFile(fMatch)
  206. matchFile.needconfig = False
  207. def getUIHandlerNum(self, command, params):
  208. return bb.event.get_uihandler()
  209. getUIHandlerNum.needconfig = False
  210. getUIHandlerNum.readonly = True
  211. def setEventMask(self, command, params):
  212. handlerNum = params[0]
  213. llevel = params[1]
  214. debug_domains = params[2]
  215. mask = params[3]
  216. return bb.event.set_UIHmask(handlerNum, llevel, debug_domains, mask)
  217. setEventMask.needconfig = False
  218. setEventMask.readonly = True
  219. def setFeatures(self, command, params):
  220. """
  221. Set the cooker features to include the passed list of features
  222. """
  223. features = params[0]
  224. command.cooker.setFeatures(features)
  225. setFeatures.needconfig = False
  226. # although we change the internal state of the cooker, this is transparent since
  227. # we always take and leave the cooker in state.initial
  228. setFeatures.readonly = True
  229. def updateConfig(self, command, params):
  230. options = params[0]
  231. environment = params[1]
  232. cmdline = params[2]
  233. command.cooker.updateConfigOpts(options, environment, cmdline)
  234. updateConfig.needconfig = False
  235. def parseConfiguration(self, command, params):
  236. """Instruct bitbake to parse its configuration
  237. NOTE: it is only necessary to call this if you aren't calling any normal action
  238. (otherwise parsing is taken care of automatically)
  239. """
  240. command.cooker.parseConfiguration()
  241. parseConfiguration.needconfig = False
  242. def getLayerPriorities(self, command, params):
  243. command.cooker.parseConfiguration()
  244. ret = []
  245. # regex objects cannot be marshalled by xmlrpc
  246. for collection, pattern, regex, pri in command.cooker.bbfile_config_priorities:
  247. ret.append((collection, pattern, regex.pattern, pri))
  248. return ret
  249. getLayerPriorities.readonly = True
  250. def getRecipes(self, command, params):
  251. try:
  252. mc = params[0]
  253. except IndexError:
  254. mc = ''
  255. return list(command.cooker.recipecaches[mc].pkg_pn.items())
  256. getRecipes.readonly = True
  257. def getRecipeDepends(self, command, params):
  258. try:
  259. mc = params[0]
  260. except IndexError:
  261. mc = ''
  262. return list(command.cooker.recipecaches[mc].deps.items())
  263. getRecipeDepends.readonly = True
  264. def getRecipeVersions(self, command, params):
  265. try:
  266. mc = params[0]
  267. except IndexError:
  268. mc = ''
  269. return command.cooker.recipecaches[mc].pkg_pepvpr
  270. getRecipeVersions.readonly = True
  271. def getRecipeProvides(self, command, params):
  272. try:
  273. mc = params[0]
  274. except IndexError:
  275. mc = ''
  276. return command.cooker.recipecaches[mc].fn_provides
  277. getRecipeProvides.readonly = True
  278. def getRecipePackages(self, command, params):
  279. try:
  280. mc = params[0]
  281. except IndexError:
  282. mc = ''
  283. return command.cooker.recipecaches[mc].packages
  284. getRecipePackages.readonly = True
  285. def getRecipePackagesDynamic(self, command, params):
  286. try:
  287. mc = params[0]
  288. except IndexError:
  289. mc = ''
  290. return command.cooker.recipecaches[mc].packages_dynamic
  291. getRecipePackagesDynamic.readonly = True
  292. def getRProviders(self, command, params):
  293. try:
  294. mc = params[0]
  295. except IndexError:
  296. mc = ''
  297. return command.cooker.recipecaches[mc].rproviders
  298. getRProviders.readonly = True
  299. def getRuntimeDepends(self, command, params):
  300. ret = []
  301. try:
  302. mc = params[0]
  303. except IndexError:
  304. mc = ''
  305. rundeps = command.cooker.recipecaches[mc].rundeps
  306. for key, value in rundeps.items():
  307. if isinstance(value, defaultdict):
  308. value = dict(value)
  309. ret.append((key, value))
  310. return ret
  311. getRuntimeDepends.readonly = True
  312. def getRuntimeRecommends(self, command, params):
  313. ret = []
  314. try:
  315. mc = params[0]
  316. except IndexError:
  317. mc = ''
  318. runrecs = command.cooker.recipecaches[mc].runrecs
  319. for key, value in runrecs.items():
  320. if isinstance(value, defaultdict):
  321. value = dict(value)
  322. ret.append((key, value))
  323. return ret
  324. getRuntimeRecommends.readonly = True
  325. def getRecipeInherits(self, command, params):
  326. try:
  327. mc = params[0]
  328. except IndexError:
  329. mc = ''
  330. return command.cooker.recipecaches[mc].inherits
  331. getRecipeInherits.readonly = True
  332. def getBbFilePriority(self, command, params):
  333. try:
  334. mc = params[0]
  335. except IndexError:
  336. mc = ''
  337. return command.cooker.recipecaches[mc].bbfile_priority
  338. getBbFilePriority.readonly = True
  339. def getDefaultPreference(self, command, params):
  340. try:
  341. mc = params[0]
  342. except IndexError:
  343. mc = ''
  344. return command.cooker.recipecaches[mc].pkg_dp
  345. getDefaultPreference.readonly = True
  346. def getSkippedRecipes(self, command, params):
  347. # Return list sorted by reverse priority order
  348. import bb.cache
  349. skipdict = OrderedDict(sorted(command.cooker.skiplist.items(),
  350. key=lambda x: (-command.cooker.collection.calc_bbfile_priority(bb.cache.virtualfn2realfn(x[0])[0]), x[0])))
  351. return list(skipdict.items())
  352. getSkippedRecipes.readonly = True
  353. def getOverlayedRecipes(self, command, params):
  354. return list(command.cooker.collection.overlayed.items())
  355. getOverlayedRecipes.readonly = True
  356. def getFileAppends(self, command, params):
  357. fn = params[0]
  358. return command.cooker.collection.get_file_appends(fn)
  359. getFileAppends.readonly = True
  360. def getAllAppends(self, command, params):
  361. return command.cooker.collection.bbappends
  362. getAllAppends.readonly = True
  363. def findProviders(self, command, params):
  364. return command.cooker.findProviders()
  365. findProviders.readonly = True
  366. def findBestProvider(self, command, params):
  367. (mc, pn) = split_mc_pn(params[0])
  368. return command.cooker.findBestProvider(pn, mc)
  369. findBestProvider.readonly = True
  370. def allProviders(self, command, params):
  371. try:
  372. mc = params[0]
  373. except IndexError:
  374. mc = ''
  375. return list(bb.providers.allProviders(command.cooker.recipecaches[mc]).items())
  376. allProviders.readonly = True
  377. def getRuntimeProviders(self, command, params):
  378. rprovide = params[0]
  379. try:
  380. mc = params[1]
  381. except IndexError:
  382. mc = ''
  383. all_p = bb.providers.getRuntimeProviders(command.cooker.recipecaches[mc], rprovide)
  384. if all_p:
  385. best = bb.providers.filterProvidersRunTime(all_p, rprovide,
  386. command.cooker.data,
  387. command.cooker.recipecaches[mc])[0][0]
  388. else:
  389. best = None
  390. return all_p, best
  391. getRuntimeProviders.readonly = True
  392. def dataStoreConnectorFindVar(self, command, params):
  393. dsindex = params[0]
  394. name = params[1]
  395. datastore = command.remotedatastores[dsindex]
  396. value, overridedata = datastore._findVar(name)
  397. if value:
  398. content = value.get('_content', None)
  399. if isinstance(content, bb.data_smart.DataSmart):
  400. # Value is a datastore (e.g. BB_ORIGENV) - need to handle this carefully
  401. idx = command.remotedatastores.check_store(content, True)
  402. return {'_content': DataStoreConnectionHandle(idx),
  403. '_connector_origtype': 'DataStoreConnectionHandle',
  404. '_connector_overrides': overridedata}
  405. elif isinstance(content, set):
  406. return {'_content': list(content),
  407. '_connector_origtype': 'set',
  408. '_connector_overrides': overridedata}
  409. else:
  410. value['_connector_overrides'] = overridedata
  411. else:
  412. value = {}
  413. value['_connector_overrides'] = overridedata
  414. return value
  415. dataStoreConnectorFindVar.readonly = True
  416. def dataStoreConnectorGetKeys(self, command, params):
  417. dsindex = params[0]
  418. datastore = command.remotedatastores[dsindex]
  419. return list(datastore.keys())
  420. dataStoreConnectorGetKeys.readonly = True
  421. def dataStoreConnectorGetVarHistory(self, command, params):
  422. dsindex = params[0]
  423. name = params[1]
  424. datastore = command.remotedatastores[dsindex]
  425. return datastore.varhistory.variable(name)
  426. dataStoreConnectorGetVarHistory.readonly = True
  427. def dataStoreConnectorExpandPythonRef(self, command, params):
  428. config_data_dict = params[0]
  429. varname = params[1]
  430. expr = params[2]
  431. config_data = command.remotedatastores.receive_datastore(config_data_dict)
  432. varparse = bb.data_smart.VariableParse(varname, config_data)
  433. return varparse.python_sub(expr)
  434. def dataStoreConnectorRelease(self, command, params):
  435. dsindex = params[0]
  436. if dsindex <= 0:
  437. raise CommandError('dataStoreConnectorRelease: invalid index %d' % dsindex)
  438. command.remotedatastores.release(dsindex)
  439. def dataStoreConnectorSetVarFlag(self, command, params):
  440. dsindex = params[0]
  441. name = params[1]
  442. flag = params[2]
  443. value = params[3]
  444. datastore = command.remotedatastores[dsindex]
  445. datastore.setVarFlag(name, flag, value)
  446. def dataStoreConnectorDelVar(self, command, params):
  447. dsindex = params[0]
  448. name = params[1]
  449. datastore = command.remotedatastores[dsindex]
  450. if len(params) > 2:
  451. flag = params[2]
  452. datastore.delVarFlag(name, flag)
  453. else:
  454. datastore.delVar(name)
  455. def dataStoreConnectorRenameVar(self, command, params):
  456. dsindex = params[0]
  457. name = params[1]
  458. newname = params[2]
  459. datastore = command.remotedatastores[dsindex]
  460. datastore.renameVar(name, newname)
  461. def parseRecipeFile(self, command, params):
  462. """
  463. Parse the specified recipe file (with or without bbappends)
  464. and return a datastore object representing the environment
  465. for the recipe.
  466. """
  467. fn = params[0]
  468. appends = params[1]
  469. appendlist = params[2]
  470. if len(params) > 3:
  471. config_data_dict = params[3]
  472. config_data = command.remotedatastores.receive_datastore(config_data_dict)
  473. else:
  474. config_data = None
  475. if appends:
  476. if appendlist is not None:
  477. appendfiles = appendlist
  478. else:
  479. appendfiles = command.cooker.collection.get_file_appends(fn)
  480. else:
  481. appendfiles = []
  482. # We are calling bb.cache locally here rather than on the server,
  483. # but that's OK because it doesn't actually need anything from
  484. # the server barring the global datastore (which we have a remote
  485. # version of)
  486. if config_data:
  487. # We have to use a different function here if we're passing in a datastore
  488. # NOTE: we took a copy above, so we don't do it here again
  489. envdata = bb.cache.parse_recipe(config_data, fn, appendfiles)['']
  490. else:
  491. # Use the standard path
  492. parser = bb.cache.NoCache(command.cooker.databuilder)
  493. envdata = parser.loadDataFull(fn, appendfiles)
  494. idx = command.remotedatastores.store(envdata)
  495. return DataStoreConnectionHandle(idx)
  496. parseRecipeFile.readonly = True
  497. class CommandsAsync:
  498. """
  499. A class of asynchronous commands
  500. These functions communicate via generated events.
  501. Any function that requires metadata parsing should be here.
  502. """
  503. def buildFile(self, command, params):
  504. """
  505. Build a single specified .bb file
  506. """
  507. bfile = params[0]
  508. task = params[1]
  509. if len(params) > 2:
  510. internal = params[2]
  511. else:
  512. internal = False
  513. if internal:
  514. command.cooker.buildFileInternal(bfile, task, fireevents=False, quietlog=True)
  515. else:
  516. command.cooker.buildFile(bfile, task)
  517. buildFile.needcache = False
  518. def buildTargets(self, command, params):
  519. """
  520. Build a set of targets
  521. """
  522. pkgs_to_build = params[0]
  523. task = params[1]
  524. command.cooker.buildTargets(pkgs_to_build, task)
  525. buildTargets.needcache = True
  526. def generateDepTreeEvent(self, command, params):
  527. """
  528. Generate an event containing the dependency information
  529. """
  530. pkgs_to_build = params[0]
  531. task = params[1]
  532. command.cooker.generateDepTreeEvent(pkgs_to_build, task)
  533. command.finishAsyncCommand()
  534. generateDepTreeEvent.needcache = True
  535. def generateDotGraph(self, command, params):
  536. """
  537. Dump dependency information to disk as .dot files
  538. """
  539. pkgs_to_build = params[0]
  540. task = params[1]
  541. command.cooker.generateDotGraphFiles(pkgs_to_build, task)
  542. command.finishAsyncCommand()
  543. generateDotGraph.needcache = True
  544. def generateTargetsTree(self, command, params):
  545. """
  546. Generate a tree of buildable targets.
  547. If klass is provided ensure all recipes that inherit the class are
  548. included in the package list.
  549. If pkg_list provided use that list (plus any extras brought in by
  550. klass) rather than generating a tree for all packages.
  551. """
  552. klass = params[0]
  553. pkg_list = params[1]
  554. command.cooker.generateTargetsTree(klass, pkg_list)
  555. command.finishAsyncCommand()
  556. generateTargetsTree.needcache = True
  557. def findConfigFiles(self, command, params):
  558. """
  559. Find config files which provide appropriate values
  560. for the passed configuration variable. i.e. MACHINE
  561. """
  562. varname = params[0]
  563. command.cooker.findConfigFiles(varname)
  564. command.finishAsyncCommand()
  565. findConfigFiles.needcache = False
  566. def findFilesMatchingInDir(self, command, params):
  567. """
  568. Find implementation files matching the specified pattern
  569. in the requested subdirectory of a BBPATH
  570. """
  571. pattern = params[0]
  572. directory = params[1]
  573. command.cooker.findFilesMatchingInDir(pattern, directory)
  574. command.finishAsyncCommand()
  575. findFilesMatchingInDir.needcache = False
  576. def findConfigFilePath(self, command, params):
  577. """
  578. Find the path of the requested configuration file
  579. """
  580. configfile = params[0]
  581. command.cooker.findConfigFilePath(configfile)
  582. command.finishAsyncCommand()
  583. findConfigFilePath.needcache = False
  584. def showVersions(self, command, params):
  585. """
  586. Show the currently selected versions
  587. """
  588. command.cooker.showVersions()
  589. command.finishAsyncCommand()
  590. showVersions.needcache = True
  591. def showEnvironmentTarget(self, command, params):
  592. """
  593. Print the environment of a target recipe
  594. (needs the cache to work out which recipe to use)
  595. """
  596. pkg = params[0]
  597. command.cooker.showEnvironment(None, pkg)
  598. command.finishAsyncCommand()
  599. showEnvironmentTarget.needcache = True
  600. def showEnvironment(self, command, params):
  601. """
  602. Print the standard environment
  603. or if specified the environment for a specified recipe
  604. """
  605. bfile = params[0]
  606. command.cooker.showEnvironment(bfile)
  607. command.finishAsyncCommand()
  608. showEnvironment.needcache = False
  609. def parseFiles(self, command, params):
  610. """
  611. Parse the .bb files
  612. """
  613. command.cooker.updateCache()
  614. command.finishAsyncCommand()
  615. parseFiles.needcache = True
  616. def compareRevisions(self, command, params):
  617. """
  618. Parse the .bb files
  619. """
  620. if bb.fetch.fetcher_compare_revisions(command.cooker.data):
  621. command.finishAsyncCommand(code=1)
  622. else:
  623. command.finishAsyncCommand()
  624. compareRevisions.needcache = True
  625. def triggerEvent(self, command, params):
  626. """
  627. Trigger a certain event
  628. """
  629. event = params[0]
  630. bb.event.fire(eval(event), command.cooker.data)
  631. command.currentAsyncCommand = None
  632. triggerEvent.needcache = False
  633. def resetCooker(self, command, params):
  634. """
  635. Reset the cooker to its initial state, thus forcing a reparse for
  636. any async command that has the needcache property set to True
  637. """
  638. command.cooker.reset()
  639. command.finishAsyncCommand()
  640. resetCooker.needcache = False
  641. def clientComplete(self, command, params):
  642. """
  643. Do the right thing when the controlling client exits
  644. """
  645. command.cooker.clientComplete()
  646. command.finishAsyncCommand()
  647. clientComplete.needcache = False
  648. def findSigInfo(self, command, params):
  649. """
  650. Find signature info files via the signature generator
  651. """
  652. pn = params[0]
  653. taskname = params[1]
  654. sigs = params[2]
  655. res = bb.siggen.find_siginfo(pn, taskname, sigs, command.cooker.data)
  656. bb.event.fire(bb.event.FindSigInfoResult(res), command.cooker.data)
  657. command.finishAsyncCommand()
  658. findSigInfo.needcache = False