blob: ccfd32b1372e95f7e92478e2f014be2e80d016b2 [file] [log] [blame]
Daniel Dunbar9066af82009-01-09 01:00:40 +00001class HostInfo(object):
2 """HostInfo - Config information about a particular host which may
3 interact with driver behavior. This can be very different from the
4 target(s) of a particular driver invocation."""
5
6 def __init__(self):
7 pass
8
9 def getArchName(self):
10 abstract
11
12 def useDriverDriver(self):
13 abstract
14
15# Darwin
16
17class DarwinHostInfo(HostInfo):
18 def useDriverDriver(self):
19 return True
20
21class DarwinPPCHostInfo(DarwinHostInfo):
22 def getArchName(self):
23 return 'ppc'
24
25class DarwinPPC_64HostInfo(DarwinHostInfo):
26 def getArchName(self):
27 return 'ppc64'
28
29class DarwinX86HostInfo(DarwinHostInfo):
30 def getArchName(self):
31 return 'i386'
32
33class DarwinX86_64HostInfo(DarwinHostInfo):
34 def getArchName(self):
35 return 'x86_64'
36
37def getDarwinHostInfo(machine, bits):
38 if machine == 'i386':
39 if bits == '32':
40 return DarwinX86HostInfo()
41 if bits == '64':
42 return DarwinX86_64HostInfo()
43 elif machine == 'ppc':
44 if bits == '32':
45 return DarwinPPCHostInfo()
46 if bits == '64':
47 return DarwinPPC_64HostInfo()
48
49 raise RuntimeError,'Unrecognized Darwin-i386 platform: %r:%r' % (machine, bits)
50
51# Unknown
52
53class UnknownHostInfo(HostInfo):
54 def getArchName(self):
55 raise RuntimeError,'getArchName() unsupported on unknown host.'
56
57 def useDriverDriver(self):
58 return False
59
60def getUnknownHostInfo(machine, bits):
61 return UnknownHostInfo()
62
63####
64
65kSystems = {
66 'darwin' : getDarwinHostInfo,
67 'unknown' : getUnknownHostInfo,
68 }
69
70def getHostInfo(driver, system, machine, bits):
71 handler = kSystems.get(system)
72 if handler:
73 return handler(machine, bits)
74
75 driver.warning('Unknown host %r, using generic host information.' % system)
76 return UnknownHostInfo()