PNG  IHDR  8] PLTE S =tRNS   PNG  IHDR  8] PLTE S =tRNS   REDROOM
PHP 7.4.33
Preview: emxccompiler.py Size: 11.65 KB
/opt/alt/python27/lib64/python2.7/distutils/emxccompiler.py

"""distutils.emxccompiler

Provides the EMXCCompiler class, a subclass of UnixCCompiler that
handles the EMX port of the GNU C compiler to OS/2.
"""

# issues:
#
# * OS/2 insists that DLLs can have names no longer than 8 characters
#   We put export_symbols in a def-file, as though the DLL can have
#   an arbitrary length name, but truncate the output filename.
#
# * only use OMF objects and use LINK386 as the linker (-Zomf)
#
# * always build for multithreading (-Zmt) as the accompanying OS/2 port
#   of Python is only distributed with threads enabled.
#
# tested configurations:
#
# * EMX gcc 2.81/EMX 0.9d fix03

__revision__ = "$Id$"

import os,sys,copy
from distutils.ccompiler import gen_preprocess_options, gen_lib_options
from distutils.unixccompiler import UnixCCompiler
from distutils.file_util import write_file
from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
from distutils import log

class EMXCCompiler (UnixCCompiler):

    compiler_type = 'emx'
    obj_extension = ".obj"
    static_lib_extension = ".lib"
    shared_lib_extension = ".dll"
    static_lib_format = "%s%s"
    shared_lib_format = "%s%s"
    res_extension = ".res"      # compiled resource file
    exe_extension = ".exe"

    def __init__ (self,
                  verbose=0,
                  dry_run=0,
                  force=0):

        UnixCCompiler.__init__ (self, verbose, dry_run, force)

        (status, details) = check_config_h()
        self.debug_print("Python's GCC status: %s (details: %s)" %
                         (status, details))
        if status is not CONFIG_H_OK:
            self.warn(
                "Python's pyconfig.h doesn't seem to support your compiler.  " +
                ("Reason: %s." % details) +
                "Compiling may fail because of undefined preprocessor macros.")

        (self.gcc_version, self.ld_version) = \
            get_versions()
        self.debug_print(self.compiler_type + ": gcc %s, ld %s\n" %
                         (self.gcc_version,
                          self.ld_version) )

        # Hard-code GCC because that's what this is all about.
        # XXX optimization, warnings etc. should be customizable.
        self.set_executables(compiler='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
                             compiler_so='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
                             linker_exe='gcc -Zomf -Zmt -Zcrtdll',
                             linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll')

        # want the gcc library statically linked (so that we don't have
        # to distribute a version dependent on the compiler we have)
        self.dll_libraries=["gcc"]

    # __init__ ()

    def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
        if ext == '.rc':
            # gcc requires '.rc' compiled to binary ('.res') files !!!
            try:
                self.spawn(["rc", "-r", src])
            except DistutilsExecError, msg:
                raise CompileError, msg
        else: # for other files use the C-compiler
            try:
                self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
                           extra_postargs)
            except DistutilsExecError, msg:
                raise CompileError, msg

    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)

    # link ()

    # -- Miscellaneous methods -----------------------------------------

    # override the object_filenames method from CCompiler to
    # support rc and res-files
    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

    # object_filenames ()

    # override the find_library_file method from UnixCCompiler
    # to deal with file naming/searching differences
    def find_library_file(self, dirs, lib, debug=0):
        shortlib = '%s.lib' % lib
        longlib = 'lib%s.lib' % lib    # this form very rare

        # get EMX's default library directory search path
        try:
            emx_dirs = os.environ['LIBRARY_PATH'].split(';')
        except KeyError:
            emx_dirs = []

        for dir in dirs + emx_dirs:
            shortlibp = os.path.join(dir, shortlib)
            longlibp = os.path.join(dir, longlib)
            if os.path.exists(shortlibp):
                return shortlibp
            elif os.path.exists(longlibp):
                return longlibp

        # Oops, didn't find it in *any* of 'dirs'
        return None

# class EMXCCompiler


# Because these compilers aren't configured in Python's pyconfig.h file by
# default, we should at least warn the user if he is using a unmodified
# version.

CONFIG_H_OK = "ok"
CONFIG_H_NOTOK = "not ok"
CONFIG_H_UNCERTAIN = "uncertain"

def check_config_h():

    """Check if the current Python installation (specifically, pyconfig.h)
    appears amenable to building extensions with GCC.  Returns a tuple
    (status, details), where 'status' is one of the following constants:
      CONFIG_H_OK
        all is well, go ahead and compile
      CONFIG_H_NOTOK
        doesn't look good
      CONFIG_H_UNCERTAIN
        not sure -- unable to read pyconfig.h
    'details' is a human-readable string explaining the situation.

    Note there are two ways to conclude "OK": either 'sys.version' contains
    the string "GCC" (implying that this Python was built with GCC), or the
    installed "pyconfig.h" contains the string "__GNUC__".
    """

    # XXX since this function also checks sys.version, it's not strictly a
    # "pyconfig.h" check -- should probably be renamed...

    from distutils import sysconfig
    import string
    # if sys.version contains GCC then python was compiled with
    # GCC, and the pyconfig.h file should be OK
    if string.find(sys.version,"GCC") >= 0:
        return (CONFIG_H_OK, "sys.version mentions 'GCC'")

    fn = sysconfig.get_config_h_filename()
    try:
        # It would probably better to read single lines to search.
        # But we do this only once, and it is fast enough
        f = open(fn)
        try:
            s = f.read()
        finally:
            f.close()

    except IOError, exc:
        # if we can't read this file, we cannot say it is wrong
        # the compiler will complain later about this file as missing
        return (CONFIG_H_UNCERTAIN,
                "couldn't read '%s': %s" % (fn, exc.strerror))

    else:
        # "pyconfig.h" contains an "#ifdef __GNUC__" or something similar
        if string.find(s,"__GNUC__") >= 0:
            return (CONFIG_H_OK, "'%s' mentions '__GNUC__'" % fn)
        else:
            return (CONFIG_H_NOTOK, "'%s' does not mention '__GNUC__'" % fn)


def get_versions():
    """ Try to find out the versions of gcc and ld.
        If not possible it returns None for it.
    """
    from distutils.version import StrictVersion
    from distutils.spawn import find_executable
    import re

    gcc_exe = find_executable('gcc')
    if gcc_exe:
        out = os.popen(gcc_exe + ' -dumpversion','r')
        try:
            out_string = out.read()
        finally:
            out.close()
        result = re.search('(\d+\.\d+\.\d+)',out_string)
        if result:
            gcc_version = StrictVersion(result.group(1))
        else:
            gcc_version = None
    else:
        gcc_version = None
    # EMX ld has no way of reporting version number, and we use GCC
    # anyway - so we can link OMF DLLs
    ld_version = None
    return (gcc_version, ld_version)

Directory Contents

Dirs: 1 × Files: 87

Name Size Perms Modified Actions
command DIR
- drwxr-xr-x 2025-12-02 12:55:38
Edit Download
8.03 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
7.52 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
7.52 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
14.59 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
7.81 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
7.81 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
45.63 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
36.72 KB lrw-r--r-- 2025-12-02 12:55:37
Edit Download
36.58 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
18.82 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
16.88 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
16.88 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
4.04 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
3.57 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
3.57 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
8.81 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
7.41 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
7.41 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
17.32 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
9.75 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
9.75 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
162 B lrw-r--r-- 2025-01-08 10:54:00
Edit Download
267 B lrw-r--r-- 2025-12-02 12:55:12
Edit Download
267 B lrw-r--r-- 2025-01-08 10:54:00
Edit Download
3.43 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
3.16 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
3.16 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
7.68 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
6.72 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
6.72 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
48.88 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
39.11 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
39.11 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
11.65 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
7.41 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
7.41 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
3.41 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
6.39 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
6.39 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
10.65 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
7.29 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
7.07 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
17.53 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
11.94 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
11.77 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
12.39 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
10.72 KB lrw-r--r-- 2025-12-02 12:55:37
Edit Download
10.72 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
7.94 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
6.66 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
6.66 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
1.65 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
2.87 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
2.87 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
30.28 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
21.39 KB lrw-r--r-- 2025-12-02 12:55:37
Edit Download
21.32 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
23.08 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
17.44 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
17.44 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
295 B lrw-r--r-- 2025-01-08 10:54:00
Edit Download
8.45 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
6.37 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
6.37 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
17.29 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
17.21 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
13.29 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
13.29 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
12.14 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
9.18 KB lrw-r--r-- 2025-12-02 12:55:37
Edit Download
9.18 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
13.89 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
13.36 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
8.19 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
8.19 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
17.81 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
14.23 KB lrw-r--r-- 2025-12-02 12:55:12
Edit Download
14.23 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
11.17 KB lrw-r--r-- 2025-01-08 10:54:00
Edit Download
7.23 KB lrw-r--r-- 2025-12-02 12:55:37
Edit Download
7.23 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
4.98 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
5.50 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
5.50 KB lrw-r--r-- 2025-01-08 10:54:01
Edit Download
236 B lrw-r--r-- 2025-01-08 10:54:00
Edit Download
428 B lrw-r--r-- 2025-12-02 12:55:12
Edit Download
428 B lrw-r--r-- 2025-01-08 10:54:01
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).
 !"#$%&'(()*+,-./00123456789 t\ wIDATx ]ys  47Y ƒ -  "  Rv  < f{Ɛ $k l L > L  ~h^ 1  [  r G t& h  l F z3O Y ! p A(_g̷ E8 )S 8 c  Kb"z ~ 5 J xAL WU <  *  5 m;W a pB h ~P J 2 3 6 ҙ .Ƹ P i  4g F R L P ΪK/D  M v (a3 k J Œ4N5* SH ` SdJ z  O J Xՠ V>u ߱ BE&L b2 ?2` tX+  c CB A$ i b C ĀMB E : /  # Dx &l =q Ty  0 \p I ( L Ǎ { e 4k ;`u^ヲ eP!( d {  )T A 8 O;Ě n >;s6 !  :Nx `[S D HU ~ q›J F} a g*D 49 / pn k h (t 8NxƐF _!r չ7 ZR R׷ q/5") Ӎ NY 0 x sZ!   o  fu  ,  K"$ ? pg  㕣=  1» {h " fh7    y  } € +7  $ y " X —ą - G P u 4 m >J 5 L =V ' ^@I p ?MS xЌ XV P ! h "C NS9B8̢ ]!K  e   zA , ӏkbY  !< XQ ٿyS| *" f { w  4@[S <  # 0 ! js [m  =,~ o "ݎ DHf Wo $ g ! Vԅ t mB /y Wf V4񺍸 c+@x?  B ~u " xUN e 0 BĂ) ~J pz! 7y6]l Ԥ@ P a< O /DHC `≻  N m"$  0ObB }{ x AO FCG D R ^ "B  { WDH  UR l@ T #  +"d T ; 0 i  D}. 7 ` ' ] w rE &S i ƕiTD EL P _ u h $ Ա FG wVD G L R Zf ' .!] J /ZR oGЍs Mr Ĥ ʬ 3 Q [3 cL ` ^ p + ( F;# B 5 '  2Y f [  ϶R0e }  E 7 6M aۮ H <& n % L] E}Up x紉, Uw' Q  Ǯշo k ވۙ 0N94 VX5 xEDE l D #֤ } C o )W :  ^ s 9  bRf iX5u ཱི 4 :[  T 1. | [E 2ؽ Iy\ : o x K G 5 ylP ' uK E ftb/i[3 .g _  [3M n G, #NwQ5~  ؚ) | n =Ц"x qg gB ` 듘 ~ x w ? ? R~  _ u. &VQ K˻   H C ( TN˄+ `C dA nB׭ D 3"Z G ê ^k H_ /- ~ " R_  .8 Z_ 6@ o  xg  uP ? 3լ @7AM!  E7^ - =V L  x  g-D0  CtmW 7  O  G _ WD0 g C  w1 r d w : a | \  *" f nֳ ^ H# f L ` Z ۽hV  }S F r0Ù Bć5r] @! NL iQ]{s^=4 d  WD  "  "   M; t" 8 5 e dL| "-*st" ) SWD ?R[S e ooF  20.D ? bo =) A i o d ģ ZҰaO @E =) i D a &ܟa CϞ y6 ,<%{^x%{f8? `iw^ ?/ M * IEND B`