2 # ex:ts=4:sw=4:sts=4:et
3 # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
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
11 # This program is free software; you can redistribute it and/or modify it under
12 # the terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
16 # This program is distributed in the hope that it will be useful, but WITHOUT
17 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along with
21 # this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22 # Place, Suite 330, Boston, MA 02111-1307 USA.
24 import sys, os, getopt, glob, copy, os.path, re
25 sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
27 from bb import utils, data, parse, debug, event, fatal
29 import itertools, optparse
31 parsespin = itertools.cycle( r'|/-\\' )
36 #============================================================================#
38 #============================================================================#
39 class BBParsingStatus:
41 The initial idea for this status class is to use the data when it is
42 already loaded instead of loading it from various place over and over
47 self.cache_dirty = False
49 self.bbfile_priority = {}
50 self.bbfile_config_priorities = []
51 self.ignored_depedencies = None
52 self.possible_world = []
53 self.world_target = Set()
59 self.all_depends = Set()
61 def handle_bb_data(self, file_name, bb_data, cached):
63 We will fill the dictionaries with the stuff we
64 need for building the tree more fast
70 self.cache_dirty = True
72 pn = bb.data.getVar('PN', bb_data, True)
73 pv = bb.data.getVar('PV', bb_data, True)
74 pr = bb.data.getVar('PR', bb_data, True)
75 dp = int(bb.data.getVar('DEFAULT_PREFERENCE', bb_data, True) or "0")
76 provides = Set([pn] + (bb.data.getVar("PROVIDES", bb_data, 1) or "").split())
77 depends = (bb.data.getVar("DEPENDS", bb_data, True) or "").split()
80 # build PackageName to FileName lookup table
81 if pn not in self.pkg_pn:
83 self.pkg_pn[pn].append(file_name)
85 # build FileName to PackageName lookup table
86 self.pkg_fn[file_name] = pn
87 self.pkg_pvpr[file_name] = (pv,pr)
88 self.pkg_dp[file_name] = dp
90 # Build forward and reverse provider hashes
91 # Forward: virtual -> [filenames]
92 # Reverse: PN -> [virtuals]
93 if pn not in self.pn_provides:
94 self.pn_provides[pn] = Set()
95 self.pn_provides[pn] |= provides
97 for provide in provides:
98 if provide not in self.providers:
99 self.providers[provide] = []
100 self.providers[provide].append(file_name)
103 self.all_depends.add(dep)
105 # Collect files we may need for possible world-dep
107 if not bb.data.getVar('BROKEN', bb_data, True) and not bb.data.getVar('EXCLUDE_FROM_WORLD', bb_data, True):
108 self.possible_world.append(file_name)
111 #============================================================================#
113 #============================================================================#
116 Manage build statistics for one run
125 print "Build statistics:"
126 print " Attempted builds: %d" % self.attempt
128 print " Failed builds: %d" % self.fail
130 print " Dependencies not satisfied: %d" % self.deps
131 if self.fail or self.deps: return 1
135 #============================================================================#
137 #============================================================================#
138 class BBConfiguration( object ):
140 Manages build options and configurations for one run
142 def __init__( self, options ):
143 for key, val in options.__dict__.items():
144 setattr( self, key, val )
145 self.data = data.init()
147 #============================================================================#
149 #============================================================================#
152 Manages one bitbake build run
155 ParsingStatus = BBParsingStatus # make it visible from the shell
156 Statistics = BBStatistics # make it visible from the shell
158 def __init__( self ):
159 self.build_cache_fail = []
160 self.build_cache = []
161 self.building_list = []
163 self.consider_msgs_cache = []
165 self.stats = BBStatistics()
171 def tryBuildPackage( self, fn, item, the_data ):
172 """Build one package"""
173 bb.event.fire(bb.event.PkgStarted(item, the_data))
175 self.stats.attempt += 1
176 if self.configuration.force:
177 bb.data.setVarFlag('do_%s' % self.configuration.cmd, 'force', 1, the_data)
178 if not self.configuration.dry_run:
179 bb.build.exec_task('do_%s' % self.configuration.cmd, the_data)
180 bb.event.fire(bb.event.PkgSucceeded(item, the_data))
181 self.build_cache.append(fn)
183 except bb.build.FuncFailed:
185 bb.error("task stack execution failed")
186 bb.event.fire(bb.event.PkgFailed(item, the_data))
187 self.build_cache_fail.append(fn)
189 except bb.build.EventException, e:
192 bb.error("%s event exception, aborting" % bb.event.getName(event))
193 bb.event.fire(bb.event.PkgFailed(item, the_data))
194 self.build_cache_fail.append(fn)
197 def tryBuild( self, fn, virtual ):
198 """Build a provider and its dependencies"""
199 if fn in self.building_list:
200 bb.error("%s depends on itself (eventually)" % fn)
201 bb.error("upwards chain is: %s" % (" -> ".join(self.build_path)))
204 the_data = self.pkgdata[fn]
205 item = self.status.pkg_fn[fn]
207 self.building_list.append(fn)
209 pathstr = "%s (%s)" % (item, virtual)
210 self.build_path.append(pathstr)
212 depends_list = (bb.data.getVar('DEPENDS', the_data, 1) or "").split()
213 if self.configuration.verbose:
214 bb.note("current path: %s" % (" -> ".join(self.build_path)))
215 bb.note("dependencies for %s are: %s" % (item, " ".join(depends_list)))
220 depcmd = self.configuration.cmd
221 bbdepcmd = bb.data.getVarFlag('do_%s' % self.configuration.cmd, 'bbdepcmd', the_data)
222 if bbdepcmd is not None:
229 oldcmd = self.configuration.cmd
230 self.configuration.cmd = depcmd
232 for dependency in depends_list:
233 if dependency in self.status.ignored_dependencies:
237 if self.buildProvider( dependency ) == 0:
238 bb.error("dependency %s (for %s) not satisfied" % (dependency,item))
240 if self.configuration.abort:
244 self.configuration.cmd = oldcmd
250 if bb.build.stamp_is_current('do_%s' % self.configuration.cmd, the_data):
251 self.build_cache.append(fn)
254 return self.tryBuildPackage( fn, item, the_data )
257 self.building_list.remove(fn)
258 self.build_path.remove(pathstr)
260 def findBestProvider( self, pn, pkg_pn = None):
262 If there is a PREFERRED_VERSION, find the highest-priority bbfile
263 providing that version. If not, find the latest version provided by
264 an bbfile in the highest-priority set.
267 pkg_pn = self.status.pkg_pn
272 priority = self.status.bbfile_priority[f]
273 if priority not in priorities:
274 priorities[priority] = []
275 priorities[priority].append(f)
276 p_list = priorities.keys()
277 p_list.sort(lambda a, b: a - b)
280 tmp_pn = [priorities[p]] + tmp_pn
282 preferred_file = None
284 preferred_v = bb.data.getVar('PREFERRED_VERSION_%s' % pn, self.configuration.data, 1)
286 m = re.match('(.*)_(.*)', preferred_v)
288 preferred_v = m.group(1)
289 preferred_r = m.group(2)
293 for file_set in tmp_pn:
295 pv,pr = self.status.pkg_pvpr[f]
296 if preferred_v == pv and (preferred_r == pr or preferred_r == None):
298 preferred_ver = (pv, pr)
303 pv_str = '%s-%s' % (preferred_v, preferred_r)
306 if preferred_file is None:
307 bb.note("preferred version %s of %s not available" % (pv_str, pn))
309 bb.debug(1, "selecting %s as PREFERRED_VERSION %s of package %s" % (preferred_file, pv_str, pn))
311 # get highest priority file set
316 for file_name in files:
317 pv,pr = self.status.pkg_pvpr[file_name]
318 dp = self.status.pkg_dp[file_name]
320 if (latest is None) or ((latest_p == dp) and (utils.vercmp(latest, (pv, pr)) < 0)) or (dp > latest_p):
324 if preferred_file is None:
325 preferred_file = latest_f
326 preferred_ver = latest
328 return (latest,latest_f,preferred_ver, preferred_file)
330 def showVersions( self ):
331 pkg_pn = self.status.pkg_pn
332 preferred_versions = {}
336 for pn in pkg_pn.keys():
337 (last_ver,last_file,pref_ver,pref_file) = self.findBestProvider(pn)
338 preferred_versions[pn] = (pref_ver, pref_file)
339 latest_versions[pn] = (last_ver, last_file)
341 pkg_list = pkg_pn.keys()
345 pref = preferred_versions[p]
346 latest = latest_versions[p]
349 prefstr = pref[0][0] + "-" + pref[0][1]
353 print "%-30s %20s %20s" % (p, latest[0][0] + "-" + latest[0][1],
356 def showEnvironment( self ):
357 """Show the outer or per-package environment"""
358 if self.configuration.buildfile:
360 self.configuration.data, fromCache = self.load_bbfile( self.configuration.buildfile )
362 fatal("Unable to read %s: %s" % ( self.configuration.buildfile, e ))
365 # emit variables and shell functions
367 data.update_data( self.configuration.data )
368 data.emit_env(sys.__stdout__, self.configuration.data, True)
371 # emit the metadata which isnt valid shell
372 for e in self.configuration.data.keys():
373 if data.getVarFlag( e, 'python', self.configuration.data ):
374 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, data.getVar(e, self.configuration.data, 1)))
376 def buildProvider( self, item ):
379 discriminated = False
381 if item not in self.status.providers:
382 bb.error("Nothing provides %s" % item)
385 all_p = self.status.providers[item]
388 if p in self.build_cache:
389 bb.debug(1, "already built %s in this run\n" % p)
393 preferred_versions = {}
395 # Collate providers by PN
398 pn = self.status.pkg_fn[p]
403 bb.debug(1, "providers for %s are: %s" % (item, pkg_pn.keys()))
405 for pn in pkg_pn.keys():
406 preferred_versions[pn] = self.findBestProvider(pn, pkg_pn)[2:4]
407 eligible.append(preferred_versions[pn][1])
410 if p in self.build_cache_fail:
411 bb.debug(1, "rejecting already-failed %s" % p)
414 if len(eligible) == 0:
415 bb.error("no eligible providers for %s" % item)
418 # look to see if one of them is already staged, or marked as preferred.
419 # if so, bump it to the head of the queue
421 the_data = self.pkgdata[p]
422 pn = bb.data.getVar('PN', the_data, 1)
423 pv = bb.data.getVar('PV', the_data, 1)
424 pr = bb.data.getVar('PR', the_data, 1)
425 tmpdir = bb.data.getVar('TMPDIR', the_data, 1)
426 stamp = '%s/stamps/%s-%s-%s.do_populate_staging' % (tmpdir, pn, pv, pr)
427 if os.path.exists(stamp):
428 (newvers, fn) = preferred_versions[pn]
429 if not fn in eligible:
430 # package was made ineligible by already-failed check
432 oldver = "%s-%s" % (pv, pr)
433 newver = '-'.join(newvers)
434 if (newver != oldver):
435 extra_chat = "; upgrading from %s to %s" % (oldver, newver)
438 if self.configuration.verbose:
439 bb.note("selecting already-staged %s to satisfy %s%s" % (pn, item, extra_chat))
441 eligible = [fn] + eligible
445 prefervar = bb.data.getVar('PREFERRED_PROVIDER_%s' % item, self.configuration.data, 1)
447 self.preferred[item] = prefervar
449 if item in self.preferred:
451 pn = self.status.pkg_fn[p]
452 if self.preferred[item] == pn:
453 if self.configuration.verbose:
454 bb.note("selecting %s to satisfy %s due to PREFERRED_PROVIDERS" % (pn, item))
456 eligible = [p] + eligible
460 if len(eligible) > 1 and discriminated == False:
461 if item not in self.consider_msgs_cache:
464 providers_list.append(self.status.pkg_fn[fn])
465 bb.note("multiple providers are available (%s);" % ", ".join(providers_list))
466 bb.note("consider defining PREFERRED_PROVIDER_%s" % item)
467 self.consider_msgs_cache.append(item)
470 # run through the list until we find one that we can build
472 bb.debug(2, "selecting %s to satisfy %s" % (fn, item))
473 if self.tryBuild(fn, item):
476 bb.note("no buildable providers for %s" % item)
479 def buildDepgraph( self ):
480 all_depends = self.status.all_depends
481 pn_provides = self.status.pn_provides
483 def calc_bbfile_priority(filename):
484 for (regex, pri) in self.status.bbfile_config_priorities:
485 if regex.match(filename):
489 # Handle PREFERRED_PROVIDERS
490 for p in (bb.data.getVar('PREFERRED_PROVIDERS', self.configuration.data, 1) or "").split():
491 (providee, provider) = p.split(':')
492 if providee in self.preferred and self.preferred[providee] != provider:
493 bb.error("conflicting preferences for %s: both %s and %s specified" % (providee, provider, self.preferred[providee]))
494 self.preferred[providee] = provider
496 # Calculate priorities for each file
497 for p in self.pkgdata.keys():
498 self.status.bbfile_priority[p] = calc_bbfile_priority(p)
500 # Build package list for "bitbake world"
501 bb.debug(1, "collating packages for \"world\"")
502 for f in self.status.possible_world:
504 pn = self.status.pkg_fn[f]
506 for p in pn_provides[pn]:
507 if p.startswith('virtual/'):
508 bb.debug(2, "skipping %s due to %s provider starting with virtual/" % (f, p))
511 for pf in self.status.providers[p]:
512 if self.status.pkg_fn[pf] != pn:
513 bb.debug(2, "skipping %s due to both us and %s providing %s" % (f, pf, p))
517 self.status.world_target.add(pn)
519 # drop reference count now
520 self.status.possible_world = None
521 self.status.all_depends = None
523 def myProgressCallback( self, x, y, f, file_data, from_cache ):
524 # feed the status with new input
525 self.status.handle_bb_data(f, file_data, from_cache)
529 if os.isatty(sys.stdout.fileno()):
530 sys.stdout.write("\rNOTE: Handling BitBake files: %s (%04d/%04d) [%2d %%]" % ( parsespin.next(), x, y, x*100/y ) )
534 sys.stdout.write("Parsing .bb files, please wait...")
537 sys.stdout.write("done.")
540 def interactiveMode( self ):
541 """Drop off into a shell"""
544 except ImportError, details:
545 bb.fatal("Sorry, shell not available (%s)" % details )
547 bb.data.update_data( self.configuration.data )
551 def parseConfigurationFile( self, afile ):
553 self.configuration.data = bb.parse.handle( afile, self.configuration.data )
555 bb.fatal( "Unable to open %s" % afile )
556 except bb.parse.ParseError, details:
557 bb.fatal( "Unable to parse %s (%s)" % (afile, details) )
559 def handleCollections( self, collections ):
560 """Handle collections"""
562 collection_list = collections.split()
563 for c in collection_list:
564 regex = bb.data.getVar("BBFILE_PATTERN_%s" % c, self.configuration.data, 1)
566 bb.error("BBFILE_PATTERN_%s not defined" % c)
568 priority = bb.data.getVar("BBFILE_PRIORITY_%s" % c, self.configuration.data, 1)
570 bb.error("BBFILE_PRIORITY_%s not defined" % c)
573 cre = re.compile(regex)
575 bb.error("BBFILE_PATTERN_%s \"%s\" is not a valid regular expression" % (c, regex))
579 self.status.bbfile_config_priorities.append((cre, pri))
581 bb.error("invalid value for BBFILE_PRIORITY_%s: \"%s\"" % (c, priority))
584 def cook( self, configuration, args ):
585 self.configuration = configuration
587 if not self.configuration.cmd:
588 self.configuration.cmd = "build"
590 if self.configuration.debug:
591 bb.debug_level = self.configuration.debug
593 self.configuration.data = bb.data.init()
595 for f in self.configuration.file:
596 self.parseConfigurationFile( f )
598 self.parseConfigurationFile( os.path.join( "conf", "bitbake.conf" ) )
600 if self.configuration.show_environment:
601 self.showEnvironment()
604 if not bb.data.getVar("BUILDNAME", self.configuration.data):
605 bb.data.setVar("BUILDNAME", os.popen('date +%Y%m%d%H%M').readline().strip(), self.configuration.data)
607 buildname = bb.data.getVar("BUILDNAME", self.configuration.data)
609 if self.configuration.interactive:
610 self.interactiveMode()
612 if self.configuration.buildfile is not None:
613 bf = os.path.abspath( self.configuration.buildfile )
615 bbfile_data = bb.parse.handle(bf, self.configuration.data)
617 bb.fatal("Unable to open %s" % bf)
619 item = bb.data.getVar('PN', bbfile_data, 1)
621 self.tryBuildPackage( bf, item, bbfile_data )
622 except bb.build.EventException:
623 bb.error( "Build of '%s' failed" % item )
625 sys.exit( self.stats.show() )
627 # initialise the parsing status now we know we will need deps
628 self.status = BBParsingStatus()
630 ignore = bb.data.getVar("ASSUME_PROVIDED", self.configuration.data, 1) or ""
631 self.status.ignored_dependencies = Set( ignore.split() )
633 self.handleCollections( bb.data.getVar("BBFILE_COLLECTIONS", self.configuration.data, 1) )
637 if not pkgs_to_build:
639 pkgs_to_build.extend(args)
640 if not pkgs_to_build:
641 bbpkgs = bb.data.getVar('BBPKGS', self.configuration.data, 1)
643 pkgs_to_build = bbpkgs.split()
644 if not pkgs_to_build and not self.configuration.show_versions \
645 and not self.configuration.interactive \
646 and not self.configuration.show_environment:
647 print "Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help'"
648 print "for usage information."
651 # Import Psyco if available and not disabled
652 if not self.configuration.disable_psyco:
657 bb.note("Psyco JIT Compiler (http://psyco.sf.net) not available. Install it to increase performance.")
659 psyco.bind( self.collect_bbfiles )
661 bb.note("You have disabled Psyco. This decreases performance.")
664 bb.debug(1, "collecting .bb files")
665 self.collect_bbfiles( self.myProgressCallback )
666 bb.debug(1, "parsing complete")
669 if self.configuration.parse_only:
670 print "Requested parsing .bb files only. Exiting."
673 bb.data.update_data( self.configuration.data )
676 if self.configuration.show_versions:
679 if 'world' in pkgs_to_build:
680 pkgs_to_build.remove('world')
681 for t in self.status.world_target:
682 pkgs_to_build.append(t)
684 bb.event.fire(bb.event.BuildStarted(buildname, pkgs_to_build, self.configuration.data))
686 for k in pkgs_to_build:
689 if self.buildProvider( k ) == 0:
692 except bb.build.EventException:
693 bb.error("Build of " + k + " failed")
697 if self.configuration.abort:
700 bb.event.fire(bb.event.BuildCompleted(buildname, pkgs_to_build, self.configuration.data))
702 sys.exit( self.stats.show() )
704 except KeyboardInterrupt:
705 print "\nNOTE: KeyboardInterrupt - Build not completed."
708 def get_bbfiles( self, path = os.getcwd() ):
709 """Get list of default .bb files by reading out the current directory"""
710 contents = os.listdir(path)
713 (root, ext) = os.path.splitext(f)
715 bbfiles.append(os.path.abspath(os.path.join(os.getcwd(),f)))
718 def find_bbfiles( self, path ):
719 """Find all the .bb files in a directory (uses find)"""
720 findcmd = 'find ' + path + ' -name *.bb | grep -v SCCS/'
722 finddata = os.popen(findcmd)
725 return finddata.readlines()
727 def deps_clean(self, d):
728 depstr = data.getVar('__depends', d)
730 deps = depstr.split(" ")
732 (f,old_mtime_s) = dep.split("@")
733 old_mtime = int(old_mtime_s)
734 new_mtime = parse.cached_mtime(f)
735 if (new_mtime > old_mtime):
739 def load_bbfile( self, bbfile ):
740 """Load and parse one .bb build file"""
742 if not self.cache in [None, '']:
744 cache_mtime = data.init_db_mtime(self.cache, bbfile)
745 file_mtime = parse.cached_mtime(bbfile)
747 if file_mtime > cache_mtime:
748 #print " : '%s' dirty. reparsing..." % bbfile
751 #print " : '%s' clean. loading from cache..." % bbfile
752 cache_data = data.init_db( self.cache, bbfile, False )
753 if self.deps_clean(cache_data):
754 return cache_data, True
756 topdir = data.getVar('TOPDIR', self.configuration.data)
758 topdir = os.path.abspath(os.getcwd())
760 data.setVar('TOPDIR', topdir, self.configuration)
761 bbfile = os.path.abspath(bbfile)
762 bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
763 # expand tmpdir to include this topdir
764 data.setVar('TMPDIR', data.getVar('TMPDIR', self.configuration.data, 1) or "", self.configuration.data)
765 # set topdir to location of .bb file
767 #data.setVar('TOPDIR', topdir, cfg)
769 oldpath = os.path.abspath(os.getcwd())
771 bb = data.init_db(self.cache,bbfile, True, self.configuration.data)
773 parse.handle(bbfile, bb) # read .bb data
774 if not self.cache in [None, '']:
775 bb.commit(parse.cached_mtime(bbfile)) # write cache
781 def collect_bbfiles( self, progressCallback ):
782 """Collect all available .bb build files"""
783 self.cb = progressCallback
784 parsed, cached, skipped, masked = 0, 0, 0, 0
785 self.cache = bb.data.getVar( "CACHE", self.configuration.data, 1 )
786 self.pkgdata = data.pkgdata( not self.cache in [None, ''], self.cache )
788 if not self.cache in [None, '']:
789 if self.cb is not None:
790 print "NOTE: Using cache in '%s'" % self.cache
792 os.stat( self.cache )
794 bb.mkdirhier( self.cache )
796 if self.cb is not None:
797 print "NOTE: Not using a cache. Set CACHE = <directory> to enable."
798 files = (data.getVar( "BBFILES", self.configuration.data, 1 ) or "").split()
799 data.setVar("BBFILES", " ".join(files), self.configuration.data)
802 files = self.get_bbfiles()
805 bb.error("no files to build.")
810 dirfiles = self.find_bbfiles(f)
814 newfiles += glob.glob(f) or [ f ]
816 bbmask = bb.data.getVar('BBMASK', self.configuration.data, 1) or ""
818 bbmask_compiled = re.compile(bbmask)
819 except sre_constants.error:
820 bb.fatal("BBMASK is not a valid regular expression.")
822 for i in xrange( len( newfiles ) ):
824 if bbmask and bbmask_compiled.search(f):
825 bb.debug(1, "bbmake: skipping %s" % f)
828 debug(1, "bbmake: parsing %s" % f)
830 # read a file's metadata
832 bb_data, fromCache = self.load_bbfile(f)
833 if fromCache: cached += 1
836 if bb_data is not None:
837 # allow metadata files to add items to BBFILES
838 #data.update_data(self.pkgdata[f])
839 addbbfiles = data.getVar('BBFILES', bb_data) or None
841 for aof in addbbfiles.split():
842 if not files.count(aof):
843 if not os.path.isabs(aof):
844 aof = os.path.join(os.path.dirname(f),aof)
846 for var in bb_data.keys():
847 if data.getVarFlag(var, "handler", bb_data) and data.getVar(var, bb_data):
848 event.register(data.getVar(var, bb_data))
849 self.pkgdata[f] = bb_data
851 # now inform the caller
852 if self.cb is not None:
853 self.cb( i + 1, len( newfiles ), f, bb_data, fromCache )
856 bb.error("opening %s: %s" % (f, e))
858 except bb.parse.SkipPackage:
861 except KeyboardInterrupt:
864 bb.error("%s while parsing %s" % (e, f))
866 if self.cb is not None:
867 print "\rNOTE: Parsing finished. %d cached, %d parsed, %d skipped, %d masked." % ( cached, parsed, skipped, masked ),
869 #============================================================================#
871 #============================================================================#
873 if __name__ == "__main__":
875 parser = optparse.OptionParser( version = "BitBake Build Tool Core version %s, %%prog version %s" % ( bb.__version__, __version__ ),
876 usage = """%prog [options] [package ...]
878 Executes the specified task (default is 'build') for a given set of BitBake files.
879 It expects that BBFILES is defined, which is a space seperated list of files to
880 be executed. BBFILES does support wildcards.
881 Default BBFILES are the .bb files in the current directory.""" )
883 parser.add_option( "-b", "--buildfile", help = "execute the task against this .bb file, rather than a package from BBFILES.",
884 action = "store", dest = "buildfile", default = None )
886 parser.add_option( "-k", "--continue", help = "continue as much as possible after an error. While the target that failed, and those that depend on it, cannot be remade, the other dependencies of these targets can be processed all the same.",
887 action = "store_false", dest = "abort", default = True )
889 parser.add_option( "-f", "--force", help = "force run of specified cmd, regardless of stamp status",
890 action = "store_true", dest = "force", default = False )
892 parser.add_option( "-i", "--interactive", help = "drop into the interactive mode.",
893 action = "store_true", dest = "interactive", default = False )
895 parser.add_option( "-c", "--cmd", help = "Specify task to execute. Note that this only executes the specified task for the providee and the packages it depends on, i.e. 'compile' does not implicitly call stage for the dependencies (IOW: use only if you know what you are doing)",
896 action = "store", dest = "cmd", default = "build" )
898 parser.add_option( "-r", "--read", help = "read the specified file before bitbake.conf",
899 action = "append", dest = "file", default = [] )
901 parser.add_option( "-v", "--verbose", help = "output more chit-chat to the terminal",
902 action = "store_true", dest = "verbose", default = False )
904 parser.add_option( "-D", "--debug", help = "Increase the debug level",
905 action = "count", dest="debug", default = 0)
907 parser.add_option( "-n", "--dry-run", help = "don't execute, just go through the motions",
908 action = "store_true", dest = "dry_run", default = False )
910 parser.add_option( "-p", "--parse-only", help = "quit after parsing the BB files (developers only)",
911 action = "store_true", dest = "parse_only", default = False )
913 parser.add_option( "-d", "--disable-psyco", help = "disable using the psyco just-in-time compiler (not recommended)",
914 action = "store_true", dest = "disable_psyco", default = False )
916 parser.add_option( "-s", "--show-versions", help = "show current and preferred versions of all packages",
917 action = "store_true", dest = "show_versions", default = False )
919 parser.add_option( "-e", "--environment", help = "show the global or per-package environment (this is what used to be bbread)",
920 action = "store_true", dest = "show_environment", default = False )
922 options, args = parser.parse_args( sys.argv )
925 cooker.cook( BBConfiguration( options ), args[1:] )