]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/my_distutils.py
4 from distutils
.msvccompiler
import MSVCCompiler
6 from distutils
.errors
import \
7 DistutilsExecError
, DistutilsPlatformError
, \
8 CompileError
, LibError
, LinkError
9 from distutils
.ccompiler
import \
10 CCompiler
, gen_preprocess_options
, gen_lib_options
12 #----------------------------------------------------------------------
14 class MyMSVCCompiler(MSVCCompiler
):
16 ##------------------------------------------------------------
17 ## Override the entire compile method just to add flags to the
18 ## RC command. There should be an easier way to do this from
19 ## distutils directly or in a derived class...
20 ##------------------------------------------------------------
31 (output_dir
, macros
, include_dirs
) = \
32 self
._fix
_compile
_args
(output_dir
, macros
, include_dirs
)
33 (objects
, skip_sources
) = self
._prep
_compile
(sources
, output_dir
)
35 if extra_postargs
is None:
38 pp_opts
= gen_preprocess_options (macros
, include_dirs
)
39 compile_opts
= extra_preargs
or []
40 compile_opts
.append ('/c')
42 compile_opts
.extend (self
.compile_options_debug
)
44 compile_opts
.extend (self
.compile_options
)
46 for i
in range (len (sources
)):
47 src
= sources
[i
] ; obj
= objects
[i
]
48 ext
= (os
.path
.splitext (src
))[1]
51 self
.announce ("skipping %s (%s up-to-date)" % (src
, obj
))
53 self
.mkpath (os
.path
.dirname (obj
))
55 if ext
in self
._c
_extensions
:
56 input_opt
= "/Tc" + os
.path
.abspath(src
)
57 elif ext
in self
._cpp
_extensions
:
58 input_opt
= "/Tp" + os
.path
.abspath(src
)
59 elif ext
in self
._rc
_extensions
:
60 # compile .RC to .RES file
62 output_opt
= "/fo" + obj
64 self
.spawn ([self
.rc
] + pp_opts
+ ### RPD changed this line only
65 [output_opt
] + [input_opt
])
66 except DistutilsExecError
, msg
:
67 raise CompileError
, msg
69 elif ext
in self
._mc
_extensions
:
71 # Compile .MC to .RC file to .RES file.
72 # * '-h dir' specifies the directory for the
73 # generated include file
74 # * '-r dir' specifies the target directory of the
75 # generated RC file and the binary message resource
78 # For now (since there are no options to change this),
79 # we use the source-directory for the include file and
80 # the build directory for the RC file and message
81 # resources. This works at least for win32all.
83 h_dir
= os
.path
.dirname (src
)
84 rc_dir
= os
.path
.dirname (obj
)
86 # first compile .MC to .RC and .H file
87 self
.spawn ([self
.mc
] +
88 ['-h', h_dir
, '-r', rc_dir
] + [src
])
89 base
, _
= os
.path
.splitext (os
.path
.basename (src
))
90 rc_file
= os
.path
.join (rc_dir
, base
+ '.rc')
91 # then compile .RC to .RES file
92 self
.spawn ([self
.rc
] +
93 ["/fo" + obj
] + [rc_file
])
95 except DistutilsExecError
, msg
:
96 raise CompileError
, msg
99 # how to handle this file?
101 "Don't know how to compile %s to %s" % \
104 output_opt
= "/Fo" + obj
106 self
.spawn ([self
.cc
] + compile_opts
+ pp_opts
+
107 [input_opt
, output_opt
] +
109 except DistutilsExecError
, msg
:
110 raise CompileError
, msg
120 #----------------------------------------------------------------------
121 # Hack this module and class into the distutils...
123 from distutils
import ccompiler
125 ccompiler
.default_compiler
['nt'] = 'my_msvc'
126 ccompiler
.compiler_class
['my_msvc'] = ('my_distutils',
128 'My MSVC derived class')
131 # make it look like it is part of the package...
133 sys
.modules
['distutils.my_distutils'] = my_distutils
138 #----------------------------------------------------------------------
139 # Run SWIG the way I want it done
141 def run_swig(files
, dir, gendir
, package
, USE_SWIG
, force
, swig_args
, swig_deps
=[]):
142 from distutils
.file_util
import copy_file
143 from distutils
.dep_util
import newer
144 from distutils
.spawn
import spawn
149 basefile
= os
.path
.splitext(file)[0]
150 i_file
= os
.path
.join(dir, file)
151 py_file
= os
.path
.join(dir, gendir
, basefile
+'.py')
152 cpp_file
= os
.path
.join(dir, gendir
, basefile
+'.cpp')
154 sources
.append(cpp_file
)
157 for dep
in swig_deps
:
158 if newer(dep
, py_file
) or newer(dep
, cpp_file
):
162 if force
or newer(i_file
, py_file
) or newer(i_file
, cpp_file
):
163 # we need forward slashes here even on win32
164 cpp_file
= string
.join(string
.split(cpp_file
, '\\'), '/')
165 i_file
= string
.join(string
.split(i_file
, '\\'), '/')
167 cmd
= ['swig'] + swig_args
+ ['-I'+dir, '-c', '-o', cpp_file
, i_file
]
168 spawn(cmd
, verbose
=1)
170 # copy the generated python file to the package directory
171 copy_file(py_file
, package
, update
=not force
, verbose
=0)
178 #----------------------------------------------------------------------
179 # Update local copies of wxWindows contrib files
182 def contrib_copy_tree(src
, dest
, verbose
=0):
183 from distutils
.dir_util
import mkpath
, copy_tree
185 mkpath(dest
, verbose
=verbose
)
186 copy_tree(src
, dest
, update
=1, verbose
=verbose
)