Commits

Gary Oberbrunner committed beedc03

New debug option --debug=duplicate to debug Variant-dir duplication

Comments (0)

Files changed (8)

 files).
 
 .TP
+--debug=duplicate
+Print a line for each unlink/relink (or copy) of a variant file from
+its source file.  Includes debugging info for unlinking stale variant
+files, as well as unlinking old targets before building them.
+
+.TP
 --debug=dtree
 A synonym for the newer
 .B --tree=derived

doc/user/troubleshoot.in

 
   </section>
 
+  <section>
+
+  <title>Why is a file disappearing?  the --debug=duplicate Option</title>
+
+    <para>
+
+    When using the &Duplicate; option to create variant dirs,
+    sometimes you may find files not getting copied to where you
+    expect (or not at all), or files mysteriously disappearing.  These
+    are usually because of a misconfiguration of some kind in the
+    SConstruct/SConscript, but they can be tricky to debug.  The
+    --debug=duplicate option shows each time a variant file is
+    unlinked and relinked from its source (or copied, depending on
+    settings), and also shows a message for removing "stale"
+    variant-dir files that no longer have a corresponding source file.
+    It also prints a line for each target that's removed just before
+    building, since that can also be mistaken for the same thing.
+
+    </para>
+
+  </section>
+
   <!--
 
+
   <section>
 
   <title>Where Are My Build Bottlenecks?  the &profile; Option</title>

doc/user/troubleshoot.xml

 
   </section>
 
+  <section>
+
+  <title>Why is a file disappearing?  the --debug=duplicate Option</title>
+
+    <para>
+
+    When using the &Duplicate; option to create variant dirs,
+    sometimes you may find files not getting copied to where you
+    expect (or not at all), or files mysteriously disappearing.  These
+    are usually because of a misconfiguration of some kind in the
+    SConstruct/SConscript, but they can be tricky to debug.  The
+    --debug=duplicate option shows each time a variant file is
+    unlinked and relinked from its source (or copied, depending on
+    settings), and also shows a message for removing "stale"
+    variant-dir files that no longer have a corresponding source file.
+    It also prints a line for each target that's removed just before
+    building, since that can also be mistaken for the same thing.
+
+    </para>
+
+  </section>
+
   <!--
 
   <section>
     - New --debug=prepare option to show each target as it's being
       prepared, whether or not anything needs to be done for it.
 
+  From Gary Oberbrunner:
+    - New debug option --debug=duplicate to print a line for each
+      unlink/relink (or copy) of a variant file from its source file.
+    
   From David Garcia Garzon:
     - Fix Delete to be able to delete broken symlinks and dir
       symlinks.
 
   IMPROVEMENTS
 
+    - New debugging options to print unlink/relinking of variant files
+      (--debug=duplicate) and preparation of targets (--debug=prepare).
     - SCons can now generate MSVS 9.0 and 10.0 Projects and Solutions.
     - MSVS Solution generation is improved.
     - Fortran 03 is supported (preliminary)

src/engine/SCons/Node/FS.py

 from SCons.Debug import Trace
 
 do_store_info = True
+print_duplicate = 0
 
 
 class EntryProxyAttributeError(AttributeError):
 
     def _rmv_existing(self):
         self.clear_memoized_values()
+        if print_duplicate:
+            print "dup: removing existing target %s"%self
         e = Unlink(self, [], None)
         if isinstance(e, SCons.Errors.BuildError):
             raise e
 
     def do_duplicate(self, src):
         self._createDir()
+        if print_duplicate:
+            print "dup: relinking variant '%s' from '%s'"%(self, src)
         Unlink(self, None, None)
         e = Link(self, src, None)
         if isinstance(e, SCons.Errors.BuildError):
                     else:
                         # The source file does not exist.  Make sure no old
                         # copy remains in the variant directory.
+                        if print_duplicate:
+                            print "dup: no src for %s, unlinking old variant copy"%self
                         if Base.exists(self) or self.islink():
                             self.fs.unlink(self.path)
                         # Return None explicitly because the Base.exists() call

src/engine/SCons/Script/Main.py

         options.tree_printers.append(TreePrinter())
     if "prepare" in debug_values:
         SCons.Taskmaster.print_prepare = 1
+    if "duplicate" in debug_values:
+        SCons.Node.FS.print_duplicate = 1
 
 def _create_path(plist):
     path = '.'

src/engine/SCons/Script/SConsOptions.py

         "tree"          : '; please use --tree=all instead',
     }
 
-    debug_options = ["count", "explain", "findlibs",
+    debug_options = ["count", "duplicate", "explain", "findlibs",
                      "includes", "memoizer", "memory", "objects",
                      "pdb", "prepare", "presub", "stacktrace",
                      "time"] + list(deprecated_debug_options.keys())
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.