コード例 #1
0
ファイル: mingw32ccompiler.py プロジェクト: shmuller/numpy
    def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
        if output_dir is None: output_dir = ''
        obj_names = []
        for src_name in source_filenames:
            # use normcase to make sure '.rc' is really '.rc' and not '.RC'
            (base, ext) = os.path.splitext(os.path.normcase(src_name))

            # added these lines to strip off windows drive letters
            # without it, .o files are placed next to .c files
            # instead of the build directory
            drv, base = os.path.splitdrive(base)
            if drv:
                base = base[1:]

            if ext not in (self.src_extensions + ['.rc', '.res']):
                raise UnknownFileError(
                      "unknown file type '%s' (from '%s')" % \
                      (ext, src_name))
            if strip_dir:
                base = os.path.basename(base)
            if ext == '.res' or ext == '.rc':
                # these need to be compiled to object files
                obj_names.append(
                    os.path.join(output_dir, base + ext + self.obj_extension))
            else:
                obj_names.append(
                    os.path.join(output_dir, base + self.obj_extension))
        return obj_names
コード例 #2
0
 def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
     if output_dir is None:
         output_dir = ''
     obj_names = []
     for src_name in source_filenames:
         base, ext = os.path.splitext(src_name)
         base = self._mangle_base(base)
         if ext not in self.src_extensions:
             raise UnknownFileError(
                 "unknown file type '{}' (from '{}')".format(ext, src_name))
         if strip_dir:
             base = os.path.basename(base)
         obj_names.append(
             os.path.join(output_dir, base + self.obj_extension))
     return obj_names
コード例 #3
0
ファイル: ccompiler.py プロジェクト: zushilong003/jython3
 def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
     if output_dir is None:
         output_dir = ''
     obj_names = []
     for src_name in source_filenames:
         base, ext = os.path.splitext(src_name)
         base = os.path.splitdrive(base)[1] # Chop off the drive
         base = base[os.path.isabs(base):]  # If abs, chop off leading /
         if ext not in self.src_extensions:
             raise UnknownFileError("unknown file type '%s' (from '%s')" % (ext, src_name))
         if strip_dir:
             base = os.path.basename(base)
         obj_names.append(os.path.join(output_dir,
                                       base + self.obj_extension))
     return obj_names
コード例 #4
0
def CCompiler_object_filenames(self,
                               source_filenames,
                               strip_dir=0,
                               output_dir=''):
    """
    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
        Whether to strip the directory from the returned paths. If True,
        the file name prepended by `output_dir` is returned. Default is False.
    output_dir : str, optional
        If given, this path is prepended to the returned paths to the
        object files.

    Returns
    -------
    obj_names : list of str
        The list of paths to the object files corresponding to the source
        files in `source_filenames`.

    """
    if output_dir is None:
        output_dir = ''
    obj_names = []
    for src_name in source_filenames:
        base, ext = os.path.splitext(os.path.normpath(src_name))
        base = os.path.splitdrive(base)[1]  # Chop off the drive
        base = base[os.path.isabs(base):]  # If abs, chop off leading /
        if base.startswith('..'):
            # Resolve starting relative path components, middle ones
            # (if any) have been handled by os.path.normpath above.
            i = base.rfind('..') + 2
            d = base[:i]
            d = os.path.basename(os.path.abspath(d))
            base = d + base[i:]
        if ext not in self.src_extensions:
            raise UnknownFileError("unknown file type '%s' (from '%s')" %
                                   (ext, src_name))
        if strip_dir:
            base = os.path.basename(base)
        obj_name = os.path.join(output_dir, base + self.obj_extension)
        obj_names.append(obj_name)
    return obj_names
コード例 #5
0
 def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
     if output_dir is None: output_dir = ''
     obj_names = []
     for src_name in source_filenames:
         # use normcase to make sure '.rc' is really '.rc' and not '.RC'
         (base, ext) = os.path.splitext(os.path.normcase(src_name))
         if ext not in (self.src_extensions + ['.rc']):
             raise UnknownFileError("unknown file type '%s' (from '%s')" % \
                   (ext, src_name))
         if strip_dir:
             base = os.path.basename(base)
         if ext == '.rc':
             # these need to be compiled to object files
             obj_names.append(
                 os.path.join(output_dir, base + self.res_extension))
         else:
             obj_names.append(
                 os.path.join(output_dir, base + self.obj_extension))
     return obj_names
コード例 #6
0
 def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
     """Adds supports for rc and res files."""
     if output_dir is None:
         output_dir = ''
     obj_names = []
     for src_name in source_filenames:
         base, ext = os.path.splitext(os.path.normcase(src_name))
         if ext not in self.src_extensions + ['.rc', '.res']:
             raise UnknownFileError("unknown file type '%s' (from '%s')" %
                                    (ext, src_name))
         if strip_dir:
             base = os.path.basename(base)
         if ext in ('.res', '.rc'):
             obj_names.append(
                 os.path.join(output_dir, base + ext + self.obj_extension))
         else:
             obj_names.append(
                 os.path.join(output_dir, base + self.obj_extension))
     return obj_names
コード例 #7
0
 def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
     """Adds supports for rc and res files."""
     if output_dir is None:
         output_dir = ''
     obj_names = []
     for src_name in source_filenames:
         # use normcase to make sure '.rc' is really '.rc' and not '.RC'
         base, ext = os.path.splitext(os.path.normcase(src_name))
         if ext not in (self.src_extensions + ['.rc', '.res']):
             raise UnknownFileError(
                 "unknown file type '{}' (from '{}')".format(ext, src_name))
         if strip_dir:
             base = os.path.basename(base)
         if ext in ('.res', '.rc'):
             # these need to be compiled to object files
             obj_names.append(
                 os.path.join(output_dir, base + ext + self.obj_extension))
         else:
             obj_names.append(
                 os.path.join(output_dir, base + self.obj_extension))
     return obj_names
コード例 #8
0
 def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
     """Adds supports for rc and res files."""
     if output_dir is None:
         output_dir = ''
     obj_names = []
     for src_name in source_filenames:
         base, ext = os.path.splitext(src_name)
         base = os.path.splitdrive(base)[1]  # Chop off the drive
         base = base[os.path.isabs(base):]  # If abs, chop off leading /
         if ext not in (self.src_extensions + self._rc_extensions):
             raise UnknownFileError("unknown file type '%s' (from '%s')" % \
                   (ext, src_name))
         if strip_dir:
             base = os.path.basename(base)
         if ext in self._rc_extensions:
             # these need to be compiled to object files
             obj_names.append(
                 os.path.join(output_dir, base + self.res_extension))
         else:
             obj_names.append(
                 os.path.join(output_dir, base + self.obj_extension))
     return obj_names