summaryrefslogtreecommitdiff
path: root/tools/minicargo/main.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-08-20 22:16:09 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-08-20 22:16:09 +0800
commit739443094434e2622abd1fea5d2b5a03bc1ba0ef (patch)
treedbc593a8fd14e95c2c73dd441e513aee21d03824 /tools/minicargo/main.cpp
parent10e0d9a2609cc2b4d30c38e7f1f20e11de432fd6 (diff)
parenta99e49b7505d2912d8699d4c791b8b30c194024b (diff)
downloadmrust-739443094434e2622abd1fea5d2b5a03bc1ba0ef.tar.gz
Merge branch 'master' of https://github.com/thepowersgang/mrustc
Diffstat (limited to 'tools/minicargo/main.cpp')
-rw-r--r--tools/minicargo/main.cpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/tools/minicargo/main.cpp b/tools/minicargo/main.cpp
index c2fe4c2e..236b9d77 100644
--- a/tools/minicargo/main.cpp
+++ b/tools/minicargo/main.cpp
@@ -6,9 +6,11 @@
*/
#include <iostream>
#include <cstring> // strcmp
+#include <map>
#include "debug.h"
#include "manifest.h"
#include "helpers.h"
+#include "repository.h"
extern void MiniCargo_Build(const PackageManifest& manifest);
@@ -22,6 +24,8 @@ struct ProgramOptions
const char* output_directory = nullptr;
+ const char* vendor_dir = nullptr;
+
int parse(int argc, const char* argv[]);
void usage() const;
};
@@ -33,19 +37,34 @@ int main(int argc, const char* argv[])
return 1;
}
- // 1. Load the Cargo.toml file from the passed directory
- auto m = PackageManifest::load_from_toml( ::helpers::path(opts.directory ? opts.directory : ".") / "Cargo.toml" );
+ try
+ {
+ // Load package database
+ Repository repo;
+ // TODO: load repository from a local cache
+ if( opts.vendor_dir )
+ {
+ repo.load_vendored(opts.vendor_dir);
+ }
+
+ // 1. Load the Cargo.toml file from the passed directory
+ auto dir = ::helpers::path(opts.directory ? opts.directory : ".");
+ auto m = PackageManifest::load_from_toml( dir / "Cargo.toml" );
+
+ m.load_dependencies(repo);
- // 2. Recursively load dependency manifests
- for(const auto& dep : m.dependencies())
+ // 3. Build dependency tree
+ MiniCargo_Build(m);
+ }
+ catch(const ::std::exception& e)
{
- throw "TODO: Deps";
+ ::std::cerr << "EXCEPTION: " << e.what() << ::std::endl;
+ ::std::cout << "Press enter to exit..." << ::std::endl;
+ ::std::cin.get();
+ return 1;
}
- // 3. Build dependency tree
- MiniCargo_Build(m);
-
- ::std::cout << "Press any key to exit..." << ::std::endl;
+ ::std::cout << "Press enter to exit..." << ::std::endl;
::std::cin.get();
return 0;
}
@@ -106,9 +125,9 @@ void ProgramOptions::usage() const
}
-
void Debug_Print(::std::function<void(::std::ostream& os)> cb)
{
cb(::std::cout);
::std::cout << ::std::endl;
}
+