source: valtobtest/subversion-1.6.2/build/generator/swig/checkout_swig_header.py @ 3

Last change on this file since 3 was 3, checked in by valtob, 15 years ago

subversion source 1.6.2 as test

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#!/usr/bin/env python
2#
3# Checkout files from the SWIG library into Subversion's proxy directory
4#
5
6import sys, os, re, fileinput, shutil
7if __name__ == "__main__":
8  parent_dir = os.path.dirname(os.path.abspath(os.path.dirname(sys.argv[0])))
9  sys.path[0:0] = [ parent_dir, os.path.dirname(parent_dir) ]
10import generator.swig
11from gen_base import build_path_splitfile, build_path_join
12from generator.util.executable import run
13
14class Generator(generator.swig.Generator):
15
16  def write(self):
17    """Checkout all files"""
18    for path in self.swig_checkout_files:
19      self.checkout(path)
20
21  def write_makefile_rules(self, makefile):
22    """Write makefile rules to checkout files"""
23    script_path = '$(top_srcdir)/build/generator/swig/checkout_swig_header.py'
24    conf = '$(abs_srcdir)/build.conf'
25    makefile.write('CHECKOUT_SWIG = cd $(top_builddir) && $(PYTHON)' +
26                   ' %s %s $(SWIG)\n\n' % (script_path, conf))
27    checkout_locations = []
28    for path in self.swig_checkout_files:
29      out = self._output_file(path)
30      checkout_locations.append(out)
31      makefile.write('%s: %s\n' % (out, script_path) +
32                     '\t$(CHECKOUT_SWIG) %s\n\n' % path)
33    makefile.write('SWIG_CHECKOUT_FILES = %s\n\n\n'
34                   % " ".join(checkout_locations))
35
36  def checkout(self, path):
37    """Checkout a specific header file from SWIG"""
38    out = self._output_file(path)
39    if os.path.exists(out):
40      os.remove(out)
41    if self._skip_checkout(path):
42      open(out, "w")
43    elif self.version() == 103024:
44      shutil.copy(build_path_join(self.swig_libdir, path), out)
45    else:
46      run("%s -o %s -co %s" % (self.swig_path, out, path))
47
48  def _skip_checkout(self, path):
49    """Should we skip this checkout?"""
50    return (path == "ruby/rubytracking.swg" and self.version() < 103026 or
51            path == "common.swg" and self.version() > 103024)
52
53  def _output_file(self, path):
54    """Get output filename"""
55    dir, filename = build_path_splitfile(path)
56    return build_path_join(self.proxy_dir, filename)
57
58if __name__ == "__main__":
59  if len(sys.argv) != 4:
60    print("Usage: %s build.conf swig file.swg")
61    print("Checkout a specific header file from SWIG's library into")
62    print("the Subversion proxy directory.")
63  else:
64    gen = Generator(sys.argv[1], sys.argv[2])
65    gen.checkout(sys.argv[3])
Note: See TracBrowser for help on using the repository browser.