mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 11:00:07 +01:00
Since we're running the etg scripts and sip from build.py then we don't need the distutils hacks needed to run them from setup.py. Deactivate the and just use normal distutils stuff on the generated C++ files.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69075 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
36
build.py
36
build.py
@@ -13,6 +13,7 @@ import glob
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import optparse
|
import optparse
|
||||||
|
import tempfile
|
||||||
|
|
||||||
from distutils.dep_util import newer, newer_group
|
from distutils.dep_util import newer, newer_group
|
||||||
from buildtools.config import Config, msg, opj, posixjoin, loadETG, etg2sip
|
from buildtools.config import Config, msg, opj, posixjoin, loadETG, etg2sip
|
||||||
@@ -374,6 +375,7 @@ def sip(options, args):
|
|||||||
msg('Running command: sip')
|
msg('Running command: sip')
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
for src_name in glob.glob(opj(cfg.SIPGEN, '_*.sip')):
|
for src_name in glob.glob(opj(cfg.SIPGEN, '_*.sip')):
|
||||||
|
tmpdir = tempfile.mkdtemp()
|
||||||
src_name = src_name.replace('\\', '/')
|
src_name = src_name.replace('\\', '/')
|
||||||
base = os.path.basename(os.path.splitext(src_name)[0])
|
base = os.path.basename(os.path.splitext(src_name)[0])
|
||||||
sbf = posixjoin(cfg.SIPOUT, base) + '.sbf'
|
sbf = posixjoin(cfg.SIPOUT, base) + '.sbf'
|
||||||
@@ -381,10 +383,39 @@ def sip(options, args):
|
|||||||
pycode = posixjoin(cfg.PKGDIR, pycode) + '.py'
|
pycode = posixjoin(cfg.PKGDIR, pycode) + '.py'
|
||||||
pycode = '-X pycode:'+pycode
|
pycode = '-X pycode:'+pycode
|
||||||
cmd = '%s %s -c %s -b %s %s %s' % \
|
cmd = '%s %s -c %s -b %s %s %s' % \
|
||||||
(cfg.SIP, cfg.SIPOPTS, cfg.SIPOUT, sbf, pycode, src_name)
|
(cfg.SIP, cfg.SIPOPTS, tmpdir, sbf, pycode, src_name)
|
||||||
runcmd(cmd)
|
runcmd(cmd)
|
||||||
|
|
||||||
|
# Check each file in tmpdir to see if it is different than the same file
|
||||||
|
# in cfg.SIPOUT. If so then copy the new one to cfg.SIPOUT, otherwise
|
||||||
|
# ignore it.
|
||||||
|
for src in glob.glob(tmpdir + '/*'):
|
||||||
|
dest = opj(cfg.SIPOUT, os.path.basename(src))
|
||||||
|
if not os.path.exists(dest):
|
||||||
|
msg('%s is a new file, copying...' % os.path.basename(src))
|
||||||
|
shutil.copy2(src, dest)
|
||||||
|
continue
|
||||||
|
|
||||||
|
with file(src, 'rb') as f:
|
||||||
|
srcTxt = f.read()
|
||||||
|
srcTxt = srcTxt.replace(tmpdir, cfg.SIPOUT)
|
||||||
|
# TODO remove lines starting with '#line'?
|
||||||
|
with file(dest, 'rb') as f:
|
||||||
|
destTxt = f.read()
|
||||||
|
|
||||||
|
if srcTxt == destTxt:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
msg('%s is changed, copying...' % os.path.basename(src))
|
||||||
|
f = file(dest, 'wb')
|
||||||
|
f.write(srcTxt)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
# Remove tmpdir and its contents
|
||||||
|
shutil.rmtree(tmpdir)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def touch(options, args):
|
def touch(options, args):
|
||||||
msg('Running command: touch')
|
msg('Running command: touch')
|
||||||
pwd = pushDir(phoenixDir())
|
pwd = pushDir(phoenixDir())
|
||||||
@@ -664,6 +695,7 @@ def clean_py(options, args):
|
|||||||
clean_py(options, args)
|
clean_py(options, args)
|
||||||
options.both = True
|
options.both = True
|
||||||
|
|
||||||
|
|
||||||
def clean(options, args):
|
def clean(options, args):
|
||||||
clean_wx(options, args)
|
clean_wx(options, args)
|
||||||
clean_py(options, args)
|
clean_py(options, args)
|
||||||
|
|||||||
@@ -170,11 +170,11 @@ class Configuration(object):
|
|||||||
else:
|
else:
|
||||||
self.VCDLL = 'vc_dll'
|
self.VCDLL = 'vc_dll'
|
||||||
|
|
||||||
self.includes = ['include', 'src',
|
self.includes += ['include',
|
||||||
opj(self.WXDIR, 'lib', self.VCDLL, 'msw' + self.libFlag()),
|
opj(self.WXDIR, 'lib', self.VCDLL, 'msw' + self.libFlag()),
|
||||||
opj(self.WXDIR, 'include'),
|
opj(self.WXDIR, 'include'),
|
||||||
opj(self.WXDIR, 'contrib', 'include'),
|
opj(self.WXDIR, 'contrib', 'include'),
|
||||||
]
|
]
|
||||||
|
|
||||||
self.defines = [ ('WIN32', None),
|
self.defines = [ ('WIN32', None),
|
||||||
('_WINDOWS', None),
|
('_WINDOWS', None),
|
||||||
@@ -218,7 +218,7 @@ class Configuration(object):
|
|||||||
# Posix (wxGTK, wxMac or mingw32) settings
|
# Posix (wxGTK, wxMac or mingw32) settings
|
||||||
elif os.name == 'posix' or COMPILER == 'mingw32':
|
elif os.name == 'posix' or COMPILER == 'mingw32':
|
||||||
self.Verify_WX_CONFIG()
|
self.Verify_WX_CONFIG()
|
||||||
self.includes = ['include', 'src']
|
self.includes += ['include']
|
||||||
self.defines = [ ('NDEBUG',), # using a 1-tuple makes it do an undef
|
self.defines = [ ('NDEBUG',), # using a 1-tuple makes it do an undef
|
||||||
]
|
]
|
||||||
self.libdirs = []
|
self.libdirs = []
|
||||||
@@ -560,6 +560,24 @@ def loadETG(name):
|
|||||||
def etg2sip(etgfile):
|
def etg2sip(etgfile):
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
sipfile = os.path.splitext(os.path.basename(etgfile))[0] + '.sip'
|
sipfile = os.path.splitext(os.path.basename(etgfile))[0] + '.sip'
|
||||||
|
|
||||||
sipfile = posixjoin(cfg.SIPGEN, sipfile)
|
sipfile = posixjoin(cfg.SIPGEN, sipfile)
|
||||||
return sipfile
|
return sipfile
|
||||||
|
|
||||||
|
|
||||||
|
def _getSbfValue(etg, keyName):
|
||||||
|
cfg = Config()
|
||||||
|
sbf = opj(cfg.SIPOUT, etg.NAME + '.sbf')
|
||||||
|
out = list()
|
||||||
|
for line in file(sbf):
|
||||||
|
key, value = line.split('=')
|
||||||
|
if key.strip() == keyName:
|
||||||
|
return [opj(cfg.SIPOUT, v) for v in value.strip().split()]
|
||||||
|
return None
|
||||||
|
|
||||||
|
def getEtgSipCppFiles(etg):
|
||||||
|
return _getSbfValue(etg, 'sources')
|
||||||
|
|
||||||
|
def getEtgSipHeaders(etg):
|
||||||
|
return _getSbfValue(etg, 'headers')
|
||||||
|
|
||||||
|
|||||||
@@ -234,7 +234,23 @@ class MyUnixCCompiler(distutils.unixccompiler.UnixCCompiler):
|
|||||||
except DistutilsExecError, msg:
|
except DistutilsExecError, msg:
|
||||||
raise CompileError, msg
|
raise CompileError, msg
|
||||||
|
|
||||||
|
def _setup_compile(self, outdir, macros, incdirs, sources, depends, extra):
|
||||||
|
m = distutils.ccompiler.CCompiler._setup_compile
|
||||||
|
macros, objects, extra, pp_opts, build = \
|
||||||
|
m(self, outdir, macros, incdirs, sources, depends, extra)
|
||||||
|
|
||||||
|
# Remove items from the build collection that don't need to be built
|
||||||
|
# because their obj file is newer than the source fle and any other
|
||||||
|
# dependencies.
|
||||||
|
# TODO
|
||||||
|
for obj in objects:
|
||||||
|
src, ext = build[obj]
|
||||||
|
if not newer_group([src] + depends, obj):
|
||||||
|
del build[obj]
|
||||||
|
|
||||||
|
return macros, objects, extra, pp_opts, build
|
||||||
|
|
||||||
|
|
||||||
_orig_parse_makefile = distutils.sysconfig.parse_makefile
|
_orig_parse_makefile = distutils.sysconfig.parse_makefile
|
||||||
def _parse_makefile(filename, g=None):
|
def _parse_makefile(filename, g=None):
|
||||||
rv = _orig_parse_makefile(filename, g)
|
rv = _orig_parse_makefile(filename, g)
|
||||||
@@ -331,6 +347,7 @@ class etgsip_build_ext(build_ext):
|
|||||||
cfg = Config()
|
cfg = Config()
|
||||||
return cfg.SIPOUT
|
return cfg.SIPOUT
|
||||||
|
|
||||||
|
|
||||||
def build_extension(self, extension):
|
def build_extension(self, extension):
|
||||||
"""
|
"""
|
||||||
Modify the dependency list, adding the sip files generated
|
Modify the dependency list, adding the sip files generated
|
||||||
|
|||||||
33
setup.py
33
setup.py
@@ -17,7 +17,8 @@ from distutils.dir_util import mkpath
|
|||||||
from distutils.dep_util import newer, newer_group
|
from distutils.dep_util import newer, newer_group
|
||||||
from distutils.spawn import spawn
|
from distutils.spawn import spawn
|
||||||
|
|
||||||
from buildtools.config import Config, msg, opj, loadETG
|
from buildtools.config import Config, msg, opj, loadETG, \
|
||||||
|
getEtgSipCppFiles, getEtgSipHeaders
|
||||||
import buildtools.distutils_hacks as hacks
|
import buildtools.distutils_hacks as hacks
|
||||||
|
|
||||||
|
|
||||||
@@ -138,12 +139,11 @@ extensions.append(
|
|||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
etg = loadETG('etg/_core.py')
|
etg = loadETG('etg/_core.py')
|
||||||
etgDepends = etg.DEPENDS + etg.OTHERDEPS
|
ext = Extension('_core', getEtgSipCppFiles(etg) + rc_file,
|
||||||
ext = Extension('_core',
|
depends = getEtgSipHeaders(etg),
|
||||||
#['src/core_utils.cpp'] +
|
|
||||||
etg.ETGFILES + rc_file,
|
|
||||||
depends = etgDepends,
|
|
||||||
include_dirs = cfg.includes,
|
include_dirs = cfg.includes,
|
||||||
define_macros = cfg.defines,
|
define_macros = cfg.defines,
|
||||||
library_dirs = cfg.libdirs,
|
library_dirs = cfg.libdirs,
|
||||||
@@ -155,6 +155,23 @@ extensions.append(ext)
|
|||||||
cfg.CLEANUP.append(opj(cfg.PKGDIR, 'core.py'))
|
cfg.CLEANUP.append(opj(cfg.PKGDIR, 'core.py'))
|
||||||
|
|
||||||
|
|
||||||
|
#etg = loadETG('etg/_core.py')
|
||||||
|
#etgDepends = etg.DEPENDS + etg.OTHERDEPS
|
||||||
|
#ext = Extension('_core',
|
||||||
|
##['src/core_utils.cpp'] +
|
||||||
|
#etg.ETGFILES + rc_file,
|
||||||
|
#depends = etgDepends,
|
||||||
|
#include_dirs = cfg.includes,
|
||||||
|
#define_macros = cfg.defines,
|
||||||
|
#library_dirs = cfg.libdirs,
|
||||||
|
#libraries = cfg.libs,
|
||||||
|
#extra_compile_args = cfg.cflags,
|
||||||
|
#extra_link_args = cfg.lflags,
|
||||||
|
#)
|
||||||
|
#extensions.append(ext)
|
||||||
|
#cfg.CLEANUP.append(opj(cfg.PKGDIR, 'core.py'))
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@@ -177,7 +194,7 @@ if __name__ == '__main__':
|
|||||||
ext_modules = extensions,
|
ext_modules = extensions,
|
||||||
|
|
||||||
options = { 'build' : BUILD_OPTIONS,
|
options = { 'build' : BUILD_OPTIONS,
|
||||||
'build_ext' : {'sip_opts' : cfg.SIPOPTS },
|
#**'build_ext' : {'sip_opts' : cfg.SIPOPTS },
|
||||||
},
|
},
|
||||||
|
|
||||||
scripts = SCRIPTS,
|
scripts = SCRIPTS,
|
||||||
@@ -189,7 +206,7 @@ if __name__ == '__main__':
|
|||||||
'install_data' : hacks.wx_smart_install_data,
|
'install_data' : hacks.wx_smart_install_data,
|
||||||
'install_headers' : hacks.wx_install_headers,
|
'install_headers' : hacks.wx_install_headers,
|
||||||
'clean' : hacks.wx_extra_clean,
|
'clean' : hacks.wx_extra_clean,
|
||||||
'build_ext' : hacks.etgsip_build_ext,
|
#**'build_ext' : hacks.etgsip_build_ext,
|
||||||
},
|
},
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user