|
40 | 40 | except ImportError:
|
41 | 41 | pass
|
42 | 42 |
|
43 |
| -from .strutils import PY3_4_OR_HIGHER, get_mac_host_type, get_windows_host_type, \ |
| 43 | +from .strutils import get_mac_host_type, get_windows_host_type, \ |
44 | 44 | IS_LINUX, convert_to_windows_slashes
|
45 | 45 |
|
46 | 46 | from .buildutils import is_exe, find_in_path, _WINDOWS_ENV_PATHS
|
|
81 | 81 | ########################################
|
82 | 82 |
|
83 | 83 |
|
84 |
| -def where_is_xcode(xcode_version=None): |
85 |
| - """ |
86 |
| - Locate xcodebuild for a specific version of XCode. |
87 |
| -
|
88 |
| - Given a specific version by version, scan the locations that the IDE would |
89 |
| - be found. |
90 |
| -
|
91 |
| - Example: |
92 |
| - >>> burger.where_is_xcode() |
93 |
| - ("/Developer/usr/bin/xcodebuild", 3) |
94 |
| - >>> burger.where_is_xcode(2093) |
95 |
| - None |
96 |
| -
|
97 |
| - Note: |
98 |
| - This function will always return None on non-macOS hosts. |
99 |
| - Minimum version of XCode is 3. |
100 |
| -
|
101 |
| - Args: |
102 |
| - xcode_version: Version number |
103 |
| - Returns: |
104 |
| - Path to xcodebuild for the XCode version or None. |
105 |
| - """ |
106 |
| - |
107 |
| - # pylint: disable=too-many-branches |
108 |
| - |
109 |
| - # Test if running on a mac host |
110 |
| - host_type = get_mac_host_type() |
111 |
| - if not host_type: |
112 |
| - return None |
113 |
| - |
114 |
| - # Only import on macosx hosts |
115 |
| - # pylint: disable=import-outside-toplevel |
116 |
| - import plistlib |
117 |
| - |
118 |
| - # XCode 5 and higher reside in the app folder |
119 |
| - highest_version = 0 |
120 |
| - xcodebuild = None |
121 |
| - |
122 |
| - # Version 3 and 4 is in /Developer while all |
123 |
| - # others are in /Applications |
124 |
| - |
125 |
| - dir_list = [] |
126 |
| - if xcode_version is None or xcode_version < 5: |
127 |
| - dir_list.append("/Developer/Applications") |
128 |
| - if xcode_version is None or xcode_version > 3: |
129 |
| - dir_list.append("/Applications") |
130 |
| - |
131 |
| - for base_dir in dir_list: |
132 |
| - # Check if the directory exists first |
133 |
| - if os.path.isdir(base_dir): |
134 |
| - |
135 |
| - # Scan the applications folder for all apps called "XCode" |
136 |
| - for item in os.listdir(base_dir): |
137 |
| - |
138 |
| - # Scan only apps whose name starts with xcode |
139 |
| - if not item.lower().startswith("xcode"): |
140 |
| - continue |
141 |
| - |
142 |
| - temp_path = base_dir + "/" + item + "/Contents/version.plist" |
143 |
| - try: |
144 |
| - # pylint: disable=no-member |
145 |
| - if PY3_4_OR_HIGHER: |
146 |
| - with open(temp_path, "rb") as filefp: |
147 |
| - version_dict = plistlib.load(filefp) |
148 |
| - else: |
149 |
| - version_dict = plistlib.readPlist( |
150 |
| - temp_path) |
151 |
| - |
152 |
| - # Any IO error is acceptable to ignore |
153 |
| - except IOError: |
154 |
| - continue |
155 |
| - |
156 |
| - version = version_dict.get("CFBundleShortVersionString", None) |
157 |
| - if not version: |
158 |
| - continue |
159 |
| - |
160 |
| - # Check the version for a match |
161 |
| - version = int(version.split(".")[0]) |
162 |
| - |
163 |
| - # XCode 3 is hard coded to Developer |
164 |
| - if version == 3: |
165 |
| - temp_path = "/Developer/usr/bin/xcodebuild" |
166 |
| - else: |
167 |
| - temp_path = ( |
168 |
| - "{}/{}/Contents/Developer" |
169 |
| - "/usr/bin/xcodebuild").format(base_dir, item) |
170 |
| - |
171 |
| - if not os.path.isfile(temp_path): |
172 |
| - continue |
173 |
| - |
174 |
| - if xcode_version: |
175 |
| - # If scanning for a perfect match, exit if found |
176 |
| - if version == xcode_version: |
177 |
| - highest_version = version |
178 |
| - return (temp_path, version) |
179 |
| - |
180 |
| - # Scan for the most recent version of XCode |
181 |
| - elif version > highest_version: |
182 |
| - highest_version = version |
183 |
| - xcodebuild = (temp_path, version) |
184 |
| - |
185 |
| - # XCode 3 is hard coded to a specific location |
186 |
| - if (not xcode_version and not highest_version) or xcode_version == 3: |
187 |
| - # On OSX Lion and higher, XCode 3.1.4 is a separate folder |
188 |
| - for item in ("/Xcode3.1.4/usr/bin/xcodebuild",): |
189 |
| - if os.path.isfile(item): |
190 |
| - xcodebuild = (item, 3) |
191 |
| - break |
192 |
| - |
193 |
| - return xcodebuild |
194 |
| - |
195 |
| -######################################## |
196 |
| - |
197 |
| - |
198 | 84 | def _get_codeblocks_registry_path():
|
199 | 85 | """
|
200 | 86 | Locate codeblocks path using the Window Registry
|
@@ -614,7 +500,8 @@ def where_is_visual_studio(vs_version, tool_name=None, cpu=None):
|
614 | 500 |
|
615 | 501 | Examples:
|
616 | 502 | >>> burger.where_is_visual_studio(2010)
|
617 |
| - "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\ide\\devenv.com" |
| 503 | + "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0" |
| 504 | + "\\Common7\\ide\\devenv.com" |
618 | 505 |
|
619 | 506 | Args:
|
620 | 507 | vs_version: Version year as number
|
|
0 commit comments