mingw32ccompiler.py :  » Game-2D-3D » Pygame » pygame-1.9.1release » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Game 2D 3D » Pygame 
Pygame » pygame 1.9.1release » mingw32ccompiler.py
# module mingw32ccompiler.py
# Requires Python 2.1 or better.

"""Win32 GUI/console versions of the distutils mingw32 compiler classes."""

from distutils.cygwinccompiler import Mingw32CCompiler

def intersect (sequence_a, sequence_b):
    """Return true if the two sequences contain items in common

    If sequence_a is a non-sequence then return false.
    """
    try:
        for item in sequence_a:
            if item in sequence_b:
                return 1
    except TypeError:
        return 0
    return 0

def difference (sequence_a, sequence_b):
    """Return a list of items in sequence_a but not in sequence_b

    Will raise a ValueError if either argument is not a sequence.
    """
    new_sequence = []
    for item in sequence_a:
        if item not in sequence_b:
            new_sequence.append(item)
    return new_sequence

subsystem_options = ['-mwindows', '-mconsole']  # Item position is critical.

class Mingw32DefaultCCompiler (Mingw32CCompiler):
    """This mingw32 compiler class builds a Win32 GUI DLL by default.

    It is overridden by subsystem options in the linker extras.
    """

    def set_executables (self, **args):
        """Has no linker subsystem option for shared libraries"""
        Mingw32CCompiler.set_executables(self, **args)
        try:
            self.linker_so = difference (self.linker_so, subsystem_options)
        except TypeError:
            pass
                          
    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):
        """Do a Win32 GUI link if no subsystem option given."""

        if (target_desc != self.EXECUTABLE and
            not intersect(subsystem_options, extra_preargs) and
            not intersect(subsystem_options, extra_postargs)):
            try:
                extra_preargs = extra_preargs + subsystem_options[0]
            except TypeError:
                extra_preargs = subsystem_options[0:1]

        Mingw32CCompiler.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)

class Mingw32ConsoleCCompiler (Mingw32CCompiler):
    """This mingw32 compiler class builds a console DLL.

    It is not overridden by subsystem options in the linker extras.
    """

    def set_executables (self, **args):
        """Has console subsystem linker option for shared libraries."""
        Mingw32CCompiler.set_executables(self, **args)
        try:
            linker_so = difference(self.linker_so, subsystem_options)
        except TypeError:
            linker_so = subsystem_options[1:2]
        else:
            linker_so.append(subsystem_options[1])
        self.linker_so = linker_so
                          
    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):
        """Do a console link."""

        if target_desc != self.EXECUTABLE:
            try:
                extra_preargs = difference(extra_preargs, subsystem_options)
            except TypeError:
                pass
            try:
                extra_postargs = difference(extra_postargs, subsystem_options)
            except TypeError:
                pass
        Mingw32CCompiler.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)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.