return '<%s name=%r>' % (self.__class__.__name__,
self.name)
+ def forwardToGCC(self):
+ # FIXME: Get rid of this hack.
+ if self.name == '<input>':
+ return False
+
+ if self.isLinkerInput:
+ return False
+
+ return self.name not in ('-E', '-S', '-c',
+ '-arch', '-fsyntax-only', '-combine', '-x',
+ '-###')
+
class OptionGroup(Option):
"""OptionGroup - A fake option class used to group options so that
the driver can efficiently refer to an entire set of options."""
def __repr__(self):
return 'InputIndex(%d, %d)' % (self.sourceId, self.pos)
-class ArgList:
- """ArgList - Collect an input argument vector along with a set of parsed Args
- and supporting information."""
+class ArgList(object):
+ """ArgList - Collect an input argument vector along with a set of
+ parsed Args and supporting information."""
def __init__(self, parser, argv):
self.parser = parser
self.argv = list(argv)
self.syntheticArgv = []
self.lastArgs = {}
- self.lastGroupArgs = {}
self.args = []
def getArgs(self, option):
def getJoinedValue(self, arg):
return arg.getJoinedValue(self)
+class DerivedArgList(ArgList):
+ def __init__(self, args):
+ super(DerivedArgList, self).__init__(args.parser, args.argv)
+ self.parser = args.parser
+ self.argv = args.argv
+ self.syntheticArgv = args.syntheticArgv
+ self.lastArgs = {}
+ self.args = []
+
###
class OptionParser:
hasTraditionalCPP = args.getLastArg(self.parser.traditionalCPPOption)
hasPipe = args.getLastArg(self.parser.pipeOption)
- # FIXME: forward will die, this isn't really how things are
- # done, instead everything comes from the arglist. For this we
- # need a DerivedArgList for handling -Xarch, and some way to
- # still figure out what to forward to the generic gcc tool.
- forward = []
- for a in args:
- if a.opt is self.parser.inputOption:
- pass
-
- # FIXME: Needs to be part of option.
- elif (a.opt.name in ('-E', '-S', '-c',
- '-arch', '-fsyntax-only', '-combine', '-x',
- '-###') or
- a.opt.isLinkerInput):
- pass
-
- else:
- forward.append(a)
-
# We claim things here so that options for which we silently allow
# override only ever claim the used option.
if hasPipe:
def isOriginalInput(self):
return self.source is self.baseInput
- def createJobs(tc, phase, forwardArgs,
- canAcceptPipe=False, atTopLevel=False, arch=None):
+ def createJobs(tc, phase,
+ canAcceptPipe=False, atTopLevel=False, arch=None,
+ tcArgs=None):
if isinstance(phase, Phases.InputAction):
return InputInfo(phase.filename, phase.type, phase.filename)
elif isinstance(phase, Phases.BindArchAction):
archName = args.getValue(phase.arch)
tc = self.hostInfo.getToolChainForArch(archName)
- filteredArgs = []
- for arg in forwardArgs:
- if arg.opt is self.parser.archOption:
- if arg is phase.arch:
- filteredArgs.append(arg)
- elif arg.opt is self.parser.XarchOption:
- # FIXME: gcc-dd has another conditional for passing
- # through, when the arch conditional array has an empty
- # string. Why?
- if args.getJoinedValue(arg) == archName:
- # FIXME: This is wrong, we don't want a
- # unknown arg we want an actual parsed
- # version of this arg.
- filteredArgs.append(args.makeUnknownArg(args.getSeparateValue(arg)))
- else:
- filteredArgs.append(arg)
-
- return createJobs(tc, phase.inputs[0], filteredArgs,
- canAcceptPipe, atTopLevel, phase.arch)
+ return createJobs(tc, phase.inputs[0],
+ canAcceptPipe, atTopLevel, phase.arch,
+ tcArgs=None)
+
+ if tcArgs is None:
+ tcArgs = tc.translateArgs(args, arch)
assert isinstance(phase, Phases.JobAction)
tool = tc.selectTool(phase)
# Only try to use pipes when exactly one input.
canAcceptPipe = len(inputList) == 1 and tool.acceptsPipedInput()
- inputs = [createJobs(tc, p, forwardArgs, canAcceptPipe, False, arch)
+ inputs = [createJobs(tc, p, canAcceptPipe, False, arch, tcArgs)
for p in inputList]
# Determine if we should output to a pipe.
self.parser.oOption)
tool.constructJob(phase, arch, jobList, inputs, output, phase.type,
- forwardArgs, args)
+ tcArgs)
return InputInfo(output, phase.type, baseInput)
raise ValueError,"Cannot specify -o when generating multiple files."
for phase in phases:
- createJobs(self.toolChain, phase, forward,
+ createJobs(self.toolChain, phase,
canAcceptPipe=True, atTopLevel=True)
return jobs
class GCC_Common_Tool(Tool):
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args, arglist,
+ output, outputType, arglist,
extraArgs):
- cmd_args = sum(map(arglist.render, args),[]) + extraArgs
+ cmd_args = []
+ for arg in arglist.args:
+ if arg.opt.forwardToGCC():
+ cmd_args.extend(arglist.render(arg))
+
+ cmd_args.extend(extraArgs)
if arch:
cmd_args.extend(arglist.render(arch))
if isinstance(output, Jobs.PipedJob):
Tool.eFlagsPipedOutput))
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args, arglist):
+ output, outputType, arglist):
return super(GCC_PreprocessTool, self).constructJob(phase, arch, jobs, inputs,
- output, outputType, args, arglist,
+ output, outputType, arglist,
['-E'])
class GCC_CompileTool(GCC_Common_Tool):
Tool.eFlagsIntegratedCPP))
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args, arglist):
+ output, outputType, arglist):
return super(GCC_CompileTool, self).constructJob(phase, arch, jobs, inputs,
- output, outputType, args, arglist,
+ output, outputType, arglist,
['-S'])
class GCC_PrecompileTool(GCC_Common_Tool):
Tool.eFlagsIntegratedCPP))
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args, arglist):
+ output, outputType, arglist):
return super(GCC_PrecompileTool, self).constructJob(phase, arch, jobs, inputs,
- output, outputType, args, arglist,
+ output, outputType, arglist,
[])
class Darwin_AssembleTool(Tool):
self.toolChain = toolChain
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args, arglist):
+ output, outputType, arglist):
assert len(inputs) == 1
assert outputType is Types.ObjectType
super(GCC_AssembleTool, self).__init__('gcc (as)')
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args, arglist):
+ output, outputType, arglist):
return super(GCC_AssembleTool, self).constructJob(phase, arch, jobs, inputs,
- output, outputType, args, arglist,
+ output, outputType, arglist,
['-c'])
class GCC_LinkTool(GCC_Common_Tool):
super(GCC_LinkTool, self).__init__('gcc (ld)')
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args, arglist):
+ output, outputType, arglist):
return super(GCC_LinkTool, self).constructJob(phase, arch, jobs, inputs,
- output, outputType, args, arglist,
+ output, outputType, arglist,
[])
class Darwin_X86_CompileTool(Tool):
# FIXME: Remove mcpu=G4
# FIXME: Remove mcpu=G5
- if (arglist.getLastArg(arglist.parser.gOption) and
+ if (arglist.getLastArg(arglist.parser.gGroup) and
not arglist.getLastArg(arglist.parser.f_noEliminateUnusedDebugSymbolsOption)):
cmd_args.append('-feliminate-unused-debug-symbols')
return os.path.splitext(self.getBaseInputName(inputs, arglist))[0]
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args, arglist):
+ output, outputType, arglist):
inputType = inputs[0].type
assert not [i for i in inputs if i.type != inputType]
arglist.addLastArg(cmd_args, arglist.parser.MachOption)
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args, arglist):
+ output, outputType, arglist):
assert outputType is Types.ImageType
# The logic here is derived from gcc's behavior; most of which
super(LipoTool, self).__init__('lipo')
def constructJob(self, phase, arch, jobs, inputs,
- output, outputType, args, arglist):
+ output, outputType, arglist):
assert outputType is Types.ImageType
cmd_args = ['-create']