Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
41192ad6
Commit
41192ad6
authored
Jun 29, 2000
by
Greg Ward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up and reformatted by Rene Liebscher.
More reformatting by me. Also added some editorial comments.
parent
0350ebe9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
113 additions
and
95 deletions
+113
-95
cygwinccompiler.py
cygwinccompiler.py
+113
-95
No files found.
cygwinccompiler.py
View file @
41192ad6
"""distutils.cygwinccompiler
"""distutils.cygwinccompiler
Contains the CygwinCCompiler class, a subclass of UnixCCompiler that handles
Provides the CygwinCCompiler class, a subclass of UnixCCompiler that
the Gnu Win32 C compiler.
handles the Cygwin port of the GNU C compiler to Windows. It also contains
It also contains the Mingw32CCompiler class which handles the mingw32 compiler
the Mingw32CCompiler class which handles the mingw32 port of GCC (same as
(same as cygwin in no-cygwin mode.)
cygwin in no-cygwin mode).
"""
"""
# created 2000/05/05, Rene Liebscher
# created 2000/05/05, Rene Liebscher
__revision__
=
"$Id$"
__revision__
=
"$Id$"
import
os
,
sys
,
string
,
tempfile
import
os
,
sys
,
string
from
distutils
import
sysconfig
from
distutils
import
sysconfig
from
distutils.unixccompiler
import
UnixCCompiler
from
distutils.unixccompiler
import
UnixCCompiler
# Because these compilers aren't configured in Python's config.h file by default
# Because these compilers aren't configured in Python's config.h file by
# we should at least warn the user if he used this unmodified version.
# default we should at least warn the user if he is using a unmodified
def
check_if_config_h_is_gcc_ready
():
# version.
""" checks, if the gcc-compiler is mentioned in config.h
if it is not, compiling probably doesn't work """
def
check_config_h
():
from
distutils
import
sysconfig
"""Checks if the GCC compiler is mentioned in config.h. If it is not,
import
string
,
sys
compiling probably doesn't work, so print a warning to stderr.
"""
# XXX the result of the check should be returned!
from
distutils
import
sysconfig
import
string
,
sys
try
:
# It would probably better to read single lines to search.
# But we do this only once, and it is fast enough
f
=
open
(
sysconfig
.
get_config_h_filename
())
s
=
f
.
read
()
f
.
close
()
try
:
try
:
# It would probably better to read single lines to search.
# is somewhere a #ifdef __GNUC__ or something similar
# But we do this only once, and it is fast enough
string
.
index
(
s
,
"__GNUC__"
)
f
=
open
(
sysconfig
.
get_config_h_filename
())
except
ValueError
:
s
=
f
.
read
()
sys
.
stderr
.
write
(
"warning: "
+
f
.
close
()
"Python's config.h doesn't seem to support your compiler.
\
n
"
)
try
:
except
IOError
:
string
.
index
(
s
,
"__GNUC__"
)
# is somewhere a #ifdef __GNUC__ or something similar
# if we can't read this file, we cannot say it is wrong
except
:
# the compiler will complain later about this file as missing
sys
.
stderr
.
write
(
"warning: Python's config.h doesn't seem to support your compiler.
\
n
"
)
pass
except
:
# unspecific error => ignore
pass
# This is called when the module is imported, so we make this check only once
# This is called when the module is imported, so we make this check only once
check_if_config_h_is_gcc_ready
()
# XXX why not make it only when the compiler is needed?
check_config_h
()
# XXX Things not currently handled:
# * see UnixCCompiler
class
CygwinCCompiler
(
UnixCCompiler
):
class
CygwinCCompiler
(
UnixCCompiler
):
compiler_type
=
'cygwin'
compiler_type
=
'cygwin'
...
@@ -54,21 +61,22 @@ class CygwinCCompiler (UnixCCompiler):
...
@@ -54,21 +61,22 @@ class CygwinCCompiler (UnixCCompiler):
UnixCCompiler
.
__init__
(
self
,
verbose
,
dry_run
,
force
)
UnixCCompiler
.
__init__
(
self
,
verbose
,
dry_run
,
force
)
# our compiler uses other names
# Hard-code GCC because that's what this is all about.
self
.
cc
=
'gcc'
# XXX optimization, warnings etc. should be customizable.
self
.
ld_shared
=
'dllwrap'
self
.
set_executables
(
compiler
=
'gcc -O -Wall'
,
self
.
ldflags_shared
=
[]
compiler_so
=
'gcc -O -Wall'
,
linker_exe
=
'gcc'
,
# some variables to manage the differences between cygwin and mingw32
linker_so
=
'dllwrap --target=i386-cygwin32'
)
self
.
dllwrap_options
=
[
"--target=i386-cygwin32"
]
# specification of entry point is not necessary
# cygwin and mingw32 need different sets of libraries
self
.
dll_libraries
=
[
self
.
dll_additional_libraries
=
[
# cygwin shouldn't need msvcrt,
# cygwin shouldn't need msvcrt, but without the dll's will crash
# but without the dll's will crash
# perhaps something about initialization (Python uses it, too)
# ( gcc version 2.91.57 )
# perhaps something about initialization
# mingw32 needs it in all cases
# mingw32 needs it in all cases
"msvcrt"
"msvcrt"
]
]
# __init__ ()
# __init__ ()
...
@@ -80,79 +88,88 @@ class CygwinCCompiler (UnixCCompiler):
...
@@ -80,79 +88,88 @@ class CygwinCCompiler (UnixCCompiler):
library_dirs
=
None
,
library_dirs
=
None
,
runtime_library_dirs
=
None
,
runtime_library_dirs
=
None
,
export_symbols
=
None
,
export_symbols
=
None
,
debug
=
0
,
debug
=
0
,
extra_preargs
=
None
,
extra_preargs
=
None
,
extra_postargs
=
None
):
extra_postargs
=
None
,
build_temp
=
None
):
if
libraries
==
None
:
if
libraries
==
None
:
libraries
=
[]
libraries
=
[]
python_library
=
[
"python"
+
str
(
sys
.
hexversion
>>
24
)
+
str
((
sys
.
hexversion
>>
16
)
&
0xff
)]
# Additional libraries: the python library is always needed on
libraries
=
libraries
+
python_library
+
self
.
dll_additional_libraries
# Windows we need the python version without the dot, eg. '15'
# if you don't need the def-file afterwards, it is
pythonlib
=
(
"python%d%d"
%
# better to use for it tempfile.mktemp() as its name
(
sys
.
hexversion
>>
24
,
(
sys
.
hexversion
>>
16
)
&
0xff
))
# (unix-style compilers don't like backslashes in filenames)
libraries
.
append
(
pythonlib
)
win_dll_def_file
=
string
.
replace
(
tempfile
.
mktemp
(),
"
\
\
"
,
"/"
)
libraries
.
extend
(
self
.
dll_libraries
)
#win_dll_def_file=output_filename[:-len(self.shared_lib_extension)]+".def"
#win_dll_exp_file=output_filename[:-len(self.shared_lib_extension)]+".exp"
# name of extension
#win_dll_lib_file=output_filename[:-len(self.shared_lib_extension)]+".a"
# XXX WRONG WRONG WRONG
# this is NOT the place to make guesses about Python namespaces;
# that MUST be done in build_ext.py
if
not
debug
:
ext_name
=
os
.
path
.
basename
(
output_filename
)[:
-
len
(
".pyd"
)]
else
:
ext_name
=
os
.
path
.
basename
(
output_filename
)[:
-
len
(
"_d.pyd"
)]
def_file
=
os
.
path
.
join
(
build_temp
,
ext_name
+
".def"
)
#exp_file = os.path.join(build_temp, ext_name + ".exp")
#lib_file = os.path.join(build_temp, 'lib' + ext_name + ".a")
# Make .def file
# Make .def file
# (It would probably better to check if we really need this, but for this we had to
# (It would probably better to check if we really need this,
# insert some unchanged parts of UnixCCompiler, and this is not what I want.)
# but for this we had to insert some unchanged parts of
f
=
open
(
win_dll_def_file
,
"w"
)
# UnixCCompiler, and this is not what we want.)
f
=
open
(
def_file
,
"w"
)
f
.
write
(
"EXPORTS
\
n
"
)
# intro
f
.
write
(
"EXPORTS
\
n
"
)
# intro
# always export a function "init"+module_name
if
export_symbols
==
None
:
if
not
debug
:
# export a function "init" + ext_name
f
.
write
(
"init"
+
os
.
path
.
basename
(
output_filename
)[:
-
len
(
self
.
shared_lib_extension
)]
+
"
\
n
"
)
f
.
write
(
"init"
+
ext_name
+
"
\
n
"
)
else
:
# in debug mode outfile_name is something like XXXXX_d.pyd
else
:
f
.
write
(
"init"
+
os
.
path
.
basename
(
output_filename
)[:
-
(
len
(
self
.
shared_lib_extension
)
+
2
)]
+
"
\
n
"
)
# if there are more symbols to export write them into f
# if there are more symbols to export
# insert code here to write them in f
if
export_symbols
!=
None
:
for
sym
in
export_symbols
:
for
sym
in
export_symbols
:
f
.
write
(
sym
+
"
\
n
"
)
f
.
write
(
sym
+
"
\
n
"
)
f
.
close
()
f
.
close
()
if
extra_preargs
==
None
:
if
extra_preargs
==
None
:
extra_preargs
=
[]
extra_preargs
=
[]
extra_preargs
=
extra_preargs
+
[
extra_preargs
=
extra_preargs
+
[
#"--verbose",
#"--verbose",
#"--output-exp",
win_dll_
exp_file,
#"--output-exp",exp_file,
#"--output-lib",
win_dll_
lib_file,
#"--output-lib",lib_file,
"--def"
,
win_dll_
def_file
"--def"
,
def_file
]
+
self
.
dllwrap_options
]
# who wants symbols and a many times
great
er output file
# who wants symbols and a many times
larg
er output file
# should explicitely switch the debug mode on
# should explicitely switch the debug mode on
# otherwise we let dllwrap strip the outputfile
# otherwise we let dllwrap strip the output
file
# (On my machine unstripped_file
=stripped_file+
254KB
# (On my machine unstripped_file
= stripped_file +
254KB
# 10KB < stripped_file < ??100KB )
# 10KB < stripped_file < ??100KB )
if
not
debug
:
if
not
debug
:
extra_preargs
=
extra_preargs
+
[
"-s"
]
extra_preargs
=
extra_preargs
+
[
"-s"
]
try
:
UnixCCompiler
.
link_shared_object
(
self
,
UnixCCompiler
.
link_shared_object
(
self
,
objects
,
objects
,
output_filename
,
output_filename
,
output_dir
,
output_dir
,
libraries
,
libraries
,
library_dirs
,
library_dirs
,
runtime_library_dirs
,
runtime_library_dirs
,
None
,
# export_symbols, we do this with our def-file
None
,
# export_symbols, we do this with our def-file
debug
,
debug
,
extra_preargs
,
extra_preargs
,
extra_postargs
)
extra_postargs
,
finally
:
build_temp
)
# we don't need the def-file anymore
os
.
remove
(
win_dll_def_file
)
# link_shared_object ()
# link_shared_object ()
# class CygwinCCompiler
# class CygwinCCompiler
# the same as cygwin plus some additional parameters
# the same as cygwin plus some additional parameters
class
Mingw32CCompiler
(
CygwinCCompiler
):
class
Mingw32CCompiler
(
CygwinCCompiler
):
...
@@ -165,14 +182,15 @@ class Mingw32CCompiler (CygwinCCompiler):
...
@@ -165,14 +182,15 @@ class Mingw32CCompiler (CygwinCCompiler):
CygwinCCompiler
.
__init__
(
self
,
verbose
,
dry_run
,
force
)
CygwinCCompiler
.
__init__
(
self
,
verbose
,
dry_run
,
force
)
self
.
ccflags
=
self
.
ccflags
+
[
"-mno-cygwin"
]
self
.
set_executables
(
compiler
=
'gcc -mno-cygwin -O -Wall'
,
self
.
dllwrap_options
=
[
compiler_so
=
'gcc -mno-cygwin -O -Wall'
,
# mingw32 doesn't really need 'target'
linker_exe
=
'gcc -mno-cygwin'
,
# and cygwin too (it seems, it is enough
linker_so
=
'dllwrap'
# to specify a different entry point)
+
' --target=i386-mingw32'
#"--target=i386-mingw32",
+
' --entry _DllMain@12'
)
"--entry"
,
"_DllMain@12"
# mingw32 doesn't really need 'target' and cygwin too (it seems,
]
# it is enough to specify a different entry point)
# no additional libraries need
# no additional libraries need
# (only msvcrt, which is already added by CygwinCCompiler)
# (only msvcrt, which is already added by CygwinCCompiler)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment