From 7a4a5eb4cf5c9dc5eeb2439c7bdeab188c498b6c Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 31 May 2012 20:31:03 +0000 Subject: [PATCH] Check dependencies and skip running sip if nothing is out of date. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71618 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- build.py | 14 ++++++++++---- buildtools/config.py | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/build.py b/build.py index 491b6df7..1db142d6 100755 --- a/build.py +++ b/build.py @@ -29,7 +29,7 @@ from distutils.dep_util import newer, newer_group from buildtools.config import Config, msg, opj, posixjoin, loadETG, etg2sip, findCmd, \ phoenixDir, wxDir, copyIfNewer, copyFile, \ macFixDependencyInstallName, macSetLoaderNames, \ - getSvnRev, runcmd, textfile_open + getSvnRev, runcmd, textfile_open, getSipFiles import buildtools.version as version @@ -702,14 +702,20 @@ def sip(options, args): modules.insert(0, opj(cfg.SIPGEN, '_core.sip')) for src_name in modules: - # TODO: Add some dependency checking here. If none of the included - # files has been updated then running sip can probably be avoided. - # OTOH, it's fast enough that it probably doesn't matter. tmpdir = tempfile.mkdtemp() tmpdir = tmpdir.replace('\\', '/') src_name = src_name.replace('\\', '/') base = os.path.basename(os.path.splitext(src_name)[0]) sbf = posixjoin(cfg.SIPOUT, base) + '.sbf' + + # Check if any of the included files are newer than the .sbf file + # produced by the previous run of sip. If not then we don't need to + # run sip again. + etg = loadETG(posixjoin('etg', base + '.py')) + sipFiles = getSipFiles(etg.INCLUDES) + if not newer_group(sipFiles, sbf): + continue + pycode = base[1:] # remove the leading _ pycode = posixjoin(cfg.PKGDIR, pycode) + '.py' pycode = '-X pycode'+base+':'+pycode diff --git a/buildtools/config.py b/buildtools/config.py index 78e26fe0..726e0239 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -788,3 +788,19 @@ def textfile_open(filename, mode='rt'): return codecs.open(filename, mode, encoding='utf-8') else: return open(filename, mode, encoding='utf-8') + + +def getSipFiles(names): + """ + Returns a list of the coresponding .sip files for each of the names in names. + """ + files = list() + for template in ['sip/gen/%s.sip', 'src/%s.sip']: + for name in names: + name = template % name + if os.path.exists(name): + files.append(name) + return files + + +