Handle finding implicit dependents defined with doubled path
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 9 Feb 2009 21:09:43 +0000 (21:09 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 9 Feb 2009 21:09:43 +0000 (21:09 +0000)
separators, as can happen on Windows systems when the backslashes
in the path name are escaped (e.g. "C:\\some\\include.h").

git-svn-id: http://scons.tigris.org/svn/scons/trunk@3988 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Node/FS.py
test/CPPPATH/absolute-path.py

index 57eb348f52663a1e2f5c6396fd3a27e9bc3b57d7..519821903e86a0d0f434cda4df445043c01f0282 100644 (file)
@@ -22,6 +22,9 @@ RELEASE X.X.X - XXX
 
     - Fix interaction of $CHANGED_SOURCES with the --config=force option.
 
+    - Fix finding #include files when the string contains escaped
+      backslashes like "C:\\some\\include.h".
+
   From Robert P. J. Day:
 
     - User's Guide updates.
index 76852aa428616b72741c41f68e9ae18c634c536f..5a2e1aa7808b65f3ab9b23c1ebc25b2fdb852e10 100644 (file)
@@ -3005,8 +3005,9 @@ class FileFinder:
             fd = self.default_filedir
         dir, name = os.path.split(fd)
         drive, d = os.path.splitdrive(dir)
-        if d in ('/', os.sep):
-            return p.fs.get_root(drive).dir_on_disk(name)
+        if not name and d[:1] in ('/', os.sep):
+            #return p.fs.get_root(drive).dir_on_disk(name)
+            return p.fs.get_root(drive)
         if dir:
             p = self.filedir_lookup(p, dir)
             if not p:
index 5c60de19c7670b76650c3c81a4e83dde6c4f176b..1912f4f6f654354e5ed80ef814b8473d0ebe7db8 100644 (file)
@@ -29,22 +29,32 @@ Verify the ability to #include a file with an absolute path name.  (Which
 is not strictly a test of using $CPPPATH, but it's in the ball park...)
 """
 
+import os
+import string
+
 import TestSCons
 
 test = TestSCons.TestSCons()
 
 test.subdir('include', 'work')
 
-inc_h = test.workpath('include', 'inc.h')
+inc1_h = test.workpath('include', 'inc1.h')
+inc2_h = test.workpath('include', 'inc2.h')
 does_not_exist_h = test.workpath('include', 'does_not_exist.h')
 
+# Verify that including an absolute path still works even if they
+# double the separators in the input file.  This can happen especially
+# on Windows if they use \\ to represent an escaped backslash.
+inc2_h = string.replace(inc2_h, os.sep, os.sep+os.sep)
+
 test.write(['work', 'SConstruct'], """\
 Program('prog.c')
 """)
 
 test.write(['work', 'prog.c'], """\
 #include <stdio.h>
-#include "%(inc_h)s"
+#include "%(inc1_h)s"
+#include "%(inc2_h)s"
 #if     0
 #include "%(does_not_exist_h)s"
 #endif
@@ -53,29 +63,34 @@ int
 main(int argc, char *argv[])
 {
     argv[argc++] = "--";
-    printf("%%s\\n", STRING);
+    printf("%%s\\n", STRING1);
+    printf("%%s\\n", STRING2);
     return 0;
 }
 """ % locals())
 
-test.write(['include', 'inc.h'], """\
-#define STRING  "include/inc.h 1\\n"
+test.write(['include', 'inc1.h'], """\
+#define STRING1  "include/inc1.h A\\n"
+""")
+
+test.write(['include', 'inc2.h'], """\
+#define STRING2  "include/inc2.h A\\n"
 """)
 
 test.run(chdir = 'work', arguments = '.')
 
 test.up_to_date(chdir = 'work', arguments = '.')
 
-test.write(['include', 'inc.h'], """\
-#define STRING  "include/inc.h 2\\n"
+test.write(['include', 'inc1.h'], """\
+#define STRING1  "include/inc1.h B\\n"
 """)
 
 test.not_up_to_date(chdir = 'work', arguments = '.')
 
-test.pass_test()
+test.write(['include', 'inc2.h'], """\
+#define STRING2  "include/inc2.h B\\n"
+""")
+
+test.not_up_to_date(chdir = 'work', arguments = '.')
 
-# Local Variables:
-# tab-width:4
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=4 shiftwidth=4:
+test.pass_test()