diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-09-03 21:04:11 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-09-03 21:04:11 +0800 |
commit | 93bbe31c8b58cdf1c5a9325bb9308729149d88d6 (patch) | |
tree | f9fd2618f1c1e8c58423f02e9ca919d655140b2e /tools/minicargo/manifest.cpp | |
parent | bfa90e9edff156bf3227a5ffcc1948a0724831cb (diff) | |
download | mrust-93bbe31c8b58cdf1c5a9325bb9308729149d88d6.tar.gz |
minicargo - If path isn't valid, load from repo
Diffstat (limited to 'tools/minicargo/manifest.cpp')
-rw-r--r-- | tools/minicargo/manifest.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/tools/minicargo/manifest.cpp b/tools/minicargo/manifest.cpp index 5f7ecdf0..721a231a 100644 --- a/tools/minicargo/manifest.cpp +++ b/tools/minicargo/manifest.cpp @@ -586,17 +586,29 @@ void PackageManifest::load_build_script(const ::std::string& path) void PackageRef::load_manifest(Repository& repo, const ::helpers::path& base_path, bool include_build_deps) { TRACE_FUNCTION_F(this->m_name); - // If the path isn't set, check for: - // - Git (checkout and use) - // - Version and repository (check vendored, check cache, download into cache) - if( ! this->has_path() ) + if( !m_manifest ) { - if( this->has_git() ) + // If the path isn't set, check for: + // - Git (checkout and use) + // - Version and repository (check vendored, check cache, download into cache) + if( this->has_path() ) + { + DEBUG("Load dependency " << m_name << " from path " << m_path); + // Search for a copy of this already loaded + auto path = base_path / ::helpers::path(m_path) / "Cargo.toml"; + if( ::std::ifstream(path.str()).good() ) + { + m_manifest = repo.from_path(path); + } + } + + if( !m_manifest && this->has_git() ) { DEBUG("Load dependency " << this->name() << " from git"); throw "TODO: Git"; } - else + + if( !m_manifest ) { DEBUG("Load dependency " << this->name() << " from repo"); m_manifest = repo.find(this->name(), this->get_version()); @@ -604,13 +616,11 @@ void PackageRef::load_manifest(Repository& repo, const ::helpers::path& base_pat throw ::std::runtime_error(::format("Unable to load manifest for ", this->name(), ":", this->get_version())); } } - } - else - { - DEBUG("Load dependency " << m_name << " from path " << m_path); - // Search for a copy of this already loaded - m_manifest = repo.from_path(base_path / ::helpers::path(m_path) / "Cargo.toml"); - assert(m_manifest); + + if( !m_manifest ) + { + throw ::std::runtime_error(::format( "Unable to find a manifest for ", this->name() )); + } } m_manifest->set_features(this->m_features, this->m_use_default_features); |