forked from OSchip/llvm-project
ccc: Implement file & path searching.
- Toolchain is responsible for providing list of prefixes to search. - Implement -print-file-name=xxx and -print-prog-name=xxx driver options. llvm-svn: 62659
This commit is contained in:
parent
43c2bab6d3
commit
a184754570
|
@ -475,7 +475,7 @@ class OptionParser:
|
||||||
self.dumpversionOption = self.addOption(FlagOption('-dumpversion'))
|
self.dumpversionOption = self.addOption(FlagOption('-dumpversion'))
|
||||||
self.dumpmachineOption = self.addOption(FlagOption('-dumpmachine'))
|
self.dumpmachineOption = self.addOption(FlagOption('-dumpmachine'))
|
||||||
self.printSearchDirsOption = self.addOption(FlagOption('-print-search-dirs'))
|
self.printSearchDirsOption = self.addOption(FlagOption('-print-search-dirs'))
|
||||||
self.printLibgccFilenameOption = self.addOption(FlagOption('-print-libgcc-file-name'))
|
self.printLibgccFileNameOption = self.addOption(FlagOption('-print-libgcc-file-name'))
|
||||||
# FIXME: Hrm, where does this come from? It isn't always true that
|
# FIXME: Hrm, where does this come from? It isn't always true that
|
||||||
# we take both - and --. For example, gcc --S ... ends up sending
|
# we take both - and --. For example, gcc --S ... ends up sending
|
||||||
# -fS to cc1. Investigate.
|
# -fS to cc1. Investigate.
|
||||||
|
|
|
@ -78,6 +78,24 @@ class Driver(object):
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
def getFilePath(self, name, toolChain=None):
|
||||||
|
tc = toolChain or self.toolChain
|
||||||
|
for p in tc.filePathPrefixes:
|
||||||
|
path = os.path.join(p, name)
|
||||||
|
if os.path.exists(path):
|
||||||
|
return path
|
||||||
|
return name
|
||||||
|
|
||||||
|
def getProgramPath(self, name, toolChain=None):
|
||||||
|
tc = toolChain or self.toolChain
|
||||||
|
for p in tc.programPathPrefixes:
|
||||||
|
path = os.path.join(p, name)
|
||||||
|
if os.path.exists(path):
|
||||||
|
return path
|
||||||
|
return name
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
def run(self, argv):
|
def run(self, argv):
|
||||||
# FIXME: Things to support from environment: GCC_EXEC_PREFIX,
|
# FIXME: Things to support from environment: GCC_EXEC_PREFIX,
|
||||||
# COMPILER_PATH, LIBRARY_PATH, LPATH, CC_PRINT_OPTIONS,
|
# COMPILER_PATH, LIBRARY_PATH, LPATH, CC_PRINT_OPTIONS,
|
||||||
|
@ -287,50 +305,32 @@ class Driver(object):
|
||||||
# FIXME: Do we want to report "argument unused" type errors in the
|
# FIXME: Do we want to report "argument unused" type errors in the
|
||||||
# presence of things like -dumpmachine and -print-search-dirs?
|
# presence of things like -dumpmachine and -print-search-dirs?
|
||||||
# Probably not.
|
# Probably not.
|
||||||
arg = args.getLastArg(self.parser.dumpmachineOption)
|
arg = (args.getLastArg(self.parser.dumpmachineOption) or
|
||||||
|
args.getLastArg(self.parser.dumpversionOption) or
|
||||||
|
args.getLastArg(self.parser.printSearchDirsOption))
|
||||||
if arg:
|
if arg:
|
||||||
print 'FIXME: %s' % arg.opt.name
|
raise NotImplementedError('%s unsupported' % arg.opt.name)
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
arg = args.getLastArg(self.parser.dumpspecsOption)
|
arg = (args.getLastArg(self.parser.dumpspecsOption) or
|
||||||
|
args.getLastArg(self.parser.printMultiDirectoryOption) or
|
||||||
|
args.getLastArg(self.parser.printMultiLibOption))
|
||||||
if arg:
|
if arg:
|
||||||
print 'FIXME: %s' % arg.opt.name
|
raise Arguments.InvalidArgumentsError('%s unsupported by this driver' % arg.opt.name)
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
arg = args.getLastArg(self.parser.dumpversionOption)
|
|
||||||
if arg:
|
|
||||||
print 'FIXME: %s' % arg.opt.name
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
arg = args.getLastArg(self.parser.printFileNameOption)
|
arg = args.getLastArg(self.parser.printFileNameOption)
|
||||||
if arg:
|
if arg:
|
||||||
print 'FIXME: %s' % arg.opt.name
|
print self.getFilePath(args.getValue(arg))
|
||||||
sys.exit(1)
|
sys.exit(0)
|
||||||
|
|
||||||
arg = args.getLastArg(self.parser.printMultiDirectoryOption)
|
|
||||||
if arg:
|
|
||||||
print 'FIXME: %s' % arg.opt.name
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
arg = args.getLastArg(self.parser.printMultiLibOption)
|
|
||||||
if arg:
|
|
||||||
print 'FIXME: %s' % arg.opt.name
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
arg = args.getLastArg(self.parser.printProgNameOption)
|
arg = args.getLastArg(self.parser.printProgNameOption)
|
||||||
if arg:
|
if arg:
|
||||||
print 'FIXME: %s' % arg.opt.name
|
print self.getProgramPath(args.getValue(arg))
|
||||||
sys.exit(1)
|
sys.exit(0)
|
||||||
|
|
||||||
arg = args.getLastArg(self.parser.printLibgccFilenameOption)
|
arg = args.getLastArg(self.parser.printLibgccFileNameOption)
|
||||||
if arg:
|
if arg:
|
||||||
print 'FIXME: %s' % arg.opt.name
|
print self.getFilePath('libgcc.a')
|
||||||
sys.exit(1)
|
sys.exit(0)
|
||||||
|
|
||||||
arg = args.getLastArg(self.parser.printSearchDirsOption)
|
|
||||||
if arg:
|
|
||||||
print 'FIXME: %s' % arg.opt.name
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def buildNormalPipeline(self, args):
|
def buildNormalPipeline(self, args):
|
||||||
hasAnalyze = args.getLastArg(self.parser.analyzeOption)
|
hasAnalyze = args.getLastArg(self.parser.analyzeOption)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import os
|
||||||
|
|
||||||
import Arguments
|
import Arguments
|
||||||
import Phases
|
import Phases
|
||||||
import Tools
|
import Tools
|
||||||
|
@ -8,8 +10,18 @@ import Types
|
||||||
class ToolChain(object):
|
class ToolChain(object):
|
||||||
"""ToolChain - Provide mappings of Actions to Tools."""
|
"""ToolChain - Provide mappings of Actions to Tools."""
|
||||||
|
|
||||||
def __init__(self, driver):
|
def __init__(self, driver,
|
||||||
|
filePathPrefixes=[],
|
||||||
|
programPathPrefixes=[]):
|
||||||
self.driver = driver
|
self.driver = driver
|
||||||
|
self.filePathPrefixes = list(filePathPrefixes)
|
||||||
|
self.programPathPrefixes = list(programPathPrefixes)
|
||||||
|
|
||||||
|
def getFilePath(self, name):
|
||||||
|
return self.driver.getFilePath(name, self)
|
||||||
|
|
||||||
|
def getProgramPath(self, name):
|
||||||
|
return self.driver.getProgramPath(name, self)
|
||||||
|
|
||||||
def selectTool(self, action):
|
def selectTool(self, action):
|
||||||
"""selectTool - Return a Tool instance to use for handling
|
"""selectTool - Return a Tool instance to use for handling
|
||||||
|
@ -63,14 +75,25 @@ class Darwin_X86_ToolChain(ToolChain):
|
||||||
Phases.LipoPhase : Tools.LipoTool(),
|
Phases.LipoPhase : Tools.LipoTool(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.filePathPrefixes.append(os.path.join(self.driver.driverDir,
|
||||||
|
'../lib/gcc',
|
||||||
|
self.getToolChainDir()))
|
||||||
|
self.filePathPrefixes.append(os.path.join(self.driver.driverDir,
|
||||||
|
'/usr/lib/gcc',
|
||||||
|
self.getToolChainDir()))
|
||||||
|
|
||||||
|
self.programPathPrefixes.append(os.path.join(self.driver.driverDir,
|
||||||
|
'../libexec/gcc',
|
||||||
|
self.getToolChainDir()))
|
||||||
|
self.programPathPrefixes.append(os.path.join(self.driver.driverDir,
|
||||||
|
'/usr/libexec/gcc',
|
||||||
|
self.getToolChainDir()))
|
||||||
|
self.programPathPrefixes.append(self.driver.driverDir)
|
||||||
|
|
||||||
def getToolChainDir(self):
|
def getToolChainDir(self):
|
||||||
return 'i686-apple-darwin%d/%s' % (self.darwinVersion[0],
|
return 'i686-apple-darwin%d/%s' % (self.darwinVersion[0],
|
||||||
'.'.join(map(str,self.gccVersion)))
|
'.'.join(map(str,self.gccVersion)))
|
||||||
|
|
||||||
def getProgramPath(self, name):
|
|
||||||
# FIXME: Implement proper search.
|
|
||||||
return '/usr/libexec/gcc/%s/%s' % (self.getToolChainDir(), name)
|
|
||||||
|
|
||||||
def getMacosxVersionMin(self):
|
def getMacosxVersionMin(self):
|
||||||
major,minor,minorminor = self.darwinVersion
|
major,minor,minorminor = self.darwinVersion
|
||||||
return '%d.%d.%d' % (10, major-4, minor)
|
return '%d.%d.%d' % (10, major-4, minor)
|
||||||
|
|
|
@ -285,7 +285,8 @@ class Clang_CompileTool(Tool):
|
||||||
else:
|
else:
|
||||||
cmd_args.extend(arglist.renderAsInput(input.source))
|
cmd_args.extend(arglist.renderAsInput(input.source))
|
||||||
|
|
||||||
jobs.addJob(Jobs.Command('clang', cmd_args))
|
jobs.addJob(Jobs.Command(self.toolChain.getProgramPath('clang'),
|
||||||
|
cmd_args))
|
||||||
|
|
||||||
class Darwin_X86_CC1Tool(Tool):
|
class Darwin_X86_CC1Tool(Tool):
|
||||||
def getCC1Name(self, type):
|
def getCC1Name(self, type):
|
||||||
|
|
Loading…
Reference in New Issue