From fd34d6446ef8706a7d9011d650fbdce45b95d7c5 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 13 Oct 2016 10:06:24 +0800 Subject: Makefile+main - Fixes to allow partial compilaing of run-pass tests --- src/main.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 3a5d4247..148faf6e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -113,6 +113,8 @@ struct ProgramParams ::std::string outfile; const char *crate_path = "."; + ::AST::Crate::Type crate_type = ::AST::Crate::Type::Unknown; + ::std::set< ::std::string> features; ProgramParams(int argc, char *argv[]); @@ -225,7 +227,10 @@ int main(int argc, char *argv[]) } // Extract the crate type and name from the crate attributes - auto crate_type = crate.m_crate_type; + auto crate_type = params.crate_type; + if( crate_type == ::AST::Crate::Type::Unknown ) { + crate_type = crate.m_crate_type; + } if( crate_type == ::AST::Crate::Type::Unknown ) { // Assume to be executable crate_type = ::AST::Crate::Type::Executable; @@ -422,6 +427,21 @@ ProgramParams::ProgramParams(int argc, char *argv[]) } this->crate_path = argv[++i]; } + else if( strcmp(arg, "--crate-type") == 0 ) { + if( i == argc - 1 ) { + ::std::cerr << "Flag --crate-type requires an argument" << ::std::endl; + exit(1); + } + const char* type_str = argv[++i]; + + if( strcmp(type_str, "rlib") == 0 ) { + this->crate_type = ::AST::Crate::Type::RustLib; + } + else { + ::std::cerr << "Unknown value for --crate-type" << ::std::endl; + exit(1); + } + } else if( strcmp(arg, "--cfg") == 0 ) { if( i == argc - 1 ) { ::std::cerr << "Flag --cfg requires an argument" << ::std::endl; -- cgit v1.2.3