hobeventhandler.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. #
  2. # BitBake Graphical GTK User Interface
  3. #
  4. # Copyright (C) 2011 Intel Corporation
  5. #
  6. # Authored by Joshua Lock <josh@linux.intel.com>
  7. # Authored by Dongxiao Xu <dongxiao.xu@intel.com>
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License version 2 as
  11. # published by the Free Software Foundation.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License along
  19. # with this program; if not, write to the Free Software Foundation, Inc.,
  20. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. import gobject
  22. import logging
  23. import ast
  24. from bb.ui.crumbs.runningbuild import RunningBuild
  25. class HobHandler(gobject.GObject):
  26. """
  27. This object does BitBake event handling for the hob gui.
  28. """
  29. __gsignals__ = {
  30. "package-formats-updated" : (gobject.SIGNAL_RUN_LAST,
  31. gobject.TYPE_NONE,
  32. (gobject.TYPE_PYOBJECT,)),
  33. "config-updated" : (gobject.SIGNAL_RUN_LAST,
  34. gobject.TYPE_NONE,
  35. (gobject.TYPE_STRING, gobject.TYPE_PYOBJECT,)),
  36. "command-succeeded" : (gobject.SIGNAL_RUN_LAST,
  37. gobject.TYPE_NONE,
  38. (gobject.TYPE_INT,)),
  39. "command-failed" : (gobject.SIGNAL_RUN_LAST,
  40. gobject.TYPE_NONE,
  41. (gobject.TYPE_STRING,)),
  42. "parsing-warning" : (gobject.SIGNAL_RUN_LAST,
  43. gobject.TYPE_NONE,
  44. (gobject.TYPE_STRING,)),
  45. "sanity-failed" : (gobject.SIGNAL_RUN_LAST,
  46. gobject.TYPE_NONE,
  47. (gobject.TYPE_STRING, gobject.TYPE_INT)),
  48. "generating-data" : (gobject.SIGNAL_RUN_LAST,
  49. gobject.TYPE_NONE,
  50. ()),
  51. "data-generated" : (gobject.SIGNAL_RUN_LAST,
  52. gobject.TYPE_NONE,
  53. ()),
  54. "parsing-started" : (gobject.SIGNAL_RUN_LAST,
  55. gobject.TYPE_NONE,
  56. (gobject.TYPE_PYOBJECT,)),
  57. "parsing" : (gobject.SIGNAL_RUN_LAST,
  58. gobject.TYPE_NONE,
  59. (gobject.TYPE_PYOBJECT,)),
  60. "parsing-completed" : (gobject.SIGNAL_RUN_LAST,
  61. gobject.TYPE_NONE,
  62. (gobject.TYPE_PYOBJECT,)),
  63. "recipe-populated" : (gobject.SIGNAL_RUN_LAST,
  64. gobject.TYPE_NONE,
  65. ()),
  66. "package-populated" : (gobject.SIGNAL_RUN_LAST,
  67. gobject.TYPE_NONE,
  68. ()),
  69. "network-passed" : (gobject.SIGNAL_RUN_LAST,
  70. gobject.TYPE_NONE,
  71. ()),
  72. "network-failed" : (gobject.SIGNAL_RUN_LAST,
  73. gobject.TYPE_NONE,
  74. ()),
  75. }
  76. (GENERATE_CONFIGURATION, GENERATE_RECIPES, GENERATE_PACKAGES, GENERATE_IMAGE, POPULATE_PACKAGEINFO, SANITY_CHECK, NETWORK_TEST) = range(7)
  77. (SUB_PATH_LAYERS, SUB_FILES_DISTRO, SUB_FILES_MACH, SUB_FILES_SDKMACH, SUB_MATCH_CLASS, SUB_PARSE_CONFIG, SUB_SANITY_CHECK,
  78. SUB_GNERATE_TGTS, SUB_GENERATE_PKGINFO, SUB_BUILD_RECIPES, SUB_BUILD_IMAGE, SUB_NETWORK_TEST) = range(12)
  79. def __init__(self, server, recipe_model, package_model):
  80. super(HobHandler, self).__init__()
  81. self.build = RunningBuild(sequential=True)
  82. self.recipe_model = recipe_model
  83. self.package_model = package_model
  84. self.commands_async = []
  85. self.generating = False
  86. self.current_phase = None
  87. self.building = False
  88. self.recipe_queue = []
  89. self.package_queue = []
  90. self.server = server
  91. self.error_msg = ""
  92. self.initcmd = None
  93. self.parsing = False
  94. def set_busy(self):
  95. if not self.generating:
  96. self.emit("generating-data")
  97. self.generating = True
  98. def clear_busy(self):
  99. if self.generating:
  100. self.emit("data-generated")
  101. self.generating = False
  102. def runCommand(self, commandline):
  103. try:
  104. result, error = self.server.runCommand(commandline)
  105. if error:
  106. raise Exception("Error running command '%s': %s" % (commandline, error))
  107. return result
  108. except Exception as e:
  109. self.commands_async = []
  110. self.clear_busy()
  111. self.emit("command-failed", "Hob Exception - %s" % (str(e)))
  112. return None
  113. def run_next_command(self, initcmd=None):
  114. if initcmd != None:
  115. self.initcmd = initcmd
  116. if self.commands_async:
  117. self.set_busy()
  118. next_command = self.commands_async.pop(0)
  119. else:
  120. self.clear_busy()
  121. if self.initcmd != None:
  122. self.emit("command-succeeded", self.initcmd)
  123. return
  124. if next_command == self.SUB_PATH_LAYERS:
  125. self.runCommand(["findConfigFilePath", "bblayers.conf"])
  126. elif next_command == self.SUB_FILES_DISTRO:
  127. self.runCommand(["findConfigFiles", "DISTRO"])
  128. elif next_command == self.SUB_FILES_MACH:
  129. self.runCommand(["findConfigFiles", "MACHINE"])
  130. elif next_command == self.SUB_FILES_SDKMACH:
  131. self.runCommand(["findConfigFiles", "MACHINE-SDK"])
  132. elif next_command == self.SUB_MATCH_CLASS:
  133. self.runCommand(["findFilesMatchingInDir", "rootfs_", "classes"])
  134. elif next_command == self.SUB_PARSE_CONFIG:
  135. self.runCommand(["resetCooker"])
  136. elif next_command == self.SUB_GNERATE_TGTS:
  137. self.runCommand(["generateTargetsTree", "classes/image.bbclass", []])
  138. elif next_command == self.SUB_GENERATE_PKGINFO:
  139. self.runCommand(["triggerEvent", "bb.event.RequestPackageInfo()"])
  140. elif next_command == self.SUB_SANITY_CHECK:
  141. self.runCommand(["triggerEvent", "bb.event.SanityCheck()"])
  142. elif next_command == self.SUB_NETWORK_TEST:
  143. self.runCommand(["triggerEvent", "bb.event.NetworkTest()"])
  144. elif next_command == self.SUB_BUILD_RECIPES:
  145. self.clear_busy()
  146. self.building = True
  147. self.runCommand(["buildTargets", self.recipe_queue, self.default_task])
  148. self.recipe_queue = []
  149. elif next_command == self.SUB_BUILD_IMAGE:
  150. self.clear_busy()
  151. self.building = True
  152. target = self.image
  153. if self.base_image:
  154. # Request the build of a custom image
  155. self.generate_hob_base_image(target)
  156. self.set_var_in_file("LINGUAS_INSTALL", "", "local.conf")
  157. hobImage = self.runCommand(["matchFile", target + ".bb"])
  158. if self.base_image != self.recipe_model.__custom_image__:
  159. baseImage = self.runCommand(["matchFile", self.base_image + ".bb"])
  160. version = self.runCommand(["generateNewImage", hobImage, baseImage, self.package_queue, True, ""])
  161. target += version
  162. self.recipe_model.set_custom_image_version(version)
  163. targets = [target]
  164. if self.toolchain_packages:
  165. self.set_var_in_file("TOOLCHAIN_TARGET_TASK", " ".join(self.toolchain_packages), "local.conf")
  166. targets.append(target + ":do_populate_sdk")
  167. self.runCommand(["buildTargets", targets, self.default_task])
  168. def display_error(self):
  169. self.clear_busy()
  170. self.emit("command-failed", self.error_msg)
  171. self.error_msg = ""
  172. if self.building:
  173. self.building = False
  174. def handle_event(self, event):
  175. if not event:
  176. return
  177. if self.building:
  178. self.current_phase = "building"
  179. self.build.handle_event(event)
  180. if isinstance(event, bb.event.PackageInfo):
  181. self.package_model.populate(event._pkginfolist)
  182. self.emit("package-populated")
  183. self.run_next_command()
  184. elif isinstance(event, bb.event.SanityCheckPassed):
  185. reparse = self.runCommand(["getVariable", "BB_INVALIDCONF"]) or None
  186. if reparse is True:
  187. self.set_var_in_file("BB_INVALIDCONF", False, "local.conf")
  188. self.runCommand(["setPrePostConfFiles", "conf/.hob.conf", ""])
  189. self.commands_async.prepend(self.SUB_PARSE_CONFIG)
  190. self.run_next_command()
  191. elif isinstance(event, bb.event.SanityCheckFailed):
  192. self.emit("sanity-failed", event._msg, event._network_error)
  193. elif isinstance(event, logging.LogRecord):
  194. if not self.building:
  195. if event.levelno >= logging.ERROR:
  196. formatter = bb.msg.BBLogFormatter()
  197. msg = formatter.format(event)
  198. self.error_msg += msg + '\n'
  199. elif event.levelno >= logging.WARNING and self.parsing == True:
  200. formatter = bb.msg.BBLogFormatter()
  201. msg = formatter.format(event)
  202. warn_msg = msg + '\n'
  203. self.emit("parsing-warning", warn_msg)
  204. elif isinstance(event, bb.event.TargetsTreeGenerated):
  205. self.current_phase = "data generation"
  206. if event._model:
  207. self.recipe_model.populate(event._model)
  208. self.emit("recipe-populated")
  209. elif isinstance(event, bb.event.ConfigFilesFound):
  210. self.current_phase = "configuration lookup"
  211. var = event._variable
  212. values = event._values
  213. values.sort()
  214. self.emit("config-updated", var, values)
  215. elif isinstance(event, bb.event.ConfigFilePathFound):
  216. self.current_phase = "configuration lookup"
  217. elif isinstance(event, bb.event.FilesMatchingFound):
  218. self.current_phase = "configuration lookup"
  219. # FIXME: hard coding, should at least be a variable shared between
  220. # here and the caller
  221. if event._pattern == "rootfs_":
  222. formats = []
  223. for match in event._matches:
  224. classname, sep, cls = match.rpartition(".")
  225. fs, sep, format = classname.rpartition("_")
  226. formats.append(format)
  227. formats.sort()
  228. self.emit("package-formats-updated", formats)
  229. elif isinstance(event, bb.command.CommandCompleted):
  230. self.current_phase = None
  231. self.run_next_command()
  232. elif isinstance(event, bb.command.CommandFailed):
  233. if event.error not in ("Forced shutdown", "Stopped build"):
  234. self.error_msg += event.error
  235. self.commands_async = []
  236. self.display_error()
  237. elif isinstance(event, (bb.event.ParseStarted,
  238. bb.event.CacheLoadStarted,
  239. bb.event.TreeDataPreparationStarted,
  240. )):
  241. message = {}
  242. message["eventname"] = bb.event.getName(event)
  243. message["current"] = 0
  244. message["total"] = None
  245. message["title"] = "Parsing recipes"
  246. self.emit("parsing-started", message)
  247. if isinstance(event, bb.event.ParseStarted):
  248. self.parsing = True
  249. elif isinstance(event, (bb.event.ParseProgress,
  250. bb.event.CacheLoadProgress,
  251. bb.event.TreeDataPreparationProgress)):
  252. message = {}
  253. message["eventname"] = bb.event.getName(event)
  254. message["current"] = event.current
  255. message["total"] = event.total
  256. message["title"] = "Parsing recipes"
  257. self.emit("parsing", message)
  258. elif isinstance(event, (bb.event.ParseCompleted,
  259. bb.event.CacheLoadCompleted,
  260. bb.event.TreeDataPreparationCompleted)):
  261. message = {}
  262. message["eventname"] = bb.event.getName(event)
  263. message["current"] = event.total
  264. message["total"] = event.total
  265. message["title"] = "Parsing recipes"
  266. self.emit("parsing-completed", message)
  267. if isinstance(event, bb.event.ParseCompleted):
  268. self.parsing = False
  269. elif isinstance(event, bb.event.NetworkTestFailed):
  270. self.emit("network-failed")
  271. self.run_next_command()
  272. elif isinstance(event, bb.event.NetworkTestPassed):
  273. self.emit("network-passed")
  274. self.run_next_command()
  275. if self.error_msg and not self.commands_async:
  276. self.display_error()
  277. return
  278. def init_cooker(self):
  279. self.runCommand(["createConfigFile", ".hob.conf"])
  280. def set_extra_inherit(self, bbclass):
  281. self.append_var_in_file("INHERIT", bbclass, ".hob.conf")
  282. def set_bblayers(self, bblayers):
  283. self.set_var_in_file("BBLAYERS", " ".join(bblayers), "bblayers.conf")
  284. def set_machine(self, machine):
  285. if machine:
  286. self.early_assign_var_in_file("MACHINE", machine, "local.conf")
  287. def set_sdk_machine(self, sdk_machine):
  288. self.set_var_in_file("SDKMACHINE", sdk_machine, "local.conf")
  289. def set_image_fstypes(self, image_fstypes):
  290. self.set_var_in_file("IMAGE_FSTYPES", image_fstypes, "local.conf")
  291. def set_distro(self, distro):
  292. self.set_var_in_file("DISTRO", distro, "local.conf")
  293. def set_package_format(self, format):
  294. package_classes = ""
  295. for pkgfmt in format.split():
  296. package_classes += ("package_%s" % pkgfmt + " ")
  297. self.set_var_in_file("PACKAGE_CLASSES", package_classes, "local.conf")
  298. def set_bbthreads(self, threads):
  299. self.set_var_in_file("BB_NUMBER_THREADS", threads, "local.conf")
  300. def set_pmake(self, threads):
  301. pmake = "-j %s" % threads
  302. self.set_var_in_file("PARALLEL_MAKE", pmake, "local.conf")
  303. def set_dl_dir(self, directory):
  304. self.set_var_in_file("DL_DIR", directory, "local.conf")
  305. def set_sstate_dir(self, directory):
  306. self.set_var_in_file("SSTATE_DIR", directory, "local.conf")
  307. def set_sstate_mirrors(self, url):
  308. self.set_var_in_file("SSTATE_MIRRORS", url, "local.conf")
  309. def set_extra_size(self, image_extra_size):
  310. self.set_var_in_file("IMAGE_ROOTFS_EXTRA_SPACE", str(image_extra_size), "local.conf")
  311. def set_rootfs_size(self, image_rootfs_size):
  312. self.set_var_in_file("IMAGE_ROOTFS_SIZE", str(image_rootfs_size), "local.conf")
  313. def set_incompatible_license(self, incompat_license):
  314. self.set_var_in_file("INCOMPATIBLE_LICENSE", incompat_license, "local.conf")
  315. def set_extra_setting(self, extra_setting):
  316. self.set_var_in_file("EXTRA_SETTING", extra_setting, "local.conf")
  317. def set_extra_config(self, extra_setting):
  318. old_extra_setting = self.runCommand(["getVariable", "EXTRA_SETTING"]) or {}
  319. old_extra_setting = str(old_extra_setting)
  320. old_extra_setting = ast.literal_eval(old_extra_setting)
  321. if not type(old_extra_setting) == dict:
  322. old_extra_setting = {}
  323. # settings not changed
  324. if old_extra_setting == extra_setting:
  325. return
  326. # remove the old EXTRA SETTING variable
  327. self.remove_var_from_file("EXTRA_SETTING")
  328. # remove old settings from conf
  329. for key in old_extra_setting.keys():
  330. if key not in extra_setting:
  331. self.remove_var_from_file(key)
  332. # add new settings
  333. for key, value in extra_setting.iteritems():
  334. self.set_var_in_file(key, value, "local.conf")
  335. if extra_setting:
  336. self.set_var_in_file("EXTRA_SETTING", extra_setting, "local.conf")
  337. def set_http_proxy(self, http_proxy):
  338. self.set_var_in_file("http_proxy", http_proxy, "local.conf")
  339. def set_https_proxy(self, https_proxy):
  340. self.set_var_in_file("https_proxy", https_proxy, "local.conf")
  341. def set_ftp_proxy(self, ftp_proxy):
  342. self.set_var_in_file("ftp_proxy", ftp_proxy, "local.conf")
  343. def set_socks_proxy(self, socks_proxy):
  344. self.set_var_in_file("all_proxy", socks_proxy, "local.conf")
  345. def set_cvs_proxy(self, host, port):
  346. self.set_var_in_file("CVS_PROXY_HOST", host, "local.conf")
  347. self.set_var_in_file("CVS_PROXY_PORT", port, "local.conf")
  348. def request_package_info(self):
  349. self.commands_async.append(self.SUB_GENERATE_PKGINFO)
  350. self.run_next_command(self.POPULATE_PACKAGEINFO)
  351. def trigger_sanity_check(self):
  352. self.commands_async.append(self.SUB_SANITY_CHECK)
  353. self.run_next_command(self.SANITY_CHECK)
  354. def trigger_network_test(self):
  355. self.commands_async.append(self.SUB_NETWORK_TEST)
  356. self.run_next_command(self.NETWORK_TEST)
  357. def generate_configuration(self):
  358. self.runCommand(["setPrePostConfFiles", "conf/.hob.conf", ""])
  359. self.commands_async.append(self.SUB_PARSE_CONFIG)
  360. self.commands_async.append(self.SUB_PATH_LAYERS)
  361. self.commands_async.append(self.SUB_FILES_DISTRO)
  362. self.commands_async.append(self.SUB_FILES_MACH)
  363. self.commands_async.append(self.SUB_FILES_SDKMACH)
  364. self.commands_async.append(self.SUB_MATCH_CLASS)
  365. self.run_next_command(self.GENERATE_CONFIGURATION)
  366. def generate_recipes(self):
  367. self.runCommand(["setPrePostConfFiles", "conf/.hob.conf", ""])
  368. self.commands_async.append(self.SUB_PARSE_CONFIG)
  369. self.commands_async.append(self.SUB_GNERATE_TGTS)
  370. self.run_next_command(self.GENERATE_RECIPES)
  371. def generate_packages(self, tgts, default_task="build"):
  372. targets = []
  373. targets.extend(tgts)
  374. self.recipe_queue = targets
  375. self.default_task = default_task
  376. self.runCommand(["setPrePostConfFiles", "conf/.hob.conf", ""])
  377. self.commands_async.append(self.SUB_PARSE_CONFIG)
  378. self.commands_async.append(self.SUB_BUILD_RECIPES)
  379. self.run_next_command(self.GENERATE_PACKAGES)
  380. def generate_image(self, image, base_image, image_packages=None, toolchain_packages=None, default_task="build"):
  381. self.image = image
  382. self.base_image = base_image
  383. if image_packages:
  384. self.package_queue = image_packages
  385. else:
  386. self.package_queue = []
  387. if toolchain_packages:
  388. self.toolchain_packages = toolchain_packages
  389. else:
  390. self.toolchain_packages = []
  391. self.default_task = default_task
  392. self.runCommand(["setPrePostConfFiles", "conf/.hob.conf", ""])
  393. self.commands_async.append(self.SUB_PARSE_CONFIG)
  394. self.commands_async.append(self.SUB_BUILD_IMAGE)
  395. self.run_next_command(self.GENERATE_IMAGE)
  396. def generate_new_image(self, image, base_image, package_queue, description):
  397. if base_image:
  398. base_image = self.runCommand(["matchFile", self.base_image + ".bb"])
  399. self.runCommand(["generateNewImage", image, base_image, package_queue, False, description])
  400. def generate_hob_base_image(self, hob_image):
  401. image_dir = self.get_topdir() + "/recipes/images/"
  402. recipe_name = hob_image + ".bb"
  403. self.ensure_dir(image_dir)
  404. self.generate_new_image(image_dir + recipe_name, None, [], "")
  405. def ensure_dir(self, directory):
  406. self.runCommand(["ensureDir", directory])
  407. def build_succeeded_async(self):
  408. self.building = False
  409. def build_failed_async(self):
  410. self.initcmd = None
  411. self.commands_async = []
  412. self.building = False
  413. def cancel_parse(self):
  414. self.runCommand(["stateForceShutdown"])
  415. def cancel_build(self, force=False):
  416. if force:
  417. # Force the cooker to stop as quickly as possible
  418. self.runCommand(["stateForceShutdown"])
  419. else:
  420. # Wait for tasks to complete before shutting down, this helps
  421. # leave the workdir in a usable state
  422. self.runCommand(["stateShutdown"])
  423. def reset_build(self):
  424. self.build.reset()
  425. def get_logfile(self):
  426. return self.server.runCommand(["getVariable", "BB_CONSOLELOG"])[0]
  427. def get_topdir(self):
  428. return self.runCommand(["getVariable", "TOPDIR"]) or ""
  429. def _remove_redundant(self, string):
  430. ret = []
  431. for i in string.split():
  432. if i not in ret:
  433. ret.append(i)
  434. return " ".join(ret)
  435. def set_var_in_file(self, var, val, default_file=None):
  436. self.runCommand(["enableDataTracking"])
  437. self.server.runCommand(["setVarFile", var, val, default_file, "set"])
  438. self.runCommand(["disableDataTracking"])
  439. def early_assign_var_in_file(self, var, val, default_file=None):
  440. self.runCommand(["enableDataTracking"])
  441. self.server.runCommand(["setVarFile", var, val, default_file, "earlyAssign"])
  442. self.runCommand(["disableDataTracking"])
  443. def remove_var_from_file(self, var):
  444. self.server.runCommand(["removeVarFile", var])
  445. def append_var_in_file(self, var, val, default_file=None):
  446. self.server.runCommand(["setVarFile", var, val, default_file, "append"])
  447. def append_to_bbfiles(self, val):
  448. bbfiles = self.runCommand(["getVariable", "BBFILES", "False"]) or ""
  449. bbfiles = bbfiles.split()
  450. if val not in bbfiles:
  451. self.append_var_in_file("BBFILES", val, "bblayers.conf")
  452. def get_parameters(self):
  453. # retrieve the parameters from bitbake
  454. params = {}
  455. params["core_base"] = self.runCommand(["getVariable", "COREBASE"]) or ""
  456. params["layer"] = self.runCommand(["getVariable", "BBLAYERS"]) or ""
  457. params["layers_non_removable"] = self.runCommand(["getVariable", "BBLAYERS_NON_REMOVABLE"]) or ""
  458. params["dldir"] = self.runCommand(["getVariable", "DL_DIR"]) or ""
  459. params["machine"] = self.runCommand(["getVariable", "MACHINE"]) or ""
  460. params["distro"] = self.runCommand(["getVariable", "DISTRO"]) or "defaultsetup"
  461. params["pclass"] = self.runCommand(["getVariable", "PACKAGE_CLASSES"]) or ""
  462. params["sstatedir"] = self.runCommand(["getVariable", "SSTATE_DIR"]) or ""
  463. params["sstatemirror"] = self.runCommand(["getVariable", "SSTATE_MIRRORS"]) or ""
  464. num_threads = self.runCommand(["getCpuCount"])
  465. if not num_threads:
  466. num_threads = 1
  467. max_threads = 65536
  468. else:
  469. try:
  470. num_threads = int(num_threads)
  471. max_threads = 16 * num_threads
  472. except:
  473. num_threads = 1
  474. max_threads = 65536
  475. params["max_threads"] = max_threads
  476. bbthread = self.runCommand(["getVariable", "BB_NUMBER_THREADS"])
  477. if not bbthread:
  478. bbthread = num_threads
  479. else:
  480. try:
  481. bbthread = int(bbthread)
  482. except:
  483. bbthread = num_threads
  484. params["bbthread"] = bbthread
  485. pmake = self.runCommand(["getVariable", "PARALLEL_MAKE"])
  486. if not pmake:
  487. pmake = num_threads
  488. elif isinstance(pmake, int):
  489. pass
  490. else:
  491. try:
  492. pmake = int(pmake.lstrip("-j "))
  493. except:
  494. pmake = num_threads
  495. params["pmake"] = "-j %s" % pmake
  496. params["image_addr"] = self.runCommand(["getVariable", "DEPLOY_DIR_IMAGE"]) or ""
  497. image_extra_size = self.runCommand(["getVariable", "IMAGE_ROOTFS_EXTRA_SPACE"])
  498. if not image_extra_size:
  499. image_extra_size = 0
  500. else:
  501. try:
  502. image_extra_size = int(image_extra_size)
  503. except:
  504. image_extra_size = 0
  505. params["image_extra_size"] = image_extra_size
  506. image_rootfs_size = self.runCommand(["getVariable", "IMAGE_ROOTFS_SIZE"])
  507. if not image_rootfs_size:
  508. image_rootfs_size = 0
  509. else:
  510. try:
  511. image_rootfs_size = int(image_rootfs_size)
  512. except:
  513. image_rootfs_size = 0
  514. params["image_rootfs_size"] = image_rootfs_size
  515. image_overhead_factor = self.runCommand(["getVariable", "IMAGE_OVERHEAD_FACTOR"])
  516. if not image_overhead_factor:
  517. image_overhead_factor = 1
  518. else:
  519. try:
  520. image_overhead_factor = float(image_overhead_factor)
  521. except:
  522. image_overhead_factor = 1
  523. params['image_overhead_factor'] = image_overhead_factor
  524. params["incompat_license"] = self._remove_redundant(self.runCommand(["getVariable", "INCOMPATIBLE_LICENSE"]) or "")
  525. params["sdk_machine"] = self.runCommand(["getVariable", "SDKMACHINE"]) or self.runCommand(["getVariable", "SDK_ARCH"]) or ""
  526. params["image_fstypes"] = self._remove_redundant(self.runCommand(["getVariable", "IMAGE_FSTYPES"]) or "")
  527. params["image_types"] = self._remove_redundant(self.runCommand(["getVariable", "IMAGE_TYPES"]) or "")
  528. params["conf_version"] = self.runCommand(["getVariable", "CONF_VERSION"]) or ""
  529. params["lconf_version"] = self.runCommand(["getVariable", "LCONF_VERSION"]) or ""
  530. params["runnable_image_types"] = self._remove_redundant(self.runCommand(["getVariable", "RUNNABLE_IMAGE_TYPES"]) or "")
  531. params["runnable_machine_patterns"] = self._remove_redundant(self.runCommand(["getVariable", "RUNNABLE_MACHINE_PATTERNS"]) or "")
  532. params["deployable_image_types"] = self._remove_redundant(self.runCommand(["getVariable", "DEPLOYABLE_IMAGE_TYPES"]) or "")
  533. params["kernel_image_type"] = self.runCommand(["getVariable", "KERNEL_IMAGETYPE"]) or ""
  534. params["tmpdir"] = self.runCommand(["getVariable", "TMPDIR"]) or ""
  535. params["distro_version"] = self.runCommand(["getVariable", "DISTRO_VERSION"]) or ""
  536. params["target_os"] = self.runCommand(["getVariable", "TARGET_OS"]) or ""
  537. params["target_arch"] = self.runCommand(["getVariable", "TARGET_ARCH"]) or ""
  538. params["tune_pkgarch"] = self.runCommand(["getVariable", "TUNE_PKGARCH"]) or ""
  539. params["bb_version"] = self.runCommand(["getVariable", "BB_MIN_VERSION"]) or ""
  540. params["default_task"] = self.runCommand(["getVariable", "BB_DEFAULT_TASK"]) or "build"
  541. params["socks_proxy"] = self.runCommand(["getVariable", "all_proxy"]) or ""
  542. params["http_proxy"] = self.runCommand(["getVariable", "http_proxy"]) or ""
  543. params["ftp_proxy"] = self.runCommand(["getVariable", "ftp_proxy"]) or ""
  544. params["https_proxy"] = self.runCommand(["getVariable", "https_proxy"]) or ""
  545. params["cvs_proxy_host"] = self.runCommand(["getVariable", "CVS_PROXY_HOST"]) or ""
  546. params["cvs_proxy_port"] = self.runCommand(["getVariable", "CVS_PROXY_PORT"]) or ""
  547. params["image_white_pattern"] = self.runCommand(["getVariable", "BBUI_IMAGE_WHITE_PATTERN"]) or ""
  548. params["image_black_pattern"] = self.runCommand(["getVariable", "BBUI_IMAGE_BLACK_PATTERN"]) or ""
  549. return params