OLD | NEW |
---|---|
1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 | 71 |
72 | 72 |
73 class PortFactory(object): | 73 class PortFactory(object): |
74 PORT_CLASSES = ( | 74 PORT_CLASSES = ( |
75 'android.AndroidPort', | 75 'android.AndroidPort', |
76 'linux.LinuxPort', | 76 'linux.LinuxPort', |
77 'mac.MacPort', | 77 'mac.MacPort', |
78 'win.WinPort', | 78 'win.WinPort', |
79 'mock_drt.MockDRTPort', | 79 'mock_drt.MockDRTPort', |
80 'test.TestPort', | 80 'test.TestPort', |
81 'browser_test.BrowserTestPort', | |
81 ) | 82 ) |
82 | 83 |
83 def __init__(self, host): | 84 def __init__(self, host): |
84 self._host = host | 85 self._host = host |
85 | 86 |
86 def _default_port(self, options): | 87 def _default_port(self, options): |
87 platform = self._host.platform | 88 platform = self._host.platform |
88 if platform.is_linux() or platform.is_freebsd(): | 89 if platform.is_linux() or platform.is_freebsd(): |
89 return 'linux' | 90 return 'linux' |
90 elif platform.is_mac(): | 91 elif platform.is_mac(): |
91 return 'mac' | 92 return 'mac' |
92 elif platform.is_win(): | 93 elif platform.is_win(): |
93 return 'win' | 94 return 'win' |
94 raise NotImplementedError('unknown platform: %s' % platform) | 95 raise NotImplementedError('unknown platform: %s' % platform) |
95 | 96 |
96 def get(self, port_name=None, options=None, **kwargs): | 97 def get(self, port_name=None, options=None, **kwargs): |
97 """Returns an object implementing the Port interface. If | 98 """Returns an object implementing the Port interface. If |
98 port_name is None, this routine attempts to guess at the most | 99 port_name is None, this routine attempts to guess at the most |
99 appropriate port on this platform.""" | 100 appropriate port on this platform.""" |
100 port_name = port_name or self._default_port(options) | 101 port_name = port_name or self._default_port(options) |
101 | 102 |
102 # FIXME(steveblock): There's no longer any need to pass '--platform | 103 # FIXME(steveblock): There's no longer any need to pass '--platform |
103 # chromium' on the command line so we can remove this logic. | 104 # chromium' on the command line so we can remove this logic. |
104 if port_name == 'chromium': | 105 if port_name == 'chromium': |
105 port_name = self._host.platform.os_name | 106 port_name = self._host.platform.os_name |
106 | 107 |
107 for port_class in self.PORT_CLASSES: | 108 for port_class in self.PORT_CLASSES: |
108 module_name, class_name = port_class.rsplit('.', 1) | 109 module_name, class_name = port_class.rsplit('.', 1) |
109 module = __import__(module_name, globals(), locals(), [], -1) | 110 module = __import__(module_name, globals(), locals(), [], -1) |
111 | |
Dirk Pranke
2014/07/10 23:37:13
nit: delete the stray blank line?
ivandavid
2014/07/16 21:29:01
Done.
| |
110 cls = module.__dict__[class_name] | 112 cls = module.__dict__[class_name] |
111 if port_name.startswith(cls.port_name): | 113 if port_name.startswith(cls.port_name): |
112 port_name = cls.determine_full_port_name(self._host, options, po rt_name) | 114 port_name = cls.determine_full_port_name(self._host, options, po rt_name) |
113 return cls(self._host, port_name, options=options, **kwargs) | 115 return cls(self._host, port_name, options=options, **kwargs) |
114 raise NotImplementedError('unsupported platform: "%s"' % port_name) | 116 raise NotImplementedError('unsupported platform: "%s"' % port_name) |
115 | 117 |
116 def all_port_names(self, platform=None): | 118 def all_port_names(self, platform=None): |
117 """Return a list of all valid, fully-specified, "real" port names. | 119 """Return a list of all valid, fully-specified, "real" port names. |
118 | 120 |
119 This is the list of directories that are used as actual baseline_paths() | 121 This is the list of directories that are used as actual baseline_paths() |
120 by real ports. This does not include any "fake" names like "test" | 122 by real ports. This does not include any "fake" names like "test" |
121 or "mock-mac", and it does not include any directories that are not. | 123 or "mock-mac", and it does not include any directories that are not. |
122 | 124 |
123 If platform is not specified, we will glob-match all ports""" | 125 If platform is not specified, we will glob-match all ports""" |
124 platform = platform or '*' | 126 platform = platform or '*' |
125 return fnmatch.filter(builders.all_port_names(), platform) | 127 return fnmatch.filter(builders.all_port_names(), platform) |
126 | 128 |
127 def get_from_builder_name(self, builder_name): | 129 def get_from_builder_name(self, builder_name): |
128 port_name = builders.port_name_for_builder_name(builder_name) | 130 port_name = builders.port_name_for_builder_name(builder_name) |
129 assert port_name, "unrecognized builder name '%s'" % builder_name | 131 assert port_name, "unrecognized builder name '%s'" % builder_name |
130 return self.get(port_name, _builder_options(builder_name)) | 132 return self.get(port_name, _builder_options(builder_name)) |
OLD | NEW |