diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-08-05 16:22:51 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-08-05 16:22:51 +0000 |
commit | cf46733632c7279a9fd0fe6ce26f9185a4ae82a9 (patch) | |
tree | da27775a2161723ef342e91af41a8b51fedef405 /build/generator/swig | |
parent | bb0ef45f7c46b0ae221b26265ef98a768c33f820 (diff) | |
download | subversion-tarball-master.tar.gz |
subversion-1.9.7HEADsubversion-1.9.7master
Diffstat (limited to 'build/generator/swig')
-rw-r--r-- | build/generator/swig/__init__.py | 17 | ||||
-rwxr-xr-x | build/generator/swig/external_runtime.py | 33 |
2 files changed, 42 insertions, 8 deletions
diff --git a/build/generator/swig/__init__.py b/build/generator/swig/__init__.py index 99820cc..993d17b 100644 --- a/build/generator/swig/__init__.py +++ b/build/generator/swig/__init__.py @@ -61,10 +61,17 @@ class Generator: self.swig_path = swig_path self.swig_libdir = _exec.output([self.swig_path, "-swiglib"], strip=1) + _swigVersion = None def version(self): """Get the version number of SWIG""" - swig_version = _exec.output([self.swig_path, "-version"]) - m = re.search("Version (\d+).(\d+).(\d+)", swig_version) - if m: - return (m.group(1), m.group(2), m.group(3)) - return (0, 0, 0) + + if not self._swigVersion: + swig_version = _exec.output([self.swig_path, "-version"]) + m = re.search("Version (\d+).(\d+).(\d+)", swig_version) + if m: + self._swigVersion = tuple(map(int, m.groups())) + else: + self._swigVersion = (0, 0, 0) + + # Copy value to avoid changes + return tuple(list(self._swigVersion)) diff --git a/build/generator/swig/external_runtime.py b/build/generator/swig/external_runtime.py index bbf58fc..c37c225 100755 --- a/build/generator/swig/external_runtime.py +++ b/build/generator/swig/external_runtime.py @@ -24,7 +24,12 @@ # external_runtime.py: Generate external runtime files for SWIG # -import sys, os, re, fileinput +import sys +import os +import re +import fileinput +import filecmp + if __name__ == "__main__": parent_dir = os.path.dirname(os.path.abspath(os.path.dirname(sys.argv[0]))) sys.path[0:0] = [ parent_dir, os.path.dirname(parent_dir) ] @@ -63,8 +68,10 @@ class Generator(generator.swig.Generator): "python": "pyrun.swg", "perl":"perlrun.swg", "ruby":"rubydef.swg" } - # Build runtime files - out = self._output_file(lang) + # Build runtime files to temporary location + dest = self._output_file(lang) + out = dest + '.tmp' + if self.version() == (1, 3, 24): out_file = open(out, "w") out_file.write(open("%s/swigrun.swg" % self.proxy_dir).read()) @@ -99,6 +106,26 @@ class Generator(generator.swig.Generator): sys.stdout.write( re.sub(r"SWIG_GetModule\(\)", "SWIG_GetModule(NULL)", line) ) + + # Did the output change? + try: + if filecmp.cmp(dest, out): + identical = True + else: + identical = False + except: + identical = False + + # Only overwrite file if changed + if identical: + os.remove(out) + else: + try: + os.remove(dest) + except: pass + os.rename(out, dest) + print('Wrote %s' % (dest,)) + def _output_file(self, lang): """Return the output filename of the runtime for the given language""" return '%s/swig_%s_external_runtime.swg' % (self.proxy_dir, lang) |