[cfe-commits] r62659 - in /cfe/trunk/tools/ccc/ccclib: Arguments.py Driver.py ToolChain.py Tools.py
Daniel Dunbar
daniel at zuster.org
Tue Jan 20 18:03:52 PST 2009
Author: ddunbar
Date: Tue Jan 20 20:03:52 2009
New Revision: 62659
URL: http://llvm.org/viewvc/llvm-project?rev=62659&view=rev
Log:
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.
Modified:
cfe/trunk/tools/ccc/ccclib/Arguments.py
cfe/trunk/tools/ccc/ccclib/Driver.py
cfe/trunk/tools/ccc/ccclib/ToolChain.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=62659&r1=62658&r2=62659&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Arguments.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Arguments.py Tue Jan 20 20:03:52 2009
@@ -475,7 +475,7 @@
self.dumpversionOption = self.addOption(FlagOption('-dumpversion'))
self.dumpmachineOption = self.addOption(FlagOption('-dumpmachine'))
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
# we take both - and --. For example, gcc --S ... ends up sending
# -fS to cc1. Investigate.
Modified: cfe/trunk/tools/ccc/ccclib/Driver.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Driver.py?rev=62659&r1=62658&r2=62659&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Driver.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Driver.py Tue Jan 20 20:03:52 2009
@@ -78,6 +78,24 @@
###
+ 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):
# FIXME: Things to support from environment: GCC_EXEC_PREFIX,
# COMPILER_PATH, LIBRARY_PATH, LPATH, CC_PRINT_OPTIONS,
@@ -287,50 +305,32 @@
# FIXME: Do we want to report "argument unused" type errors in the
# presence of things like -dumpmachine and -print-search-dirs?
# 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:
- print 'FIXME: %s' % arg.opt.name
- sys.exit(1)
+ raise NotImplementedError('%s unsupported' % arg.opt.name)
- 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:
- print 'FIXME: %s' % arg.opt.name
- sys.exit(1)
-
- arg = args.getLastArg(self.parser.dumpversionOption)
- if arg:
- print 'FIXME: %s' % arg.opt.name
- sys.exit(1)
+ raise Arguments.InvalidArgumentsError('%s unsupported by this driver' % arg.opt.name)
arg = args.getLastArg(self.parser.printFileNameOption)
if arg:
- print 'FIXME: %s' % arg.opt.name
- sys.exit(1)
-
- 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)
+ print self.getFilePath(args.getValue(arg))
+ sys.exit(0)
arg = args.getLastArg(self.parser.printProgNameOption)
if arg:
- print 'FIXME: %s' % arg.opt.name
- sys.exit(1)
-
- arg = args.getLastArg(self.parser.printLibgccFilenameOption)
- if arg:
- print 'FIXME: %s' % arg.opt.name
- sys.exit(1)
+ print self.getProgramPath(args.getValue(arg))
+ sys.exit(0)
- arg = args.getLastArg(self.parser.printSearchDirsOption)
+ arg = args.getLastArg(self.parser.printLibgccFileNameOption)
if arg:
- print 'FIXME: %s' % arg.opt.name
- sys.exit(1)
+ print self.getFilePath('libgcc.a')
+ sys.exit(0)
def buildNormalPipeline(self, args):
hasAnalyze = args.getLastArg(self.parser.analyzeOption)
Modified: cfe/trunk/tools/ccc/ccclib/ToolChain.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/ToolChain.py?rev=62659&r1=62658&r2=62659&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/ToolChain.py (original)
+++ cfe/trunk/tools/ccc/ccclib/ToolChain.py Tue Jan 20 20:03:52 2009
@@ -1,3 +1,5 @@
+import os
+
import Arguments
import Phases
import Tools
@@ -8,8 +10,18 @@
class ToolChain(object):
"""ToolChain - Provide mappings of Actions to Tools."""
- def __init__(self, driver):
+ def __init__(self, driver,
+ filePathPrefixes=[],
+ programPathPrefixes=[]):
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):
"""selectTool - Return a Tool instance to use for handling
@@ -63,14 +75,25 @@
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):
return 'i686-apple-darwin%d/%s' % (self.darwinVersion[0],
'.'.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):
major,minor,minorminor = self.darwinVersion
return '%d.%d.%d' % (10, major-4, minor)
Modified: cfe/trunk/tools/ccc/ccclib/Tools.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Tools.py?rev=62659&r1=62658&r2=62659&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Tools.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Tools.py Tue Jan 20 20:03:52 2009
@@ -285,7 +285,8 @@
else:
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):
def getCC1Name(self, type):
More information about the cfe-commits
mailing list