diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-09-23 11:14:29 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-09-23 11:18:30 +0800 |
commit | 69e7babc3bf5e7cfa86295bfa4cb139b79627a8b (patch) | |
tree | 028a43b2bf772cc294301dcf1a215c655e8bae9a | |
parent | 5d5431f1db9efba7939d5e86e3be7136e3ec39fe (diff) | |
download | mrust-69e7babc3bf5e7cfa86295bfa4cb139b79627a8b.tar.gz |
Minicargo - Support optional build-dependencies
-rw-r--r-- | tools/minicargo/build.cpp | 4 | ||||
-rw-r--r-- | tools/minicargo/main.cpp | 2 | ||||
-rw-r--r-- | tools/minicargo/manifest.cpp | 25 |
3 files changed, 25 insertions, 6 deletions
diff --git a/tools/minicargo/build.cpp b/tools/minicargo/build.cpp index 9e30996f..3849a948 100644 --- a/tools/minicargo/build.cpp +++ b/tools/minicargo/build.cpp @@ -274,6 +274,10 @@ void BuildList::add_dependencies(const PackageManifest& p, unsigned level, bool { for(const auto& dep : p.build_dependencies()) { + if( dep.is_disabled() ) + { + continue ; + } add_package(dep.get_package(), level+1, include_build); } } diff --git a/tools/minicargo/main.cpp b/tools/minicargo/main.cpp index 5062539d..c94f9bc3 100644 --- a/tools/minicargo/main.cpp +++ b/tools/minicargo/main.cpp @@ -137,7 +137,7 @@ int ProgramOptions::parse(int argc, const char* argv[]) return 1; } } - else if( arg[1] == '\0' ) + else if( arg[2] == '\0' ) { all_free = true; } diff --git a/tools/minicargo/manifest.cpp b/tools/minicargo/manifest.cpp index 84c1e257..209a0621 100644 --- a/tools/minicargo/manifest.cpp +++ b/tools/minicargo/manifest.cpp @@ -224,6 +224,9 @@ PackageManifest PackageManifest::load_from_toml(const ::std::string& path) else if( cfg == "cfg(all(unix, not(target_os = \"macos\")))" ) { success = CFG_UNIX; } + else if( cfg == "cfg(not(target_os = \"emscripten\"))" ) { + success = true; + } else if( cfg == "cfg(all(unix, not(target_os = \"emscripten\"), not(target_os = \"macos\"), not(target_os = \"ios\")))" ) { success = CFG_UNIX; } @@ -564,10 +567,21 @@ void PackageManifest::set_features(const ::std::vector<::std::string>& features, } } } - auto it2 = ::std::find_if(m_dependencies.begin(), m_dependencies.end(), [&](const auto& x){ return x.m_name == featname; }); - if(it2 != m_dependencies.end()) + { - it2->m_optional_enabled = true; + auto it2 = ::std::find_if(m_dependencies.begin(), m_dependencies.end(), [&](const auto& x){ return x.m_name == featname; }); + if(it2 != m_dependencies.end()) + { + it2->m_optional_enabled = true; + } + } + + { + auto it2 = ::std::find_if(m_build_dependencies.begin(), m_build_dependencies.end(), [&](const auto& x){ return x.m_name == featname; }); + if(it2 != m_build_dependencies.end()) + { + it2->m_optional_enabled = true; + } } } } @@ -592,8 +606,9 @@ void PackageManifest::load_dependencies(Repository& repo, bool include_build) { for(auto& dep : m_build_dependencies) { - if( dep.m_optional ) { - throw ::std::runtime_error(::format( "build-dependencies can't be optional - ", dep.m_name, " for ", m_name)); + if( dep.m_optional && !dep.m_optional_enabled ) + { + continue ; } dep.load_manifest(repo, base_path, true); } |