summaryrefslogtreecommitdiff
path: root/tools/minicargo/manifest.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2019-02-23 12:33:35 +0800
committerJohn Hodge <tpg@mutabah.net>2019-02-23 12:33:35 +0800
commit0158e0e303cf2b9ba38a8e482df9bacb4fd4c779 (patch)
treec7cf3d8d0c7492b425bf94fd9b4d8eefecea9794 /tools/minicargo/manifest.cpp
parent80c2add7b04e6e202d9a4f3b3c25ec498e3b5893 (diff)
parent7d728e447d70d79e93c01a7c51efbd61be09d68f (diff)
downloadmrust-0158e0e303cf2b9ba38a8e482df9bacb4fd4c779.tar.gz
Merge branch 'master' of ssh://github.com/thepowersgang/mrustc
Diffstat (limited to 'tools/minicargo/manifest.cpp')
-rw-r--r--tools/minicargo/manifest.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/minicargo/manifest.cpp b/tools/minicargo/manifest.cpp
index bbaa24f6..e47da1bc 100644
--- a/tools/minicargo/manifest.cpp
+++ b/tools/minicargo/manifest.cpp
@@ -484,6 +484,20 @@ PackageManifest PackageManifest::load_from_toml(const ::std::string& path)
rv.m_targets.push_back(PackageTarget { PackageTarget::Type::Lib });
}
}
+ // - If there's no binary section, but src/main.rs exists, add as a binary
+ if( ! ::std::any_of(rv.m_targets.begin(), rv.m_targets.end(), [](const auto& x){ return x.m_type == PackageTarget::Type::Bin; }) )
+ {
+ // No library, add one pointing to lib.rs
+ if( ::std::ifstream(package_dir / "src" / "main.rs").good() )
+ {
+ DEBUG("- Implicit binary");
+ rv.m_targets.push_back(PackageTarget { PackageTarget::Type::Bin });
+ }
+ }
+ if( rv.m_targets.empty() )
+ {
+ throw ::std::runtime_error(format("Manifest file ", path, " didn't specify any targets (and src/{main,lib}.rs doesn't exist)"));
+ }
// Default target names
for(auto& tgt : rv.m_targets)