[Distutils] link_executable for msvccompiler

Berthold Hoellmann hoel@germanlloyd.org
Thu, 13 Apr 2000 15:23:13 +0200


Hello,

I had urgent need for link_executable for msvccompiler. So I took
link_shared_object, copied to link_executable and made it work for
executables. See the attached result of my hacking:

Cheers

Berthold

(insert the following to msvccompiler.py)

    def link_executable (self,
                         objects,
                         output_execname,
                         output_dir=None,
                         libraries=None,
                         library_dirs=None,
                         runtime_library_dirs=None,
                         debug=0,
                         extra_preargs=None,
                         extra_postargs=None):

        output_filename = output_execname + self.exe_extension
        (objects, output_dir) = self._fix_object_args (objects,
output_dir)
        (libraries, library_dirs, runtime_library_dirs) = \
            self._fix_lib_args (libraries, library_dirs,
runtime_library_dirs)

        if self.runtime_library_dirs:
            self.warn ("I don't know what to do with
'runtime_library_dirs': "
                       + str (runtime_library_dirs))
        
        lib_opts = gen_lib_options (self,
                                    library_dirs, runtime_library_dirs,
                                    libraries)
        if type (output_dir) not in (StringType, NoneType):
            raise TypeError, "'output_dir' must be a string or None"
        if output_dir is not None:
            output_filename = os.path.join (output_dir, output_filename)

        if self._need_link (objects, output_filename):

            if debug:
                ldflags = self.ldflags_shared_debug[1:]
            else:
                ldflags = self.ldflags_shared[1:]

            ld_args = ldflags + lib_opts + \
                      objects + ['/OUT:' + output_filename]

            if extra_preargs:
                ld_args[:0] = extra_preargs
            if extra_postargs:
                ld_args.extend (extra_postargs)

            self.mkpath (os.path.dirname (output_filename))
            self.spawn ([self.link] + ld_args)

        else:
            self.announce ("skipping %s (up-to-date)" % output_filename)
    

-- 
email: hoel@GermanLloyd.org
   )
  (
C[_]  These opinions might be mine, but never those of my employer.