diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-08-19 23:14:31 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-08-19 23:14:31 +0800 |
commit | a205fad703a40c3018c2958cd4b52898dd30b1a8 (patch) | |
tree | 1cf0acf09a4eef146c1193bea85979ee9cff39c5 /tools/minicargo/main.cpp | |
parent | 9d683a9b23fb30a6b08cb85b29135960f88d2721 (diff) | |
parent | 54eda831fff08ef95f8d2e06b1557b75f90f6f93 (diff) | |
download | mrust-a205fad703a40c3018c2958cd4b52898dd30b1a8.tar.gz |
Merge branch 'master' of https://github.com/thepowersgang/mrustc
Diffstat (limited to 'tools/minicargo/main.cpp')
-rw-r--r-- | tools/minicargo/main.cpp | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/tools/minicargo/main.cpp b/tools/minicargo/main.cpp index 89097928..c2fe4c2e 100644 --- a/tools/minicargo/main.cpp +++ b/tools/minicargo/main.cpp @@ -4,6 +4,13 @@ * main.cpp * - Entrypoint */ +#include <iostream> +#include <cstring> // strcmp +#include "debug.h" +#include "manifest.h" +#include "helpers.h" + +extern void MiniCargo_Build(const PackageManifest& manifest); struct ProgramOptions { @@ -16,6 +23,7 @@ struct ProgramOptions const char* output_directory = nullptr; int parse(int argc, const char* argv[]); + void usage() const; }; int main(int argc, const char* argv[]) @@ -26,9 +34,19 @@ int main(int argc, const char* argv[]) } // 1. Load the Cargo.toml file from the passed directory + auto m = PackageManifest::load_from_toml( ::helpers::path(opts.directory ? opts.directory : ".") / "Cargo.toml" ); + // 2. Recursively load dependency manifests - // 3. Generate makefile for all dependencies + for(const auto& dep : m.dependencies()) + { + throw "TODO: Deps"; + } + // 3. Build dependency tree + MiniCargo_Build(m); + + ::std::cout << "Press any key to exit..." << ::std::endl; + ::std::cin.get(); return 0; } @@ -44,17 +62,14 @@ int ProgramOptions::parse(int argc, const char* argv[]) if( !this->directory ) { this->directory = arg; } - else if( !this->outfile ) { - this->outfile = arg; - } else { } } - else if( argv[1] != '-' ) + else if( arg[1] != '-' ) { // Short arguments } - else if( argv[1] == '\0' ) + else if( arg[1] == '\0' ) { all_free = true; } @@ -74,7 +89,7 @@ int ProgramOptions::parse(int argc, const char* argv[]) } } - if( !this->directory || !this->outfile ) + if( !this->directory /*|| !this->outfile*/ ) { usage(); exit(1); @@ -83,3 +98,17 @@ int ProgramOptions::parse(int argc, const char* argv[]) return 0; } +void ProgramOptions::usage() const +{ + ::std::cerr + << "Usage: minicargo <package dir>" << ::std::endl + ; +} + + + +void Debug_Print(::std::function<void(::std::ostream& os)> cb) +{ + cb(::std::cout); + ::std::cout << ::std::endl; +} |