3 # Checkout files from the SWIG library into Subversion's proxy directory
6 import sys
, os
, re
, fileinput
, shutil
7 if __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
) ]
11 from gen_base
import build_path_splitfile
, build_path_join
12 from generator
.util
.executable
import run
14 class Generator(generator
.swig
.Generator
):
17 """Checkout all files"""
18 for path
in self
.swig_checkout_files
:
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
))
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
):
41 if self
._skip
_checkout
(path
):
43 elif self
.version() == 103024:
44 shutil
.copy(build_path_join(self
.swig_libdir
, path
), out
)
46 run("%s -o %s -co %s" % (self
.swig_path
, out
, path
))
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)
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
)
58 if __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."
64 gen
= Generator(sys
.argv
[1], sys
.argv
[2])
65 gen
.checkout(sys
.argv
[3])