diff options
author | John Hodge <tpg@mutabah.net> | 2017-08-20 20:56:00 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2017-08-20 20:56:00 +0800 |
commit | aa44379d158085d649d9ab3514e0c2276d2d5076 (patch) | |
tree | ad739df0e5fa9f2b4f91a73c8bc812ce7e5c7bec /src/ast/crate.cpp | |
parent | 19f32ced09e7538cde01cb443b19e0a7a1c5667f (diff) | |
download | mrust-aa44379d158085d649d9ab3514e0c2276d2d5076.tar.gz |
Load Crates - Search passed library directories for crates
Diffstat (limited to 'src/ast/crate.cpp')
-rw-r--r-- | src/ast/crate.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp index 394cd47b..f003a00b 100644 --- a/src/ast/crate.cpp +++ b/src/ast/crate.cpp @@ -8,6 +8,9 @@ #include <hir/main_bindings.hpp> // HIR_Deserialise #include <fstream> +::std::vector<::std::string> AST::g_crate_load_dirs = { }; +::std::map<::std::string, ::std::string> AST::g_crate_overrides; + namespace { bool check_item_cfg(const ::AST::MetaItems& attrs) { @@ -99,15 +102,23 @@ void Crate::load_externs() 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::vector< ::std::string> paths { "output/", "output/test_deps/" }; ::std::string path; - for(const auto& p : paths){ - path = p + "lib" + name + ".hir"; + auto it = g_crate_overrides.find(name); + if(it != g_crate_overrides.end()) + { + path = it->second; + } + else + { + // Search a list of load paths for the crate + for(const auto& p : g_crate_load_dirs) + { + path = p + "/lib" + name + ".hir"; - if( ::std::ifstream(path).good() ) { - break ; + if( ::std::ifstream(path).good() ) { + break ; + } } } if( !::std::ifstream(path).good() ) { |