]> git.tdb.fi Git - builder.git/commitdiff
Pass a tool hint to VirtualFileSystem::find_header
authorMikko Rasa <tdb@tdb.fi>
Wed, 1 Oct 2014 22:27:02 +0000 (01:27 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 1 Oct 2014 22:27:02 +0000 (01:27 +0300)
This makes C++ includes findable again, since they have no suffix and
thus match no tool.

source/binarypackage.cpp
source/csourcefile.cpp
source/virtualfilesystem.cpp
source/virtualfilesystem.h

index 4c5382191661b7c627c0ef0e94db63fa34ab8ec9..94667c989dede480f3b36afbddb04108f84881cb 100644 (file)
@@ -60,7 +60,7 @@ void BinaryPackage::do_prepare()
                        *j = prefix/ *j;
 
                for(HeaderList::const_iterator j=headers.begin(); j!=headers.end(); ++j)
-                       all_found &= (builder.get_vfs().find_header(*j, incpath, system)!=0);
+                       all_found &= (builder.get_vfs().find_header(*j, 0, incpath, system)!=0);
 
                if(all_found)
                {
index d4f6d79df9e0a0e2116d4d3ed6548d00c58b6337..0034ebd0e564870c6ed101835f52cd130ef42506 100644 (file)
@@ -6,6 +6,7 @@
 #include "component.h"
 #include "csourcefile.h"
 #include "sourcepackage.h"
+#include "tool.h"
 
 using namespace std;
 using namespace Msp;
@@ -58,9 +59,12 @@ void CSourceFile::find_dependencies()
        local_incpath.insert(local_incpath.begin(), build_info.local_incpath.begin(), build_info.local_incpath.end());
        local_incpath.push_front(FS::dirname(path).str());
 
+       Tool *compiler = builder.get_toolchain().get_tool_for_suffix(FS::extpart(FS::basename(path)), true);
+       if(compiler)
+               compiler->prepare();
        for(IncludeList::iterator i=includes.begin(); i!=includes.end(); ++i)
        {
-               Target *hdr = builder.get_vfs().find_header(i->substr(1), ((*i)[0]=='"' ? local_incpath : incpath));
+               Target *hdr = builder.get_vfs().find_header(i->substr(1), compiler, ((*i)[0]=='"' ? local_incpath : incpath));
                if(hdr)
                        add_transitive_dependency(*hdr);
        }
index 5c548980073b9b46ac39da6982e4e5c2c8abfb66..0e9595085b08d1523fe89d7a714a2809f84f138c 100644 (file)
@@ -35,10 +35,10 @@ void VirtualFileSystem::register_path(const FS::Path &path, FileTarget *t)
        builder.get_logger().log("vfs", format("Path %s registered to %s", path, t->get_name()));
 }
 
-FileTarget *VirtualFileSystem::find_header(const string &name, const SearchPath &path, bool use_syspath)
+FileTarget *VirtualFileSystem::find_header(const string &name, const Tool *tool, const SearchPath &path, bool use_syspath)
 {
-       // XXX This will cause trouble with multiple architectures in a single build
-       const Tool *tool = builder.get_toolchain().get_tool_for_suffix(FS::extpart(FS::basename(name)), true);
+       if(!tool)
+               tool = builder.get_toolchain().get_tool_for_suffix(FS::extpart(FS::basename(name)), true);
        if(!tool)
                return 0;
 
index 6a92125316b9fc7465d49a4efa88661f8daee76d..90151fe86983163cd87edb61ad5624e08707db80 100644 (file)
@@ -42,7 +42,7 @@ public:
        /** Locates a source file.  If a file is found but no target is associated
        with it, a new package-less target is created with the appropriate tool.  If
        use_syspath is true, the system path reported by the tool is also searched. */
-       FileTarget *find_header(const std::string &, const SearchPath &, bool use_syspath = true);
+       FileTarget *find_header(const std::string &, const Tool *, const SearchPath &, bool use_syspath = true);
 
        /** Locates a library.  The library name should be the same as what would be
        used in linking with the library.  If a file is found but no target is