Return the name of the object files for the given source files. Parameters ---------- source_filenames : list of str The list of paths to source files. Paths can be either relative or absolute, this is handled transparently. strip_dir : bool, optional Wh
(self, source_filenames, strip_dir=0, output_dir='')
| 185 | replace_method(CCompiler, 'spawn', CCompiler_spawn) |
| 186 | |
| 187 | def CCompiler_object_filenames(self, source_filenames, strip_dir=0, output_dir=''): |
| 188 | """ |
| 189 | Return the name of the object files for the given source files. |
| 190 | |
| 191 | Parameters |
| 192 | ---------- |
| 193 | source_filenames : list of str |
| 194 | The list of paths to source files. Paths can be either relative or |
| 195 | absolute, this is handled transparently. |
| 196 | strip_dir : bool, optional |
| 197 | Whether to strip the directory from the returned paths. If True, |
| 198 | the file name prepended by `output_dir` is returned. Default is False. |
| 199 | output_dir : str, optional |
| 200 | If given, this path is prepended to the returned paths to the |
| 201 | object files. |
| 202 | |
| 203 | Returns |
| 204 | ------- |
| 205 | obj_names : list of str |
| 206 | The list of paths to the object files corresponding to the source |
| 207 | files in `source_filenames`. |
| 208 | |
| 209 | """ |
| 210 | if output_dir is None: |
| 211 | output_dir = '' |
| 212 | obj_names = [] |
| 213 | for src_name in source_filenames: |
| 214 | base, ext = os.path.splitext(os.path.normpath(src_name)) |
| 215 | base = os.path.splitdrive(base)[1] # Chop off the drive |
| 216 | base = base[os.path.isabs(base):] # If abs, chop off leading / |
| 217 | if base.startswith('..'): |
| 218 | # Resolve starting relative path components, middle ones |
| 219 | # (if any) have been handled by os.path.normpath above. |
| 220 | i = base.rfind('..')+2 |
| 221 | d = base[:i] |
| 222 | d = os.path.basename(os.path.abspath(d)) |
| 223 | base = d + base[i:] |
| 224 | if ext not in self.src_extensions: |
| 225 | raise UnknownFileError("unknown file type '%s' (from '%s')" % (ext, src_name)) |
| 226 | if strip_dir: |
| 227 | base = os.path.basename(base) |
| 228 | obj_name = os.path.join(output_dir, base + self.obj_extension) |
| 229 | obj_names.append(obj_name) |
| 230 | return obj_names |
| 231 | |
| 232 | replace_method(CCompiler, 'object_filenames', CCompiler_object_filenames) |
| 233 |
nothing calls this directly
no test coverage detected