[cfe-commits] r61869 - in /cfe/trunk/tools/ccc/ccclib: Driver.py Jobs.py Tools.py
Daniel Dunbar
daniel at zuster.org
Wed Jan 7 10:40:45 PST 2009
Author: ddunbar
Date: Wed Jan 7 12:40:45 2009
New Revision: 61869
URL: http://llvm.org/viewvc/llvm-project?rev=61869&view=rev
Log:
ccc: Change Command to take list of strings for argv instead of Arg
instances; this just complicated things and doesn't seem to provide
any benefit.
Modified:
cfe/trunk/tools/ccc/ccclib/Driver.py
cfe/trunk/tools/ccc/ccclib/Jobs.py
cfe/trunk/tools/ccc/ccclib/Tools.py
Modified: cfe/trunk/tools/ccc/ccclib/Driver.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Driver.py?rev=61869&r1=61868&r2=61869&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Driver.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Driver.py Wed Jan 7 12:40:45 2009
@@ -104,10 +104,10 @@
self.claim(hasHashHashHash)
for j in jobs.iterjobs():
if isinstance(j, Jobs.Command):
- print '"%s"' % '" "'.join(j.render(args))
+ print '"%s"' % '" "'.join(j.getArgv())
elif isinstance(j, Jobs.PipedJob):
for c in j.commands:
- print '"%s" %c' % ('" "'.join(c.render(args)),
+ print '"%s" %c' % ('" "'.join(c.getArgv()),
"| "[c is j.commands[-1]])
elif not isinstance(j, JobList):
raise ValueError,'Encountered unknown job.'
@@ -115,8 +115,7 @@
for j in jobs.iterjobs():
if isinstance(j, Jobs.Command):
- cmd_args = j.render(args)
- res = os.spawnvp(os.P_WAIT, cmd_args[0], cmd_args)
+ res = os.spawnvp(os.P_WAIT, j.executable, j.getArgv())
if res:
sys.exit(res)
elif isinstance(j, Jobs.PipedJob):
@@ -632,7 +631,8 @@
fd,filename = tempfile.mkstemp(suffix='.'+phase.type.tempSuffix)
output = Arguments.DerivedArg(filename)
- tool.constructJob(phase, arch, jobList, inputs, output, phase.type, forwardArgs)
+ tool.constructJob(phase, arch, jobList, inputs, output, phase.type,
+ forwardArgs, args)
return InputInfo(output, phase.type, baseInput)
Modified: cfe/trunk/tools/ccc/ccclib/Jobs.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Jobs.py?rev=61869&r1=61868&r2=61869&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Jobs.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Jobs.py Wed Jan 7 12:40:45 2009
@@ -9,10 +9,13 @@
class Command(Job):
"""Command - Represent the information needed to execute a single
- process."""
+ process.
+
+ This currently assumes that the executable will always be the
+ first argument."""
def __init__(self, executable, args):
- assert Util.all_true(args, lambda x: isinstance(x, Arguments.Arg))
+ assert Util.all_true(args, lambda x: isinstance(x, str))
self.executable = executable
self.args = args
@@ -20,11 +23,8 @@
return Util.prefixAndPPrint(self.__class__.__name__,
(self.executable, self.args))
- def render(self, args):
- argv = [self.executable]
- for arg in self.args:
- argv.extend(args.render(arg))
- return argv
+ def getArgv(self):
+ return [self.executable] + self.args
def iterjobs(self):
yield self
Modified: cfe/trunk/tools/ccc/ccclib/Tools.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Tools.py?rev=61869&r1=61868&r2=61869&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Tools.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Tools.py Wed Jan 7 12:40:45 2009
@@ -22,37 +22,35 @@
class GCC_Common_Tool(Tool):
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args,
+ output, outputType, args, arglist,
extraArgs):
assert len(inputs) == 1
input = inputs[0]
- cmd_args = args + extraArgs
+ cmd_args = sum(map(arglist.render, args),[]) + extraArgs
if arch:
# FIXME: Clean this up.
if isinstance(arch, Arguments.DerivedArg):
- cmd_args.extend([Arguments.DerivedArg('-arch'),
- arch])
+ cmd_args.extend(['-arch', arglist.getValue(arch)])
else:
- cmd_args.append(arch)
+ cmd_args.extend(arglist.render(arch))
if isinstance(output, Jobs.PipedJob):
- cmd_args.extend([Arguments.DerivedArg('-o'), Arguments.DerivedArg('-')])
+ cmd_args.extend(['-o', '-'])
elif output is None:
- cmd_args.append(Arguments.DerivedArg('-fsyntax-only'))
+ cmd_args.append('-fsyntax-only')
else:
# FIXME: Ditch this hack.
if isinstance(output, Arguments.DerivedArg):
- cmd_args.extend([Arguments.DerivedArg('-o'), output])
+ cmd_args.extend(['-o', arglist.getValue(output)])
else:
- cmd_args.append(output)
+ cmd_args.extend(arglist.render(output))
- cmd_args.extend([Arguments.DerivedArg('-x'),
- Arguments.DerivedArg(input.type.name)])
+ cmd_args.extend(['-x', input.type.name])
if isinstance(input.source, Jobs.PipedJob):
- cmd_args.append(Arguments.DerivedArg('-'))
+ cmd_args.append('-')
else:
- cmd_args.append(input.source)
+ cmd_args.append(arglist.getValue(input.source))
jobs.addJob(Jobs.Command('gcc', cmd_args))
@@ -63,10 +61,10 @@
Tool.eFlagsPipedOutput))
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args):
+ output, outputType, args, arglist):
return super(GCC_PreprocessTool, self).constructJob(phase, arch, jobs, inputs,
- output, outputType, args,
- [Arguments.DerivedArg('-E')])
+ output, outputType, args, arglist,
+ ['-E'])
class GCC_CompileTool(GCC_Common_Tool):
def __init__(self):
@@ -76,10 +74,10 @@
Tool.eFlagsIntegratedCPP))
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args):
+ output, outputType, args, arglist):
return super(GCC_CompileTool, self).constructJob(phase, arch, jobs, inputs,
- output, outputType, args,
- [Arguments.DerivedArg('-S')])
+ output, outputType, args, arglist,
+ ['-S'])
class GCC_PrecompileTool(GCC_Common_Tool):
def __init__(self):
@@ -88,9 +86,9 @@
Tool.eFlagsIntegratedCPP))
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args):
+ output, outputType, args, arglist):
return super(GCC_PrecompileTool, self).constructJob(phase, arch, jobs, inputs,
- output, outputType, args,
+ output, outputType, args, arglist,
[])
class DarwinAssemblerTool(Tool):
@@ -99,7 +97,7 @@
Tool.eFlagsPipedInput)
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args):
+ output, outputType, args, arglist):
assert len(inputs) == 1
assert outputType is Types.ObjectType
@@ -109,19 +107,19 @@
if arch:
# FIXME: Clean this up.
if isinstance(arch, Arguments.DerivedArg):
- cmd_args.extend([Arguments.DerivedArg('-arch'),
- arch])
+ cmd_args.extend(['-arch',
+ arglist.getValue(arch)])
else:
- cmd_args.append(arch)
- cmd_args.append(Arguments.DerivedArg('-force_cpusubtype_ALL'))
+ cmd_args.extend(arglist.render(arch))
+ cmd_args.append('-force_cpusubtype_ALL')
if isinstance(output, Arguments.DerivedArg):
- cmd_args.extend([Arguments.DerivedArg('-o'), output])
+ cmd_args.extend(['-o', arglist.getValue(output)])
else:
- cmd_args.append(output)
+ cmd_args.extend(arglist.render(output))
if isinstance(input.source, Jobs.PipedJob):
- cmd_args.append(Arguments.DerivedArg('-'))
+ cmd_args.append('-')
else:
- cmd_args.append(input.source)
+ cmd_args.append(arglist.getValue(input.source))
jobs.addJob(Jobs.Command('as', cmd_args))
class Collect2Tool(Tool):
@@ -130,25 +128,25 @@
super(Collect2Tool, self).__init__('collect2')
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args):
+ output, outputType, args, arglist):
assert outputType is Types.ImageType
cmd_args = []
for arg in args:
if arg.opt:
if arg.opt.name in ('-framework',):
- cmd_args.append(arg)
+ cmd_args.extend(arglist.render(arg))
for input in inputs:
- cmd_args.append(input.source)
+ cmd_args.append(arglist.getValue(input.source))
if isinstance(output, Arguments.DerivedArg):
- cmd_args.extend([Arguments.DerivedArg('-o'), output])
+ cmd_args.extend(['-o', arglist.getValue(output)])
else:
- cmd_args.append(output)
- cmd_args.extend([Arguments.DerivedArg('-L/usr/lib/gcc/i686-apple-darwin10/4.2.1'),
- Arguments.DerivedArg('-lcrt1.10.5.o'),
- Arguments.DerivedArg('-lgcc_s.10.5'),
- Arguments.DerivedArg('-lgcc'),
- Arguments.DerivedArg('-lSystem')])
+ 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',
+ '-lgcc',
+ '-lSystem'])
jobs.addJob(Jobs.Command(self.kCollect2Path, cmd_args))
class LipoTool(Tool):
@@ -156,14 +154,14 @@
super(LipoTool, self).__init__('lipo')
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args):
+ output, outputType, args, arglist):
assert outputType is Types.ImageType
- cmd_args = [Arguments.DerivedArg('-create')]
+ cmd_args = ['-create']
if isinstance(output, Arguments.DerivedArg):
- cmd_args.extend([Arguments.DerivedArg('-o'), output])
+ cmd_args.extend(['-o', arglist.getValue(output)])
else:
- cmd_args.append(output)
+ cmd_args.extend(arglist.render(output))
for input in inputs:
- cmd_args.append(input.source)
+ cmd_args.append(arglist.getValue(input.source))
jobs.addJob(Jobs.Command('lipo', cmd_args))
More information about the cfe-commits
mailing list