From: stevenknight Date: Sun, 29 Jul 2001 12:16:01 +0000 (+0000) Subject: add the -j argument X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=74c294d11c3ba98f497df73fdd5d5061da601975;p=scons.git add the -j argument git-svn-id: http://scons.tigris.org/svn/scons/trunk@11 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/scons.py b/src/scons.py index c700f779..70d336a5 100644 --- a/src/scons.py +++ b/src/scons.py @@ -5,13 +5,42 @@ import os.path import string import sys -opts, targets = getopt.getopt(sys.argv[1:], 'f:') +def PrintUsage(): + print "Usage: scons [OPTION]... TARGET..." + print "Build TARGET or multiple TARGET(s)" + print " " + print ' -f CONSCRIPT execute CONSCRIPT instead of "SConstruct"' + print " -j N execute N parallel jobs" + print " --help print this message and exit" + +try: + opts, targets = getopt.getopt(sys.argv[1:], 'f:j:', ['help']) +except getopt.GetoptError, x: + print x + PrintUsage() + sys.exit() Scripts = [] +num_jobs = 1 for o, a in opts: if o == '-f': Scripts.append(a) + if o == '-j': + try: + num_jobs = int(a) + except: + PrintUsage() + sys.exit(1) + + if num_jobs <= 0: + PrintUsage() + sys.exit(1) + + if o == '--help': + PrintUsage() + sys.exit(0) + if not Scripts: Scripts.append('SConstruct') @@ -26,13 +55,16 @@ if not Scripts: #for dir in sys.path: # scons = os.path.join(dir, 'scons') # if os.path.isdir(scons): -# dirlist = dirlist + [scons] +# dirlist = dirlist + [scons] # dirlist = dirlist + [dir] # #sys.path = dirlist + from scons.Node.FS import init, Dir, File, lookup from scons.Environment import Environment +import scons.Job +from scons.Builder import Builder init() @@ -49,6 +81,45 @@ while Scripts: -for path in targets: - target = lookup(File, path) - target.build() +class Task: + "this is here only until the build engine is implemented" + + def __init__(self, target): + self.target = target + + def execute(self): + self.target.build() + + + +class Taskmaster: + "this is here only until the build engine is implemented" + + def __init__(self, targets): + self.targets = targets + self.num_iterated = 0 + + + def next_task(self): + if self.num_iterated == len(self.targets): + return None + else: + current = self.num_iterated + self.num_iterated = self.num_iterated + 1 + return Task(self.targets[current]) + + def is_blocked(self): + return 0 + + def executed(self, task): + pass + + + +taskmaster = Taskmaster(map(lambda x: lookup(File, x), targets)) + +jobs = scons.Job.Jobs(num_jobs, taskmaster) +jobs.start() +jobs.wait() + +