diff --git a/tools/ccc/ccclib/Arguments.py b/tools/ccc/ccclib/Arguments.py index a6bad51d13..ee234f1a71 100644 --- a/tools/ccc/ccclib/Arguments.py +++ b/tools/ccc/ccclib/Arguments.py @@ -135,17 +135,17 @@ class PositionalArg(ValueArg): """PositionalArg - A simple positional argument.""" def getValue(self, args): - return args[self.index] + return args.getInputString(self.index) def render(self, args): - return [args[self.index]] + return [args.getInputString(self.index)] class JoinedValueArg(ValueArg): """JoinedValueArg - A single value argument where the value is joined (suffixed) to the option.""" def getValue(self, args): - return args[self.index][len(self.opt.name):] + return args.getInputString(self.index)[len(self.opt.name):] def render(self, args): return [self.opt.name + self.getValue(args)] @@ -155,7 +155,7 @@ class SeparateValueArg(ValueArg): follows the option in the argument vector.""" def getValue(self, args): - return args[self.index+1] + return args.getInputString(self.index, offset=1) def render(self, args): return [self.opt.name, self.getValue(args)] @@ -167,7 +167,8 @@ class MultipleValuesArg(Arg): # FIXME: Should we unify this with SeparateValueArg? def getValues(self, args): - return args[self.index + 1:self.index + 1 + self.opt.numArgs] + return [args.getInputString(self.index, offset=1+i) + for i in range(self.opt.numArgs)] def render(self, args): return [self.opt.name] + self.getValues(args) @@ -179,17 +180,10 @@ class JoinedAndSeparateValuesArg(Arg): separate values.""" def getJoinedValue(self, args): - return args[self.index][len(self.opt.name):] + return args.getInputString(self.index)[len(self.opt.name):] def getSeparateValue(self, args): - return args[self.index+1] - - def setJoinedValue(self, args, value): - assert self.opt.name == args[self.index][:len(self.opt.name)] - args[self.index] = self.opt.name + value - - def setSeparateValue(self, args, vaue): - args[self.index+1] = value + return args.getInputString(self.index, offset=1) def render(self, args): return ([self.opt.name + self.getJoinedValue(args)] + @@ -224,6 +218,9 @@ class ArgList: def getLastArg(self, option): return self.lastArgs.get(option) + def getInputString(self, index, offset=0): + return self.argv[index + offset] + # Support use as a simple arg list. def __iter__(self): @@ -234,18 +231,23 @@ class ArgList: self.lastArgs[arg.opt] = arg # Forwarding methods. + # + # FIXME: Clean this up once restructuring is done. + + def render(self, arg): + return arg.render(self) def getValue(self, arg): - return arg.getValue(self.argv) + return arg.getValue(self) def getValues(self, arg): - return arg.getValues(self.argv) + return arg.getValues(self) def getSeparateValue(self, arg): - return arg.getSeparateValue(self.argv) + return arg.getSeparateValue(self) def getJoinedValue(self, arg): - return arg.getJoinedValue(self.argv) + return arg.getJoinedValue(self) ### diff --git a/tools/ccc/ccclib/Driver.py b/tools/ccc/ccclib/Driver.py index aa617c611e..a8aab6cd26 100644 --- a/tools/ccc/ccclib/Driver.py +++ b/tools/ccc/ccclib/Driver.py @@ -104,10 +104,10 @@ class Driver(object): self.claim(hasHashHashHash) for j in jobs.iterjobs(): if isinstance(j, Jobs.Command): - print '"%s"' % '" "'.join(j.render(argv)) + print '"%s"' % '" "'.join(j.render(args)) elif isinstance(j, Jobs.PipedJob): for c in j.commands: - print '"%s" %c' % ('" "'.join(c.render(argv)), + print '"%s" %c' % ('" "'.join(c.render(args)), "| "[c is j.commands[-1]]) elif not isinstance(j, JobList): raise ValueError,'Encountered unknown job.' @@ -115,7 +115,7 @@ class Driver(object): for j in jobs.iterjobs(): if isinstance(j, Jobs.Command): - cmd_args = j.render(argv) + cmd_args = j.render(args) res = os.spawnvp(os.P_WAIT, cmd_args[0], cmd_args) if res: sys.exit(res) diff --git a/tools/ccc/ccclib/Jobs.py b/tools/ccc/ccclib/Jobs.py index b7d4288788..1c077caa8e 100644 --- a/tools/ccc/ccclib/Jobs.py +++ b/tools/ccc/ccclib/Jobs.py @@ -23,7 +23,7 @@ class Command(Job): def render(self, args): argv = [self.executable] for arg in self.args: - argv.extend(arg.render(args)) + argv.extend(args.render(arg)) return argv def iterjobs(self): diff --git a/tools/ccc/ccclib/Tools.py b/tools/ccc/ccclib/Tools.py index 1468fe899c..779d5d3922 100644 --- a/tools/ccc/ccclib/Tools.py +++ b/tools/ccc/ccclib/Tools.py @@ -139,7 +139,7 @@ class Collect2Tool(Tool): if arg.opt.name in ('-framework',): cmd_args.append(arg) for input in inputs: - cmd_args.append(input.source) + cmd_args.append(input.source) if isinstance(output, Arguments.DerivedArg): cmd_args.extend([Arguments.DerivedArg('-o'), output]) else: