diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-06-20 21:54:45 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-06-20 21:54:45 +0800 |
commit | b352b6acb1f13484550ab6db48464f41bf72e0f1 (patch) | |
tree | 9a24a7f65eb8c45dd6c6da0d5cd7c057fc9cfff0 | |
parent | 32a1d8b85b47ef68803fb7cdadf9974492373611 (diff) | |
download | mrust-b352b6acb1f13484550ab6db48464f41bf72e0f1.tar.gz |
minicargo - Improved test support
-rw-r--r-- | tools/minicargo/build.cpp | 23 | ||||
-rw-r--r-- | tools/minicargo/manifest.cpp | 12 |
2 files changed, 29 insertions, 6 deletions
diff --git a/tools/minicargo/build.cpp b/tools/minicargo/build.cpp index 10c7f754..3b0b9c3e 100644 --- a/tools/minicargo/build.cpp +++ b/tools/minicargo/build.cpp @@ -708,7 +708,7 @@ namespace { } ::std::string get_token() { auto t = get_token_int(); - DEBUG("get_token '" << t << "'"); + //DEBUG("get_token '" << t << "'"); return t; } ::std::string get_token_int() { @@ -885,6 +885,11 @@ bool Builder::build_target(const PackageManifest& manifest, const PackageTarget& args.push_back("-C"); args.push_back("codegen-type=monomir"); } + for(const auto& d : m_opts.lib_search_dirs) + { + args.push_back("-L"); + args.push_back(d.str().c_str()); + } args.push_back("-L"); args.push_back(this->get_output_dir(is_for_host).str()); for(const auto& dir : manifest.build_script_output().rustc_link_search) { args.push_back("-L"); args.push_back(dir.second.c_str()); @@ -910,7 +915,7 @@ bool Builder::build_target(const PackageManifest& manifest, const PackageTarget& args.push_back("--extern"); args.push_back(::format(m.get_library().m_name, "=", path)); } - if( target.m_type == PackageTarget::Type::Test /*|| building_unit_tests */) + if( target.m_type == PackageTarget::Type::Test ) { args.push_back("--test"); } @@ -924,10 +929,18 @@ bool Builder::build_target(const PackageManifest& manifest, const PackageTarget& args.push_back(::format(m.get_library().m_name, "=", path)); } } - for(const auto& d : m_opts.lib_search_dirs) + if( target.m_type == PackageTarget::Type::Test ) { - args.push_back("-L"); - args.push_back(d.str().c_str()); + for(const auto& dep : manifest.dev_dependencies()) + { + if( ! dep.is_disabled() ) + { + const auto& m = dep.get_package(); + auto path = this->get_crate_path(m, m.get_library(), is_for_host, nullptr, nullptr); + args.push_back("--extern"); + args.push_back(::format(m.get_library().m_name, "=", path)); + } + } } // TODO: Environment variables (rustc_env) diff --git a/tools/minicargo/manifest.cpp b/tools/minicargo/manifest.cpp index 28839d8b..2f6d1ca5 100644 --- a/tools/minicargo/manifest.cpp +++ b/tools/minicargo/manifest.cpp @@ -130,6 +130,16 @@ PackageManifest PackageManifest::load_from_toml(const ::std::string& path) } rv.m_links = key_val.value.as_string(); } + else if( key == "autotests" ) + { + // TODO: Fix the outer makefile so it doesn't need `foo-test` + // to be created. + //rv.m_create_auto_test = key_val.value.as_bool(); + } + else if( key == "autobenches" ) + { + //rv.m_create_auto_bench = key_val.value.as_bool(); + } else { // Unknown value in `package` @@ -380,7 +390,7 @@ PackageManifest PackageManifest::load_from_toml(const ::std::string& path) // Explicitly disabled `[package] build = false` rv.m_build_script = ""; } - else if( rv.m_build_script != "" ) + else if( rv.m_build_script == "" ) { // Not set, check for a "build.rs" file if( ::std::ifstream( package_dir / "build.rs").good() ) |