D.J. Heap wrote:
> Branko Čibej wrote:
> 
>> D.J. Heap wrote:
>>
>>
>>> This should apply against r6313 cleanly -- but I thought I had tested
>>> the last one, also, so if it doesn't work please let me know where the
>>> conflicts are.
>>
>>
>>
>> This patch applied cleanly for me, too. Committed in revision 6316. 
>> Thanks!
>>
>> There's still a ton of things that could be moved from gen_msvc_dsp.py
>> and gen_vcnet_vcproj.py into gen_win.py... Aaah, I'm too lazy to do it.
>>
> 
> Sorry, I was being lazy first.  This patch should move just about 
> everything possible into gen_win.py.  I wasn't sure if the _item class 
> that moved to gen_win.py should be renamed or not, so I just left it.
> 
> DJ
> 
And then I forget the log message...argh.
Log:
Refactor code common to dsp and vcproj generator into gen_win.py.
* build/generator/gen_vcnet_vcproj.py
* build/generator/gen_msvc_dsp.py
   (write_project): refactor configs and sources generation into
   calls to gen_win.py
   (write): refactor install_targets generation into call to
   gen_win.py and use it's new _item class
   (class _item):  moved to gen_win.py
* build/generator/gen_win.py
   (get_install_targets): refactored method
   (get_configs): refactored method
   (get_proj_sources): refactored method
   (class _item): refactored class
Index: build/generator/gen_vcnet_vcproj.py
===================================================================
--- build/generator/gen_vcnet_vcproj.py	(revision 6316)
+++ build/generator/gen_vcnet_vcproj.py	(working copy)
@@ -49,41 +49,10 @@
     else:
       raise gen_base.GenError("Cannot create project for %s" % target.name)
 
-    configs = [ ]
-    for cfg in self.configs:
-      configs.append(_item(name=cfg,
-                           lower=string.lower(cfg),
-                           defines=self.get_win_defines(target, cfg),
-                           libdirs=self.get_win_lib_dirs(target,rootpath, cfg),
-                           libs=self.get_win_libs(target, cfg),
-                           ))
+    configs = self.get_configs(target, rootpath)
 
+    sources = self.get_proj_sources(False, target, rootpath)
 
-    sources = [ ]
-    
-    if not isinstance(target, gen_base.TargetUtility):
-      for src, reldir in self.get_win_sources(target):
-        rsrc = string.replace(os.path.join(rootpath, src), os.sep, '\\')
-        sources.append(_item(path=rsrc, reldir=reldir, swig_language=None,
-                             swig_output=None))
-
-    if isinstance(target, gen_base.SWIGLibrary):
-      for obj in self.graph.get_sources(gen_base.DT_LINK, target):
-        if isinstance(obj, gen_base.SWIGObject):
-          for cobj in self.graph.get_sources(gen_base.DT_OBJECT, obj):
-            if isinstance(cobj, gen_base.SWIGObject):
-              csrc = rootpath + '\\' + string.replace(cobj.fname, '/', '\\')
-              sources.append(_item(path=csrc, reldir=None, swig_language=None,
-                                   swig_output=None))
-
-              for ifile in self.graph.get_sources(gen_base.DT_SWIG_C, cobj):
-                isrc = rootpath + '\\' + string.replace(ifile, '/', '\\')
-                sources.append(_item(path=isrc, reldir=None, 
-                                     swig_language=target.lang,
-                                     swig_output=csrc))
-
-    sources.sort(lambda x, y: cmp(x.path, y.path))
-    
     data = {
       'target' : target,
       'target_type' : config_type,
@@ -144,25 +113,10 @@
     self.move_proj_file(os.path.join('apr-util','uri'), 'gen_uri_delims.vcproj')
     self.move_proj_file(os.path.join('apr-util','xml', 'expat', 'lib'), 'xml.vcproj')
 
-    # Generate a fake depaprutil project
-    self.targets['depsubr'] = gen_base.TargetUtility('depsubr', None,
-                                                     'build/win32',
-                                                     None, None, self.cfg,
-                                                     None)
-    self.targets['depdelta'] = gen_base.TargetUtility('depdelta', None,
-                                                      'build/win32',
-                                                      None, None, self.cfg,
-                                                      None)
+    install_targets = self.get_install_targets()
 
     targets = [ ]
 
-    install_targets = self.targets.values() \
-                      + self.graph.get_all_sources(gen_base.DT_INSTALL)
-    install_targets = gen_base.unique(install_targets)
-
-    # sort these for output stability, to watch out for regressions.
-    install_targets.sort()
-
     guids = { }
 
     # VC.NET uses GUIDs to refer to projects. generate them up front
@@ -201,10 +155,10 @@
 
       deplist = [ ]
       for i in range(len(depends)):
-        deplist.append(_item(guid=guids[depends[i].name],
+        deplist.append(gen_win._item(guid=guids[depends[i].name],
                              index=i,
                              ))
-      targets.append(_item(name=target.name,
+      targets.append(gen_win._item(name=target.name,
                            path=string.replace(fname, os.sep, '\\'),
                            guid=guids[target.name],
                            depends=deplist,
@@ -216,7 +170,7 @@
     for i in range(len(self.configs)):
 
       ### this is different from write_project
-      configs.append(_item(name=self.configs[i], index=i))
+      configs.append(gen_win._item(name=self.configs[i], index=i))
 
     # sort the values for output stability.
     guidvals = guids.values()
@@ -230,7 +184,3 @@
       }
 
     self.write_with_template(oname, 'vcnet_sln.ezt', data)
-
-class _item:
-  def __init__(self, **kw):
-    vars(self).update(kw)
Index: build/generator/gen_win.py
===================================================================
--- build/generator/gen_win.py	(revision 6316)
+++ build/generator/gen_win.py	(working copy)
@@ -221,6 +221,67 @@
           libs.append(gen_base.ExternalLibrary(libname))
     return libs
 
+  def get_install_targets(self):
+    "Generate the list of targets"
+    # Generate a fake depaprutil project
+    self.targets['depsubr'] = gen_base.TargetUtility('depsubr', None,
+                                                     'build/win32',
+                                                     None, None, self.cfg,
+                                                     None)
+    self.targets['depdelta'] = gen_base.TargetUtility('depdelta', None,
+                                                      'build/win32',
+                                                      None, None, self.cfg,
+                                                      None)
+
+    install_targets = self.targets.values() \
+                      + self.graph.get_all_sources(gen_base.DT_INSTALL)
+    install_targets = gen_base.unique(install_targets)
+
+    # sort these for output stability, to watch out for regressions.
+    install_targets.sort()
+    return install_targets
+
+  def get_configs(self, target, rootpath):
+    "Get the list of configurations for the project"
+    configs = [ ]
+    for cfg in self.configs:
+      configs.append(_item(name=cfg,
+                           lower=string.lower(cfg),
+                           defines=self.get_win_defines(target, cfg),
+                           libdirs=self.get_win_lib_dirs(target,rootpath, cfg),
+                           libs=self.get_win_libs(target, cfg),
+                           ))
+    return configs
+  
+  def get_proj_sources(self, quote_path, target, rootpath):
+    "Get the list of source files for each project"
+    sources = [ ]
+    if not isinstance(target, gen_base.TargetUtility):
+      for src, reldir in self.get_win_sources(target):
+        rsrc = string.replace(os.path.join(rootpath, src), os.sep, '\\')
+        if quote_path and '-' in rsrc:
+          rsrc = '"%s"' % rsrc
+        sources.append(_item(path=rsrc, reldir=reldir, swig_language=None,
+                             swig_output=None))
+
+    if isinstance(target, gen_base.SWIGLibrary):
+      for obj in self.graph.get_sources(gen_base.DT_LINK, target):
+        if isinstance(obj, gen_base.SWIGObject):
+          for cobj in self.graph.get_sources(gen_base.DT_OBJECT, obj):
+            if isinstance(cobj, gen_base.SWIGObject):
+              csrc = rootpath + '\\' + string.replace(cobj.fname, '/', '\\')
+              sources.append(_item(path=csrc, reldir=None, swig_language=None,
+                                   swig_output=None))
+
+              for ifile in self.graph.get_sources(gen_base.DT_SWIG_C, cobj):
+                isrc = rootpath + '\\' + string.replace(ifile, '/', '\\')
+                sources.append(_item(path=isrc, reldir=None, 
+                                     swig_language=target.lang,
+                                     swig_output=csrc))
+        
+    sources.sort(lambda x, y: cmp(x.path, y.path))
+    return sources
+  
   def gen_proj_names(self, install_targets):
     "Generate project file names for the targets"
     # Generate project file names for the targets: replace dashes with
@@ -514,3 +575,7 @@
     "Override me when creating a new project type"
 
     raise NotImplementedError
+
+class _item:
+  def __init__(self, **kw):
+    vars(self).update(kw)
Index: build/generator/gen_msvc_dsp.py
===================================================================
--- build/generator/gen_msvc_dsp.py	(revision 6316)
+++ build/generator/gen_msvc_dsp.py	(working copy)
@@ -51,41 +51,10 @@
     else:
       raise gen_base.GenError("Cannot create project for %s" % target.name)
 
-    configs = [ ]
-    for cfg in self.configs:
-      configs.append(_item(name=cfg,
-                           lower=string.lower(cfg),
-                           defines=self.get_win_defines(target, cfg),
-                           libdirs=self.get_win_lib_dirs(target,rootpath, cfg),
-                           libs=self.get_win_libs(target, cfg),
-                           ))
+    configs = self.get_configs(target, rootpath)
 
-    sources = [ ]
-    if not isinstance(target, gen_base.TargetUtility):
-      for src, reldir in self.get_win_sources(target):
-        rsrc = string.replace(os.path.join(rootpath, src), os.sep, '\\')
-        if '-' in rsrc:
-          rsrc = '"%s"' % rsrc
-        sources.append(_item(path=rsrc, reldir=reldir, swig_language=None,
-                             swig_output=None))
+    sources = self.get_proj_sources(True, target, rootpath)
 
-    if isinstance(target, gen_base.SWIGLibrary):
-      for obj in self.graph.get_sources(gen_base.DT_LINK, target):
-        if isinstance(obj, gen_base.SWIGObject):
-          for cobj in self.graph.get_sources(gen_base.DT_OBJECT, obj):
-            if isinstance(cobj, gen_base.SWIGObject):
-              csrc = rootpath + '\\' + string.replace(cobj.fname, '/', '\\')
-              sources.append(_item(path=csrc, reldir=None, swig_language=None,
-                                   swig_output=None))
-
-              for ifile in self.graph.get_sources(gen_base.DT_SWIG_C, cobj):
-                isrc = rootpath + '\\' + string.replace(ifile, '/', '\\')
-                sources.append(_item(path=isrc, reldir=None, 
-                                     swig_language=target.lang,
-                                     swig_output=csrc))
-        
-    sources.sort(lambda x, y: cmp(x.path, y.path))
-
     data = {
       'target' : target,
       'target_type' : targtype,
@@ -113,23 +82,8 @@
   def write(self, oname):
     "Write a Workspace (.dsw)"
 
-    # Generate a fake depaprutil project
-    self.targets['depsubr'] = gen_base.TargetUtility('depsubr', None,
-                                                     'build/win32',
-                                                     None, None, self.cfg,
-                                                     None)
-    self.targets['depdelta'] = gen_base.TargetUtility('depdelta', None,
-                                                      'build/win32',
-                                                      None, None, self.cfg,
-                                                      None)
-
-    install_targets = self.targets.values() \
-                      + self.graph.get_all_sources(gen_base.DT_INSTALL)
-    install_targets = gen_base.unique(install_targets)
-
-    # sort these for output stability, to watch out for regressions.
-    install_targets.sort()
-
+    install_targets = self.get_install_targets()
+    
     targets = [ ]
 
     self.gen_proj_names(install_targets)
@@ -164,7 +118,7 @@
       for dep in depends:
         dep_names.append(dep.proj_name)
 
-      targets.append(_item(name=target.proj_name,
+      targets.append(gen_win._item(name=target.proj_name,
                            dsp=string.replace(fname, os.sep, '\\'),
                            depends=dep_names))
 
@@ -174,8 +128,3 @@
       }
 
     self.write_with_template(oname, 'msvc_dsw.ezt', data)
-
-
-class _item:
-  def __init__(self, **kw):
-    vars(self).update(kw)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jun 21 17:05:50 2003