mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 19:10:09 +01:00
* Refactor the code that post-processes the code output by SIP to a separate function so it can be used in more than one place.
* Check for the presense of a msgfmt command before trying to rebuild the message catalogs git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69490 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
38
build.py
38
build.py
@@ -17,7 +17,7 @@ import urllib2
|
||||
import hashlib
|
||||
|
||||
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, findCmd
|
||||
import buildtools.version as version
|
||||
|
||||
# defaults
|
||||
@@ -458,7 +458,15 @@ def sip(options, args):
|
||||
cmd = '%s %s -c %s -b %s %s %s' % \
|
||||
(sip, cfg.SIPOPTS, tmpdir, sbf, pycode, src_name)
|
||||
runcmd(cmd)
|
||||
|
||||
|
||||
def processSrc(src):
|
||||
with file(src, 'rt') as f:
|
||||
srcTxt = f.read()
|
||||
srcTxt = srcTxt.replace(tmpdir, cfg.SIPOUT)
|
||||
# TODO: remove lines starting with '#line'?
|
||||
return srcTxt
|
||||
|
||||
# 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.
|
||||
@@ -466,13 +474,13 @@ def sip(options, args):
|
||||
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)
|
||||
srcTxt = processSrc(src)
|
||||
f = file(dest, 'wt')
|
||||
f.write(srcTxt)
|
||||
f.close()
|
||||
continue
|
||||
|
||||
with file(src, 'rt') as f:
|
||||
srcTxt = f.read()
|
||||
srcTxt = srcTxt.replace(tmpdir, cfg.SIPOUT)
|
||||
# TODO remove lines starting with '#line'?
|
||||
|
||||
srcTxt = processSrc(src)
|
||||
with file(dest, 'rt') as f:
|
||||
destTxt = f.read()
|
||||
|
||||
@@ -599,10 +607,18 @@ def build_wx(options, args):
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
|
||||
os.chdir(os.path.join(wxDir(), 'locale'))
|
||||
print 'Building message catalogs'
|
||||
runcmd('make allmo')
|
||||
|
||||
# Build the wx message catalogs, but first check that there is a msgfmt
|
||||
# command available
|
||||
if findCmd('msgfmt'):
|
||||
old = os.getcwd()
|
||||
os.chdir(os.path.join(wxDir(), 'locale'))
|
||||
print 'Building message catalogs'
|
||||
runcmd('make allmo')
|
||||
os.chdir(old)
|
||||
else:
|
||||
print "WARNING: msgfmt command not found, message catalogs not rebulit.\n" \
|
||||
" Please install gettext and associated tools."
|
||||
|
||||
|
||||
|
||||
def build_py(options, args):
|
||||
|
||||
@@ -565,3 +565,17 @@ def getEtgSipCppFiles(etg):
|
||||
def getEtgSipHeaders(etg):
|
||||
return _getSbfValue(etg, 'headers')
|
||||
|
||||
|
||||
def findCmd(cmd):
|
||||
"""
|
||||
Search the PATH for a matching command
|
||||
"""
|
||||
PATH = os.environ['PATH'].split(os.pathsep)
|
||||
if os.name == 'nt' and not cmd.endswith('.exe'):
|
||||
cmd += '.exe'
|
||||
for p in PATH:
|
||||
c = os.path.join(p, cmd)
|
||||
if os.path.exists(c):
|
||||
return c
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user