From cd993966c0729074329df1a59ad46c82c68c0928 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 2 Oct 2014 01:27:02 +0300 Subject: [PATCH] Pass a tool hint to VirtualFileSystem::find_header This makes C++ includes findable again, since they have no suffix and thus match no tool. --- source/binarypackage.cpp | 2 +- source/csourcefile.cpp | 6 +++++- source/virtualfilesystem.cpp | 6 +++--- source/virtualfilesystem.h | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/binarypackage.cpp b/source/binarypackage.cpp index 4c53821..94667c9 100644 --- a/source/binarypackage.cpp +++ b/source/binarypackage.cpp @@ -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) { diff --git a/source/csourcefile.cpp b/source/csourcefile.cpp index d4f6d79..0034ebd 100644 --- a/source/csourcefile.cpp +++ b/source/csourcefile.cpp @@ -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); } diff --git a/source/virtualfilesystem.cpp b/source/virtualfilesystem.cpp index 5c54898..0e95950 100644 --- a/source/virtualfilesystem.cpp +++ b/source/virtualfilesystem.cpp @@ -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; diff --git a/source/virtualfilesystem.h b/source/virtualfilesystem.h index 6a92125..90151fe 100644 --- a/source/virtualfilesystem.h +++ b/source/virtualfilesystem.h @@ -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 -- 2.43.0