コード例 #1
0
    def link(
        self,
        target_desc,
        objects,
        output_filename,
        output_dir=None,
        libraries=None,
        library_dirs=None,
        runtime_library_dirs=None,
        export_symbols=None,
        debug=0,
        extra_preargs=None,
        extra_postargs=None,
        build_temp=None,
        target_lang=None,
    ):
        extra_preargs = copy.copy(extra_preargs or [])
        libraries = copy.copy(libraries or [])
        objects = copy.copy(objects or [])
        libraries.extend(self.dll_libraries)
        if export_symbols is not None and (target_desc != self.EXECUTABLE or self.linker_dll == "gcc"):
            temp_dir = os.path.dirname(objects[0])
            dll_name, dll_extension = os.path.splitext(os.path.basename(output_filename))
            def_file = os.path.join(temp_dir, dll_name + ".def")
            lib_file = os.path.join(temp_dir, "lib" + dll_name + ".a")
            contents = ["LIBRARY %s" % os.path.basename(output_filename), "EXPORTS"]
            for sym in export_symbols:
                contents.append(sym)

            self.execute(write_file, (def_file, contents), "writing %s" % def_file)
            if self.linker_dll == "dllwrap":
                extra_preargs.extend(["--output-lib", lib_file])
                extra_preargs.extend(["--def", def_file])
            else:
                objects.append(def_file)
        if not debug:
            extra_preargs.append("-s")
        UnixCCompiler.link(
            self,
            target_desc,
            objects,
            output_filename,
            output_dir,
            libraries,
            library_dirs,
            runtime_library_dirs,
            None,
            debug,
            extra_preargs,
            extra_postargs,
            build_temp,
            target_lang,
        )
        return
コード例 #2
0
ファイル: emxccompiler.py プロジェクト: webiumsk/WOT-0.9.12
    def link(
        self,
        target_desc,
        objects,
        output_filename,
        output_dir=None,
        libraries=None,
        library_dirs=None,
        runtime_library_dirs=None,
        export_symbols=None,
        debug=0,
        extra_preargs=None,
        extra_postargs=None,
        build_temp=None,
        target_lang=None,
    ):
        extra_preargs = copy.copy(extra_preargs or [])
        libraries = copy.copy(libraries or [])
        objects = copy.copy(objects or [])
        libraries.extend(self.dll_libraries)
        if export_symbols is not None and target_desc != self.EXECUTABLE:
            temp_dir = os.path.dirname(objects[0])
            dll_name, dll_extension = os.path.splitext(os.path.basename(output_filename))
            def_file = os.path.join(temp_dir, dll_name + ".def")
            contents = [
                "LIBRARY %s INITINSTANCE TERMINSTANCE" % os.path.splitext(os.path.basename(output_filename))[0],
                "DATA MULTIPLE NONSHARED",
                "EXPORTS",
            ]
            for sym in export_symbols:
                contents.append('  "%s"' % sym)

            self.execute(write_file, (def_file, contents), "writing %s" % def_file)
            objects.append(def_file)
        if not debug:
            extra_preargs.append("-s")
        UnixCCompiler.link(
            self,
            target_desc,
            objects,
            output_filename,
            output_dir,
            libraries,
            library_dirs,
            runtime_library_dirs,
            None,
            debug,
            extra_preargs,
            extra_postargs,
            build_temp,
            target_lang,
        )
        return
コード例 #3
0
    def link(self, target_desc, objects,
             output_filename, output_dir=None, libraries=None,
             library_dirs=None, runtime_library_dirs=None,
             export_symbols=None, debug=0, extra_preargs=None,
             extra_postargs=None, build_temp=None, target_lang=None):

        print "LINK"
        UnixCCompiler.link(self, target_desc, objects,
                           output_filename, output_dir, libraries,
                           library_dirs, runtime_library_dirs,
                           export_symbols, debug, extra_preargs,
                           extra_postargs, build_temp, target_lang)
コード例 #4
0
 def link(
     self,
     target_desc,
     objects,
     output_filename,
     output_dir,
     libraries,
     library_dirs,
     runtime_library_dirs,
     export_symbols=None,  # export_symbols, we do this in our def-file
     debug=0,
     extra_preargs=None,
     extra_postargs=None,
     build_temp=None,
     target_lang=None,
 ):
     if self.gcc_version < "3.0.0":
         distutils.cygwinccompiler.CygwinCCompiler.link(
             self,
             target_desc,
             objects,
             output_filename,
             output_dir,
             libraries,
             library_dirs,
             runtime_library_dirs,
             None,  # export_symbols, we do this in our def-file
             debug,
             extra_preargs,
             extra_postargs,
             build_temp,
             target_lang,
         )
     else:
         UnixCCompiler.link(
             self,
             target_desc,
             objects,
             output_filename,
             output_dir,
             libraries,
             library_dirs,
             runtime_library_dirs,
             None,  # export_symbols, we do this in our def-file
             debug,
             extra_preargs,
             extra_postargs,
             build_temp,
             target_lang,
         )
コード例 #5
0
 def link(
         self,
         target_desc,
         objects,
         output_filename,
         output_dir,
         libraries,
         library_dirs,
         runtime_library_dirs,
         export_symbols=None,  # export_symbols, we do this in our def-file
         debug=0,
         extra_preargs=None,
         extra_postargs=None,
         build_temp=None,
         target_lang=None):
     if self.gcc_version < "3.0.0":
         distutils.cygwinccompiler.CygwinCCompiler.link(
             self,
             target_desc,
             objects,
             output_filename,
             output_dir,
             libraries,
             library_dirs,
             runtime_library_dirs,
             None,  # export_symbols, we do this in our def-file
             debug,
             extra_preargs,
             extra_postargs,
             build_temp,
             target_lang)
     else:
         UnixCCompiler.link(
             self,
             target_desc,
             objects,
             output_filename,
             output_dir,
             libraries,
             library_dirs,
             runtime_library_dirs,
             None,  # export_symbols, we do this in our def-file
             debug,
             extra_preargs,
             extra_postargs,
             build_temp,
             target_lang)
コード例 #6
0
    def link(self, target_desc, objects, output_filename, output_dir=None,
             libraries=None, library_dirs=None, runtime_library_dirs=None,
             export_symbols=None, debug=0, extra_preargs=None,
             extra_postargs=None, build_temp=None, target_lang=None):
        """Link the objects."""
        # use separate copies, so we can modify the lists
        libraries = copy.copy(libraries or [])
        libraries.extend(self.dll_libraries)
        if os.name == 'nt':
            sysroot = os.path.dirname(os.path.realpath(sys.executable))
            library_dirs = copy.copy(library_dirs or [])
            library_dirs.append(sysroot)

        UnixCCompiler.link(self, target_desc, objects, output_filename,
            output_dir, libraries, library_dirs, runtime_library_dirs,
            None, # export_symbols, we do this in our def-file
            debug, extra_preargs, extra_postargs, build_temp, target_lang)
コード例 #7
0
    def link(self,
             target_desc,
             objects,
             output_filename,
             output_dir=None,
             libraries=None,
             library_dirs=None,
             runtime_library_dirs=None,
             export_symbols=None,
             debug=0,
             extra_preargs=None,
             extra_postargs=None,
             build_temp=None,
             target_lang=None):
        extra_preargs = copy.copy(extra_preargs or [])
        libraries = copy.copy(libraries or [])
        objects = copy.copy(objects or [])
        libraries.extend(self.dll_libraries)
        if export_symbols is not None and (target_desc != self.EXECUTABLE
                                           or self.linker_dll == 'gcc'):
            temp_dir = os.path.dirname(objects[0])
            dll_name, dll_extension = os.path.splitext(
                os.path.basename(output_filename))
            def_file = os.path.join(temp_dir, dll_name + '.def')
            lib_file = os.path.join(temp_dir, 'lib' + dll_name + '.a')
            contents = [
                'LIBRARY %s' % os.path.basename(output_filename), 'EXPORTS'
            ]
            for sym in export_symbols:
                contents.append(sym)

            self.execute(write_file, (def_file, contents),
                         'writing %s' % def_file)
            if self.linker_dll == 'dllwrap':
                extra_preargs.extend(['--output-lib', lib_file])
                extra_preargs.extend(['--def', def_file])
            else:
                objects.append(def_file)
        if not debug:
            extra_preargs.append('-s')
        UnixCCompiler.link(self, target_desc, objects, output_filename,
                           output_dir, libraries, library_dirs,
                           runtime_library_dirs, None, debug, extra_preargs,
                           extra_postargs, build_temp, target_lang)
        return
コード例 #8
0
    def link(self, target_desc, objects, output_filename, output_dir = None, libraries = None, library_dirs = None, runtime_library_dirs = None, export_symbols = None, debug = 0, extra_preargs = None, extra_postargs = None, build_temp = None, target_lang = None):
        extra_preargs = copy.copy(extra_preargs or [])
        libraries = copy.copy(libraries or [])
        objects = copy.copy(objects or [])
        libraries.extend(self.dll_libraries)
        if export_symbols is not None and target_desc != self.EXECUTABLE:
            temp_dir = os.path.dirname(objects[0])
            dll_name, dll_extension = os.path.splitext(os.path.basename(output_filename))
            def_file = os.path.join(temp_dir, dll_name + '.def')
            contents = ['LIBRARY %s INITINSTANCE TERMINSTANCE' % os.path.splitext(os.path.basename(output_filename))[0], 'DATA MULTIPLE NONSHARED', 'EXPORTS']
            for sym in export_symbols:
                contents.append('  "%s"' % sym)

            self.execute(write_file, (def_file, contents), 'writing %s' % def_file)
            objects.append(def_file)
        if not debug:
            extra_preargs.append('-s')
        UnixCCompiler.link(self, target_desc, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, None, debug, extra_preargs, extra_postargs, build_temp, target_lang)
        return
コード例 #9
0
    def link(self, target_desc, objects, output_filename, output_dir = None, libraries = None, library_dirs = None, runtime_library_dirs = None, export_symbols = None, debug = 0, extra_preargs = None, extra_postargs = None, build_temp = None, target_lang = None):
        extra_preargs = copy.copy(extra_preargs or [])
        libraries = copy.copy(libraries or [])
        objects = copy.copy(objects or [])
        libraries.extend(self.dll_libraries)
        if export_symbols is not None and (target_desc != self.EXECUTABLE or self.linker_dll == 'gcc'):
            temp_dir = os.path.dirname(objects[0])
            dll_name, dll_extension = os.path.splitext(os.path.basename(output_filename))
            def_file = os.path.join(temp_dir, dll_name + '.def')
            lib_file = os.path.join(temp_dir, 'lib' + dll_name + '.a')
            contents = ['LIBRARY %s' % os.path.basename(output_filename), 'EXPORTS']
            for sym in export_symbols:
                contents.append(sym)

            self.execute(write_file, (def_file, contents), 'writing %s' % def_file)
            if self.linker_dll == 'dllwrap':
                extra_preargs.extend(['--output-lib', lib_file])
                extra_preargs.extend(['--def', def_file])
            else:
                objects.append(def_file)
        if not debug:
            extra_preargs.append('-s')
        UnixCCompiler.link(self, target_desc, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, None, debug, extra_preargs, extra_postargs, build_temp, target_lang)
        return
コード例 #10
0
    def link (self,
              target_desc,
              objects,
              output_filename,
              output_dir=None,
              libraries=None,
              library_dirs=None,
              runtime_library_dirs=None,
              export_symbols=None,
              debug=0,
              extra_preargs=None,
              extra_postargs=None,
              build_temp=None,
              target_lang=None):

        # use separate copies, so we can modify the lists
        extra_preargs = copy.copy(extra_preargs or [])
        libraries = copy.copy(libraries or [])
        objects = copy.copy(objects or [])

        # Additional libraries
        libraries.extend(self.dll_libraries)

        # handle export symbols by creating a def-file
        # with executables this only works with gcc/ld as linker
        if ((export_symbols is not None) and
            (target_desc != self.EXECUTABLE)):
            # (The linker doesn't do anything if output is up-to-date.
            # So it would probably better to check if we really need this,
            # but for this we had to insert some unchanged parts of
            # UnixCCompiler, and this is not what we want.)

            # we want to put some files in the same directory as the
            # object files are, build_temp doesn't help much
            # where are the object files
            temp_dir = os.path.dirname(objects[0])
            # name of dll to give the helper files the same base name
            (dll_name, dll_extension) = os.path.splitext(
                os.path.basename(output_filename))

            # generate the filenames for these files
            def_file = os.path.join(temp_dir, dll_name + ".def")

            # Generate .def file
            contents = [
                "LIBRARY %s INITINSTANCE TERMINSTANCE" % \
                os.path.splitext(os.path.basename(output_filename))[0],
                "DATA MULTIPLE NONSHARED",
                "EXPORTS"]
            for sym in export_symbols:
                contents.append('  "%s"' % sym)
            self.execute(write_file, (def_file, contents),
                         "writing %s" % def_file)

            # next add options for def-file and to creating import libraries
            # for gcc/ld the def-file is specified as any other object files
            objects.append(def_file)

        #end: if ((export_symbols is not None) and
        #        (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")):

        # who wants symbols and a many times larger output file
        # should explicitly switch the debug mode on
        # otherwise we let dllwrap/ld strip the output file
        # (On my machine: 10KB < stripped_file < ??100KB
        #   unstripped_file = stripped_file + XXX KB
        #  ( XXX=254 for a typical python extension))
        if not debug:
            extra_preargs.append("-s")

        UnixCCompiler.link(self,
                           target_desc,
                           objects,
                           output_filename,
                           output_dir,
                           libraries,
                           library_dirs,
                           runtime_library_dirs,
                           None, # export_symbols, we do this in our def-file
                           debug,
                           extra_preargs,
                           extra_postargs,
                           build_temp,
                           target_lang)
コード例 #11
0
    def link(self,
             target_desc,
             objects,
             output_filename,
             output_dir=None,
             libraries=None,
             library_dirs=None,
             runtime_library_dirs=None,
             export_symbols=None,
             debug=0,
             extra_preargs=None,
             extra_postargs=None,
             build_temp=None,
             target_lang=None):

        # use separate copies, so we can modify the lists
        extra_preargs = copy.copy(extra_preargs or [])
        libraries = copy.copy(libraries or [])
        objects = copy.copy(objects or [])

        # Additional libraries
        libraries.extend(self.dll_libraries)

        # handle export symbols by creating a def-file
        # with executables this only works with gcc/ld as linker
        if ((export_symbols is not None) and
            (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")):
            # (The linker doesn't do anything if output is up-to-date.
            # So it would probably better to check if we really need this,
            # but for this we had to insert some unchanged parts of
            # UnixCCompiler, and this is not what we want.)

            # we want to put some files in the same directory as the
            # object files are, build_temp doesn't help much
            # where are the object files
            temp_dir = os.path.dirname(objects[0])
            # name of dll to give the helper files the same base name
            (dll_name, dll_extension) = os.path.splitext(
                os.path.basename(output_filename))

            # generate the filenames for these files
            def_file = os.path.join(temp_dir, dll_name + ".def")
            lib_file = os.path.join(temp_dir, 'lib' + dll_name + ".a")

            # Generate .def file
            contents = [
                "LIBRARY %s" % os.path.basename(output_filename), "EXPORTS"
            ]
            for sym in export_symbols:
                contents.append(sym)
            self.execute(write_file, (def_file, contents),
                         "writing %s" % def_file)

            # next add options for def-file and to creating import libraries

            # dllwrap uses different options than gcc/ld
            if self.linker_dll == "dllwrap":
                extra_preargs.extend(["--output-lib", lib_file])
                # for dllwrap we have to use a special option
                extra_preargs.extend(["--def", def_file])
            # we use gcc/ld here and can be sure ld is >= 2.9.10
            else:
                # doesn't work: bfd_close build\...\libfoo.a: Invalid operation
                #extra_preargs.extend(["-Wl,--out-implib,%s" % lib_file])
                # for gcc/ld the def-file is specified as any object files
                objects.append(def_file)

        #end: if ((export_symbols is not None) and
        #        (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")):

        # who wants symbols and a many times larger output file
        # should explicitly switch the debug mode on
        # otherwise we let dllwrap/ld strip the output file
        # (On my machine: 10KB < stripped_file < ??100KB
        #   unstripped_file = stripped_file + XXX KB
        #  ( XXX=254 for a typical python extension))
        if not debug:
            extra_preargs.append("-s")

        UnixCCompiler.link(
            self,
            target_desc,
            objects,
            output_filename,
            output_dir,
            libraries,
            library_dirs,
            runtime_library_dirs,
            None,  # export_symbols, we do this in our def-file
            debug,
            extra_preargs,
            extra_postargs,
            build_temp,
            target_lang)
コード例 #12
0
    def link (self,
              target_desc,
              objects,
              output_filename,
              output_dir=None,
              libraries=None,
              library_dirs=None,
              runtime_library_dirs=None,
              export_symbols=None,
              debug=0,
              extra_preargs=None,
              extra_postargs=None,
              build_temp=None):
        
        # use separate copies, so we can modify the lists
        extra_preargs = copy.copy(extra_preargs or [])
        libraries = copy.copy(libraries or [])
        objects = copy.copy(objects or [])
                
        # Additional libraries
        libraries.extend(self.dll_libraries)

        # handle export symbols by creating a def-file
        # with executables this only works with gcc/ld as linker
        if ((export_symbols is not None) and
            (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")):
            # (The linker doesn't do anything if output is up-to-date.
            # So it would probably better to check if we really need this,
            # but for this we had to insert some unchanged parts of 
            # UnixCCompiler, and this is not what we want.) 

            # we want to put some files in the same directory as the 
            # object files are, build_temp doesn't help much
            # where are the object files
            temp_dir = os.path.dirname(objects[0])
            # name of dll to give the helper files the same base name
            (dll_name, dll_extension) = os.path.splitext(
                os.path.basename(output_filename))

            # generate the filenames for these files
            def_file = os.path.join(temp_dir, dll_name + ".def")
            exp_file = os.path.join(temp_dir, dll_name + ".exp")
            lib_file = os.path.join(temp_dir, 'lib' + dll_name + ".a")
       
            # Generate .def file
            contents = [
                "LIBRARY %s" % os.path.basename(output_filename),
                "EXPORTS"]
            for sym in export_symbols:
                contents.append(sym)
            self.execute(write_file, (def_file, contents),
                         "writing %s" % def_file)

            # next add options for def-file and to creating import libraries

            # dllwrap uses different options than gcc/ld
            if self.linker_dll == "dllwrap":
                extra_preargs.extend([#"--output-exp",exp_file,
                                       "--output-lib",lib_file,
                                     ])
                # for dllwrap we have to use a special option
                extra_preargs.extend(["--def", def_file])
            # we use gcc/ld here and can be sure ld is >= 2.9.10
            else:
                # doesn't work: bfd_close build\...\libfoo.a: Invalid operation
                #extra_preargs.extend(["-Wl,--out-implib,%s" % lib_file])
                # for gcc/ld the def-file is specified as any other object files    
                objects.append(def_file)

        #end: if ((export_symbols is not None) and
        #        (target_desc <> self.EXECUTABLE or self.linker_dll == "gcc")):
                                                 
        # who wants symbols and a many times larger output file
        # should explicitly switch the debug mode on 
        # otherwise we let dllwrap/ld strip the output file
        # (On my machine: 10KB < stripped_file < ??100KB 
        #   unstripped_file = stripped_file + XXX KB
        #  ( XXX=254 for a typical python extension)) 
        if not debug: 
            extra_preargs.append("-s") 
        
        UnixCCompiler.link(self,
                           target_desc,
                           objects,
                           output_filename,
                           output_dir,
                           libraries,
                           library_dirs,
                           runtime_library_dirs,
                           None, # export_symbols, we do this in our def-file
                           debug,
                           extra_preargs,
                           extra_postargs,
                           build_temp)
コード例 #13
0
ファイル: cygwinccompiler.py プロジェクト: mcyril/ravel-ftn
"""distutils.cygwinccompiler
コード例 #14
0
    def link(self,
             target_desc,
             objects,
             output_filename,
             output_dir=None,
             libraries=None,
             library_dirs=None,
             runtime_library_dirs=None,
             export_symbols=None,
             debug=0,
             extra_preargs=None,
             extra_postargs=None,
             build_temp=None,
             target_lang=None):
        """Link the objects."""
        # use separate copies, so we can modify the lists
        extra_preargs = copy.copy(extra_preargs or [])
        libraries = copy.copy(libraries or [])
        objects = copy.copy(objects or [])

        # Additional libraries
        libraries.extend(self.dll_libraries)

        # get dll/pyd name and extension
        dll_name, dll_extension = os.path.splitext(
            os.path.basename(output_filename))
        # if name is longer than 8 char, generate a hashed 8 char name
        if len(dll_name) > 8:
            dll_name8 = os.path.basename(output_filename)[:3] + str(
                reduce(lambda x, y: x + y, map(ord, output_filename)) % 65536)
        else:
            dll_name8 = dll_name

        # full relative path of dll/pyd
        dll_extension = get_config_vars().get('EXT_SUFFIX')
        dll_namefull = os.path.join(os.path.dirname(output_filename),
                                    dll_name8 + dll_extension)

        # handle export symbols by creating a def-file
        # with executables this only works with gcc/ld as linker
        if ((export_symbols is not None) and (target_desc != self.EXECUTABLE)):
            # (The linker doesn't do anything if output is up-to-date.
            # So it would probably better to check if we really need this,
            # but for this we had to insert some unchanged parts of
            # UnixCCompiler, and this is not what we want.)

            # we want to put some files in the same directory as the
            # object files are, build_temp doesn't help much
            # where are the object files
            temp_dir = os.path.dirname(objects[0])

            # generate the filenames for these files
            def_file = os.path.join(temp_dir, dll_name + ".def")

            # prepare some needed values for the buildlevel
            vendor = os.getenv('VENDOR')
            if not vendor:
                vendor = "python build system"
            if not BOOTSTRAP:
                now = datetime.now()
                date_time = now.strftime("%d %b %Y %H:%M:%S")
            else:
                date_time = os.getenv("BOOTSTRAP_TIME")
            version = self.version
            if not version:
                version = "0.0"
            (osname, host, release, osversion, machine) = os.uname()

            # Generate .def file
            contents = [
                "LIBRARY %s INITINSTANCE TERMINSTANCE" % \
                dll_name8,
                "DESCRIPTION \"@#%s:%s#@##1## %s     %s::::0::@@%s\"" % \
                (vendor, version, date_time, host, dll_name),
                "DATA MULTIPLE NONSHARED",
                "EXPORTS"]

            for sym in export_symbols:
                contents.append('  "_%s"' % sym)
            self.execute(write_file, (def_file, contents),
                         "writing %s" % def_file)

            # next add options for def-file and to creating import libraries

            # for gcc/ld the def-file is specified as any other object files
            objects.append(def_file)

        #end: if ((export_symbols is not None) and
        #        (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")):

        # who wants symbols and a many times larger output file
        # should explicitly switch the debug mode on
        # otherwise we let dllwrap/ld strip the output file
        # (On my machine: 10KB < stripped_file < ??100KB
        #   unstripped_file = stripped_file + XXX KB
        #  ( XXX=254 for a typical python extension))
        if not debug:
            extra_preargs.append("-s")

        UnixCCompiler.link(
            self,
            target_desc,
            objects,
            dll_namefull,
            output_dir,
            libraries,
            library_dirs,
            runtime_library_dirs,
            None,  # export_symbols, we do this in our def-file
            debug,
            extra_preargs,
            extra_postargs,
            build_temp,
            target_lang)

        # if filename exceed 8 char, create a symlink to the 8 char dll/pyd
        if len(dll_name) > 8:
            try:
                os.remove(output_filename)
            except OSError:
                pass
            os.symlink(dll_name8 + dll_extension, output_filename)