]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
OK, this was one of the weirder bugs I've found recently: when we do
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 8 Dec 2010 02:55:59 +0000 (02:55 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 8 Dec 2010 02:55:59 +0000 (02:55 +0000)
  #include <vector>
we expect that either (i) make_dependencies ignores this dependence
because it can't find the file <vector> anywhere, e.g. because it
doesn't know the path to system header files, or (ii) enter the proper
dependency to the file if it does know where to find the file.

But what happened in the tests/serialization directory is that it
found a *subdirectory* named 'vector' and added it to the list of
dependencies. And 'make' then tries to re-build this directory by
compiling (using an implicit rule built into 'make') the executable
'vector' from 'vector.cc', which fails because the implicit rule of
course doesn't know anything about where deal.II include files reside,
etc. Completely strange.

So the solution is to ignore directories, if we happen to find
them. In the process, I also replaced the use of std::istream to
test-open a file (which weirdly succeeds for directories, although you
can't read from it) by uses of stat(), which should be faster as well.

git-svn-id: https://svn.dealii.org/trunk@22940 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/common/scripts/make_dependencies.cc

index 5262961d7d60103ec32775162fa31a883f9bca53..07f9515f13dc142c6cd71e14af5d00f594de92c5 100644 (file)
@@ -46,6 +46,7 @@
 #include <vector>
 #include <cassert>
 #include <cstdlib>
+#include <sys/stat.h>
 
                                  // base path for object files,
                                  // including trailing slash if
@@ -177,18 +178,33 @@ void determine_direct_includes (const std::string &file)
             for (std::vector<std::string>::const_iterator
                    include_dir=include_directories.begin();
                  include_dir!=include_directories.end(); ++include_dir)
-              if (std::ifstream((*include_dir+included_file).c_str()))
-                {
-                  included_file = *include_dir+included_file;
-                  break;
-                }
+             {
+               struct stat buf;
+               int error = stat ((*include_dir+included_file).c_str(), &buf);
+
+               if ((error == 0) &&
+                   S_ISREG(buf.st_mode))
+                 {
+                   included_file = *include_dir+included_file;
+                   break;
+                 }
+             }
         }
 
-                                       // make sure the file
-                                       // exists, otherwise just
-                                       // ignore the line
-      if (!std::ifstream(included_file.c_str()))
-        continue;
+                                       // make sure the file exists
+                                       // and that we can read from
+                                       // it, otherwise just ignore
+                                       // the line
+      {
+       struct stat buf;
+       int error = stat (included_file.c_str(), &buf);
+
+       if ((error != 0) ||
+           !S_ISREG(buf.st_mode))
+         continue;
+      }
+
+
 
                                        // ok, so we did find an
                                        // appropriate file. add it to

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.