diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-11-19 17:29:26 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-11-19 17:29:26 +0800 |
commit | 3db124f5233862042f0c8eee1c6afd4392de0539 (patch) | |
tree | 871be9c256368fbad772900628b6a6cc71eb5190 /tools | |
parent | c3644014de94c711b8233b6ca06351a17a284499 (diff) | |
download | mrust-3db124f5233862042f0c8eee1c6afd4392de0539.tar.gz |
minicargo - Fix handling of binaries
Diffstat (limited to 'tools')
-rw-r--r-- | tools/minicargo/build.cpp | 9 | ||||
-rw-r--r-- | tools/minicargo/manifest.cpp | 18 | ||||
-rw-r--r-- | tools/minicargo/manifest.h | 2 |
3 files changed, 28 insertions, 1 deletions
diff --git a/tools/minicargo/build.cpp b/tools/minicargo/build.cpp index 5204b6b6..48c296aa 100644 --- a/tools/minicargo/build.cpp +++ b/tools/minicargo/build.cpp @@ -446,6 +446,15 @@ bool Builder::build_target(const PackageManifest& manifest, const PackageTarget& for(const auto& feat : manifest.active_features()) { args.push_back("--cfg"); args.push_back(::format("feature=", feat)); } + // If not building the package's library, but the package has a library + if( target.m_type != PackageTarget::Type::Lib && manifest.has_library() ) + { + // Add a --extern for it + const auto& m = manifest; + auto path = this->get_crate_path(m, m.get_library(), nullptr, nullptr); + args.push_back("--extern"); + args.push_back(::format(m.get_library().m_name, "=", path)); + } for(const auto& dep : manifest.dependencies()) { if( ! dep.is_disabled() ) diff --git a/tools/minicargo/manifest.cpp b/tools/minicargo/manifest.cpp index 668100fc..bdb237dd 100644 --- a/tools/minicargo/manifest.cpp +++ b/tools/minicargo/manifest.cpp @@ -334,6 +334,24 @@ PackageManifest PackageManifest::load_from_toml(const ::std::string& path) // Default target names for(auto& tgt : rv.m_targets) { + if(tgt.m_path == "") + { + switch(tgt.m_type) + { + case PackageTarget::Type::Lib: + tgt.m_path = "src/lib.rs"; + break; + case PackageTarget::Type::Bin: + if(tgt.m_name == "") { + tgt.m_path = "src/main.rs"; + } + else { + // TODO: What about src/bin/foo/main.rs? + tgt.m_path = ::helpers::path("src") / "bin" / tgt.m_name.c_str() + ".rs"; + } + break; + } + } if(tgt.m_name == "") { tgt.m_name.reserve(rv.m_name.size()); diff --git a/tools/minicargo/manifest.h b/tools/minicargo/manifest.h index 043bb438..bbe2c34b 100644 --- a/tools/minicargo/manifest.h +++ b/tools/minicargo/manifest.h @@ -197,7 +197,7 @@ struct PackageTarget m_path = "src/lib.rs"; break; case Type::Bin: - m_path = "src/main.rs"; + //m_path = "src/main.rs"; break; default: break; |