[cfe-commits] r61871 - in /cfe/trunk/tools/ccc/ccclib: Arguments.py Driver.py Tools.py
Daniel Dunbar
daniel at zuster.org
Wed Jan 7 10:54:27 PST 2009
Author: ddunbar
Date: Wed Jan 7 12:54:26 2009
New Revision: 61871
URL: http://llvm.org/viewvc/llvm-project?rev=61871&view=rev
Log:
ccc: Make proper synthetic arguments in places we have to construct
"fake" options, allowing Tools to be oblivious to whether an argument
is real or synthetic. This kills off DerivedArg & a number of FIXMEs.
Modified:
cfe/trunk/tools/ccc/ccclib/Arguments.py
cfe/trunk/tools/ccc/ccclib/Driver.py
cfe/trunk/tools/ccc/ccclib/Tools.py
Modified: cfe/trunk/tools/ccc/ccclib/Arguments.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Arguments.py?rev=61871&r1=61870&r2=61871&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Arguments.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Arguments.py Wed Jan 7 12:54:26 2009
@@ -189,23 +189,6 @@
return ([self.opt.name + self.getJoinedValue(args)] +
[self.getSeparateValue(args)])
-class DerivedArg(ValueArg):
- """DerivedArg - A synthesized argument which does not correspend
- to an item in the argument vector."""
-
- def __init__(self, value):
- # FIXME: The UnknownOption() here is a total hack so we can
- # rely on arg.opt not being nil. Ok for now since DerivedArg
- # is dying.
- super(DerivedArg, self).__init__(-1, UnknownOption())
- self.value = value
-
- def getValue(self, args):
- return self.value
-
- def render(self, args):
- return [self.value]
-
###
class InputIndex:
@@ -220,7 +203,8 @@
"""ArgList - Collect an input argument vector along with a set of parsed Args
and supporting information."""
- def __init__(self, argv):
+ def __init__(self, parser, argv):
+ self.parser = parser
self.argv = list(argv)
self.syntheticArgv = []
self.lastArgs = {}
@@ -240,11 +224,27 @@
raise RuntimeError,'Unknown source ID for index.'
- def getSyntheticIndex(self, *strings):
+ def makeIndex(self, *strings):
pos = len(self.syntheticArgv)
self.syntheticArgv.extend(strings)
return InputIndex(1, pos)
+ def makeFlagArg(self, option):
+ return Arg(self.makeIndex(option.name),
+ option)
+
+ def makeInputArg(self, string):
+ return PositionalArg(self.makeIndex(string),
+ self.parser.inputOption)
+
+ def makeUnknownArg(self, string):
+ return PositionalArg(self.makeIndex(string),
+ self.parser.unknownOption)
+
+ def makeSeparateArg(self, string, option):
+ return SeparateValueArg(self.makeIndex(option.name, string),
+ option)
+
# Support use as a simple arg list.
def __iter__(self):
@@ -483,7 +483,7 @@
iargs = enumerate(argv)
it = iter(iargs)
- args = ArgList(argv)
+ args = ArgList(self, argv)
for pos,a in it:
i = InputIndex(0, pos)
# FIXME: Handle '@'
Modified: cfe/trunk/tools/ccc/ccclib/Driver.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Driver.py?rev=61871&r1=61870&r2=61871&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Driver.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Driver.py Wed Jan 7 12:54:26 2009
@@ -416,7 +416,8 @@
if not archs:
# FIXME: Need to infer arch so that we sub -Xarch
# correctly.
- archs.append(Arguments.DerivedArg('i386'))
+ archs.append(args.makeSeparateArg('i386',
+ self.parser.archOption))
actions = self.buildNormalPipeline(args)
@@ -548,9 +549,9 @@
# string. Why?
if args.getJoinedValue(arg) == archName:
# FIXME: This is wrong, we don't want a
- # DerivedArg we want an actual parsed version
- # of this arg.
- filteredArgs.append(Arguments.DerivedArg(args.getSeparateValue(arg)))
+ # unknown arg we want an actual parsed
+ # version of this arg.
+ filteredArgs.append(args.makeUnknownArg(args.getSeparateValue(arg)))
else:
filteredArgs.append(arg)
@@ -625,11 +626,13 @@
output = finalOutput
# Contruct a named destination?
elif atTopLevel or hasSaveTemps:
- output = Arguments.DerivedArg(namedOutput)
+ output = args.makeSeparateArg(namedOutput,
+ self.parser.oOption)
else:
# Output to temp file...
fd,filename = tempfile.mkstemp(suffix='.'+phase.type.tempSuffix)
- output = Arguments.DerivedArg(filename)
+ output = args.makeSeparateArg(filename,
+ self.parser.oOption)
tool.constructJob(phase, arch, jobList, inputs, output, phase.type,
forwardArgs, args)
Modified: cfe/trunk/tools/ccc/ccclib/Tools.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Tools.py?rev=61871&r1=61870&r2=61871&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Tools.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Tools.py Wed Jan 7 12:54:26 2009
@@ -30,21 +30,13 @@
cmd_args = sum(map(arglist.render, args),[]) + extraArgs
if arch:
- # FIXME: Clean this up.
- if isinstance(arch, Arguments.DerivedArg):
- cmd_args.extend(['-arch', arglist.getValue(arch)])
- else:
- cmd_args.extend(arglist.render(arch))
+ cmd_args.extend(arglist.render(arch))
if isinstance(output, Jobs.PipedJob):
cmd_args.extend(['-o', '-'])
elif output is None:
cmd_args.append('-fsyntax-only')
else:
- # FIXME: Ditch this hack.
- if isinstance(output, Arguments.DerivedArg):
- cmd_args.extend(['-o', arglist.getValue(output)])
- else:
- cmd_args.extend(arglist.render(output))
+ cmd_args.extend(arglist.render(output))
cmd_args.extend(['-x', input.type.name])
if isinstance(input.source, Jobs.PipedJob):
@@ -105,17 +97,9 @@
cmd_args = []
if arch:
- # FIXME: Clean this up.
- if isinstance(arch, Arguments.DerivedArg):
- cmd_args.extend(['-arch',
- arglist.getValue(arch)])
- else:
- cmd_args.extend(arglist.render(arch))
+ cmd_args.extend(arglist.render(arch))
cmd_args.append('-force_cpusubtype_ALL')
- if isinstance(output, Arguments.DerivedArg):
- cmd_args.extend(['-o', arglist.getValue(output)])
- else:
- cmd_args.extend(arglist.render(output))
+ cmd_args.extend(arglist.render(output))
if isinstance(input.source, Jobs.PipedJob):
cmd_args.append('-')
else:
@@ -138,10 +122,7 @@
cmd_args.extend(arglist.render(arg))
for input in inputs:
cmd_args.append(arglist.getValue(input.source))
- if isinstance(output, Arguments.DerivedArg):
- cmd_args.extend(['-o', arglist.getValue(output)])
- else:
- cmd_args.extend(arglist.render(output))
+ cmd_args.extend(arglist.render(output))
cmd_args.extend(['-L/usr/lib/gcc/i686-apple-darwin10/4.2.1',
'-lcrt1.10.5.o',
'-lgcc_s.10.5',
@@ -158,10 +139,7 @@
assert outputType is Types.ImageType
cmd_args = ['-create']
- if isinstance(output, Arguments.DerivedArg):
- cmd_args.extend(['-o', arglist.getValue(output)])
- else:
- cmd_args.extend(arglist.render(output))
+ cmd_args.extend(arglist.render(output))
for input in inputs:
cmd_args.append(arglist.getValue(input.source))
jobs.addJob(Jobs.Command('lipo', cmd_args))
More information about the cfe-commits
mailing list