[Python-checkins] CVS: distutils/distutils/command build_ext.py,1.48,1.49

Greg Ward python-dev@python.org
Mon, 26 Jun 2000 18:37:12 -0700


Update of /cvsroot/python/distutils/distutils/command
In directory slayer.i.sourceforge.net:/tmp/cvs-serv2081

Modified Files:
	build_ext.py 
Log Message:
Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Also supposedly made some change to where .lib files wind up under MSVC++,
  but I don't understand how to code is doing what Thomas says it's
  doing.


Index: build_ext.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -r1.48 -r1.49
*** build_ext.py	2000/06/25 02:30:15	1.48
--- build_ext.py	2000/06/27 01:37:10	1.49
***************
*** 78,81 ****
--- 78,83 ----
          ('compiler=', 'c',
           "specify the compiler type"),
+         ('swig-cpp', None,
+          "make SWIG create C++ files (default is C)"),
          ]
  
***************
*** 102,105 ****
--- 104,108 ----
          self.force = None
          self.compiler = None
+         self.swig_cpp = None
  
  
***************
*** 444,456 ****
          swig_targets = {}
  
!         # XXX this drops generated C files into the source tree, which
          # is fine for developers who want to distribute the generated
          # source -- but there should be an option to put SWIG output in
          # the temp dir.
  
          for source in sources:
              (base, ext) = os.path.splitext(source)
              if ext == ".i":             # SWIG interface file
!                 new_sources.append(base + ".c") # umm, what if it's C++?
                  swig_sources.append(source)
                  swig_targets[source] = new_sources[-1]
--- 447,464 ----
          swig_targets = {}
  
!         # XXX this drops generated C/C++ files into the source tree, which
          # is fine for developers who want to distribute the generated
          # source -- but there should be an option to put SWIG output in
          # the temp dir.
  
+         if self.swig_cpp:
+             target_ext = '.cpp'
+         else:
+             target_ext = '.c'
+ 
          for source in sources:
              (base, ext) = os.path.splitext(source)
              if ext == ".i":             # SWIG interface file
!                 new_sources.append(base + target_ext)
                  swig_sources.append(source)
                  swig_targets[source] = new_sources[-1]
***************
*** 462,470 ****
  
          swig = self.find_swig()
!         swig_cmd = [swig, "-python", "-dnone", "-ISWIG"] # again, C++?!?
  
          for source in swig_sources:
!             self.announce ("swigging %s to %s" % (src, obj))
!             self.spawn(swig_cmd + ["-o", swig_targets[source], source])
  
          return new_sources
--- 470,481 ----
  
          swig = self.find_swig()
!         swig_cmd = [swig, "-python", "-dnone", "-ISWIG"]
!         if self.swig_cpp:
!             swig_cmd.append ("-c++")
  
          for source in swig_sources:
!             target = swig_targets[source]
!             self.announce ("swigging %s to %s" % (source, target))
!             self.spawn(swig_cmd + ["-o", target, source])
  
          return new_sources
***************
*** 529,536 ****
              extra_args.append('/export:init%s' % modname)
  
!         # The MSVC linker generates unneeded .lib and .exp files,
!         # which cannot be suppressed by any linker switches.  So
!         # make sure they are generated in the temporary build
!         # directory.
          implib_file = os.path.join (
              self.build_temp,
--- 540,548 ----
              extra_args.append('/export:init%s' % modname)
  
!         # The MSVC linker generates .lib and .exp files, which cannot be
!         # suppressed by any linker switches. The .lib files may even be
!         # needed! Make sure they are generated in the temporary build
!         # directory. Since they have different names for debug and release
!         # builds, they can go into the same directory.
          implib_file = os.path.join (
              self.build_temp,