diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-18 16:18:31 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-18 16:18:31 +0800 |
commit | a786768f2ff4afa2a493d69cda21bde83e88063d (patch) | |
tree | 84d92bf73034899d3653c71307e3611f817c69ca | |
parent | 48e99abaf3e22bb95d322f527f4cf154e9ccef66 (diff) | |
download | mrust-a786768f2ff4afa2a493d69cda21bde83e88063d.tar.gz |
AST - Search output/ and output/test_deps for extern crates
-rw-r--r-- | src/ast/crate.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp index 5b15a15d..f99389d0 100644 --- a/src/ast/crate.cpp +++ b/src/ast/crate.cpp @@ -99,10 +99,20 @@ void Crate::load_extern_crate(Span sp, const ::std::string& name) { DEBUG("Loading crate '" << name << "'"); // TODO: Search a list of load paths for the crate - ::std::string path = "output/lib"+name+".hir"; + + ::std::vector< ::std::string> paths { "output/", "output/test_deps/" }; + ::std::string path; + for(const auto& p : paths){ + path = p + "lib" + name + ".hir"; + + if( ::std::ifstream(path).good() ) { + break ; + } + } if( !::std::ifstream(path).good() ) { ERROR(sp, E0000, "Unable to locate crate '" << name << "'"); } + auto res = m_extern_crates.insert(::std::make_pair( name, ExternCrate { name, path } )); auto crate_ext_list = mv$( res.first->second.m_hir->m_ext_crates ); |