ccc: Get host information via Driver methods.
llvm-svn: 62011
This commit is contained in:
parent
890d44eb7f
commit
61f97e290a
|
@ -30,6 +30,36 @@ class Driver(object):
|
|||
self.hostInfo = None
|
||||
self.parser = Arguments.OptionParser()
|
||||
|
||||
# Host queries which can be forcibly over-riden by the user for
|
||||
# testing purposes.
|
||||
#
|
||||
# FIXME: We should make sure these are drawn from a fixed set so
|
||||
# that nothing downstream ever plays a guessing game.
|
||||
|
||||
def getHostBits(self):
|
||||
if self.cccHostBits:
|
||||
return self.cccHostBits
|
||||
|
||||
return platform.architecture()[0].replace('bit','')
|
||||
|
||||
def getHostMachine(self):
|
||||
if self.cccHostMachine:
|
||||
return self.cccHostMachine
|
||||
|
||||
machine = platform.machine()
|
||||
# Normalize names.
|
||||
if machine == 'Power Macintosh':
|
||||
return 'ppc'
|
||||
return machine
|
||||
|
||||
def getHostSystemName(self):
|
||||
if self.cccHostSystem:
|
||||
return self.cccHostSystem
|
||||
|
||||
return platform.system().lower()
|
||||
|
||||
###
|
||||
|
||||
def run(self, argv):
|
||||
# FIXME: Things to support from environment: GCC_EXEC_PREFIX,
|
||||
# COMPILER_PATH, LIBRARY_PATH, LPATH, CC_PRINT_OPTIONS,
|
||||
|
@ -41,7 +71,10 @@ class Driver(object):
|
|||
# only allowed at the beginning of the command line.
|
||||
cccPrintOptions = False
|
||||
cccPrintPhases = False
|
||||
cccHostBits = cccHostMachine = cccHostSystem = None
|
||||
|
||||
# FIXME: How to handle override of host? ccc specific options?
|
||||
# Abuse -b?
|
||||
self.cccHostBits = self.cccHostMachine = self.cccHostSystem = None
|
||||
while argv and argv[0].startswith('-ccc-'):
|
||||
opt,argv = argv[0][5:],argv[1:]
|
||||
|
||||
|
@ -50,21 +83,15 @@ class Driver(object):
|
|||
elif opt == 'print-phases':
|
||||
cccPrintPhases = True
|
||||
elif opt == 'host-bits':
|
||||
cccHostBits,argv = argv[0],argv[1:]
|
||||
self.cccHostBits,argv = argv[0],argv[1:]
|
||||
elif opt == 'host-machine':
|
||||
cccHostMachine,argv = argv[0],argv[1:]
|
||||
self.cccHostMachine,argv = argv[0],argv[1:]
|
||||
elif opt == 'host-system':
|
||||
cccHostSystem,argv = argv[0],argv[1:]
|
||||
self.cccHostSystem,argv = argv[0],argv[1:]
|
||||
else:
|
||||
raise ValueError,"Invalid ccc option: %r" % cccPrintOptions
|
||||
|
||||
# FIXME: How to handle override of host? ccc specific options?
|
||||
# Abuse -b?
|
||||
hostBits = cccHostBits or platform.architecture()[0].replace('bit','')
|
||||
hostMachine = cccHostMachine or platform.machine()
|
||||
hostSystem = cccHostSystem or platform.system().lower()
|
||||
self.hostInfo = HostInfo.getHostInfo(self,
|
||||
hostSystem, hostMachine, hostBits)
|
||||
self.hostInfo = HostInfo.getHostInfo(self)
|
||||
|
||||
args = self.parser.parseArgs(argv)
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@ class DarwinX86_64HostInfo(DarwinHostInfo):
|
|||
def getArchName(self):
|
||||
return 'x86_64'
|
||||
|
||||
def getDarwinHostInfo(machine, bits):
|
||||
def getDarwinHostInfo(driver):
|
||||
machine = driver.getHostMachine()
|
||||
bits = driver.getHostBits()
|
||||
if machine == 'i386':
|
||||
if bits == '32':
|
||||
return DarwinX86HostInfo()
|
||||
|
@ -46,7 +48,7 @@ def getDarwinHostInfo(machine, bits):
|
|||
if bits == '64':
|
||||
return DarwinPPC_64HostInfo()
|
||||
|
||||
raise RuntimeError,'Unrecognized Darwin-i386 platform: %r:%r' % (machine, bits)
|
||||
raise RuntimeError,'Unrecognized Darwin platform: %r:%r' % (machine, bits)
|
||||
|
||||
# Unknown
|
||||
|
||||
|
@ -57,7 +59,7 @@ class UnknownHostInfo(HostInfo):
|
|||
def useDriverDriver(self):
|
||||
return False
|
||||
|
||||
def getUnknownHostInfo(machine, bits):
|
||||
def getUnknownHostInfo(driver):
|
||||
return UnknownHostInfo()
|
||||
|
||||
####
|
||||
|
@ -67,10 +69,11 @@ kSystems = {
|
|||
'unknown' : getUnknownHostInfo,
|
||||
}
|
||||
|
||||
def getHostInfo(driver, system, machine, bits):
|
||||
def getHostInfo(driver):
|
||||
system = driver.getHostSystemName()
|
||||
handler = kSystems.get(system)
|
||||
if handler:
|
||||
return handler(machine, bits)
|
||||
return handler(driver)
|
||||
|
||||
driver.warning('Unknown host %r, using generic host information.' % system)
|
||||
return UnknownHostInfo()
|
||||
|
|
|
@ -117,9 +117,8 @@ class Collect2Tool(Tool):
|
|||
|
||||
cmd_args = []
|
||||
for arg in args:
|
||||
if arg.opt:
|
||||
if arg.opt.name in ('-framework',):
|
||||
cmd_args.extend(arglist.render(arg))
|
||||
if arg.opt.name in ('-framework',):
|
||||
cmd_args.extend(arglist.render(arg))
|
||||
for input in inputs:
|
||||
cmd_args.append(arglist.getValue(input.source))
|
||||
cmd_args.extend(arglist.render(output))
|
||||
|
|
Loading…
Reference in New Issue