- string analyze_mode;
- string work_dir;
- bool full_paths=false;
- unsigned max_depth=5;
-
- GetOpt getopt;
- getopt.add_option('a', "analyze", analyze_mode, GetOpt::REQUIRED_ARG);
- getopt.add_option('b', "build", do_build, GetOpt::NO_ARG);
-// getopt.add_option('c', "clean", clean, GetOpt::NO_ARG);
- getopt.add_option('f', "file", build_file, GetOpt::REQUIRED_ARG);
- getopt.add_option('h', "help", help, GetOpt::NO_ARG);
- getopt.add_option('j', "jobs", jobs, GetOpt::REQUIRED_ARG);
- getopt.add_option('n', "dry-run", dry_run, GetOpt::NO_ARG);
- getopt.add_option('v', "verbose", verbose, GetOpt::NO_ARG);
- getopt.add_option('A', "conf-all", conf_all, GetOpt::NO_ARG);
- getopt.add_option('B', "build-all", build_all, GetOpt::NO_ARG);
- getopt.add_option('C', "chdir", work_dir, GetOpt::REQUIRED_ARG);
- getopt.add_option('W', "what-if", what_if, GetOpt::REQUIRED_ARG);
- getopt.add_option( "chrome", chrome, GetOpt::NO_ARG);
- getopt.add_option( "conf-only", conf_only, GetOpt::NO_ARG);
- getopt.add_option( "full-paths", full_paths, GetOpt::NO_ARG);
- getopt.add_option( "max-depth", max_depth, GetOpt::REQUIRED_ARG);
- getopt(argc, argv);
-
- if(!analyze_mode.empty())
- {
- analyzer=new Analyzer(*this);
-
- if(analyze_mode=="deps")
- analyzer->set_mode(Analyzer::DEPS);
- else if(analyze_mode=="alldeps")
- analyzer->set_mode(Analyzer::ALLDEPS);
- else if(analyze_mode=="rebuild")
- analyzer->set_mode(Analyzer::REBUILD);
- else if(analyze_mode=="rdeps")
- analyzer->set_mode(Analyzer::RDEPS);
- else
- throw UsageError("Invalid analyze mode");
-
- analyzer->set_max_depth(max_depth);
- analyzer->set_full_paths(full_paths);
- }
- else
- do_build=true;
-
- const list<string> &args=getopt.get_args();
- for(list<string>::const_iterator i=args.begin(); i!=args.end(); ++i)
- {
- unsigned equal=i->find('=');
- if(equal!=string::npos)
- cmdline_options.insert(StringMap::value_type(i->substr(0, equal), i->substr(equal+1)));
- else
- cmdline_targets.push_back(*i);
- }
-
- if(cmdline_targets.empty())
- cmdline_targets.push_back("default");
-
- if(!work_dir.empty())
- chdir(work_dir.c_str());
-
- cwd=Path::getcwd();
-
- archs.insert(StringMap::value_type("native", ""));
- archs.insert(StringMap::value_type("arm", "arm-linux-gnu-"));
- archs.insert(StringMap::value_type("win32", "i586-mingw32msvc-"));
-
- StringMap &native_tools=tools.insert(ToolMap::value_type("native", StringMap())).first->second;
- native_tools.insert(StringMap::value_type("CC", "gcc"));
- native_tools.insert(StringMap::value_type("CXX", "g++"));
- native_tools.insert(StringMap::value_type("LD", "gcc"));
- native_tools.insert(StringMap::value_type("LDXX", "g++"));
- native_tools.insert(StringMap::value_type("AR", "ar"));
-
- StringMap &release_profile=profile_tmpl.insert(ProfileTemplateMap::value_type("release", StringMap())).first->second;
- release_profile.insert(StringMap::value_type("optimize", "3"));
- release_profile.insert(StringMap::value_type("outdir", "$profile"));
-
- StringMap &debug_profile=profile_tmpl.insert(ProfileTemplateMap::value_type("debug", StringMap())).first->second;
- debug_profile.insert(StringMap::value_type("debug", "1"));
- debug_profile.insert(StringMap::value_type("outdir", "$profile"));
-
- for(StringMap::iterator i=archs.begin(); i!=archs.end(); ++i)
- {
- if(i->first=="native")
- continue;
-
- StringMap &arch_profile=profile_tmpl.insert(ProfileTemplateMap::value_type(i->first, StringMap())).first->second;
- arch_profile.insert(StringMap::value_type("arch", i->first));
- arch_profile.insert(StringMap::value_type("prefix", "$HOME/local/$arch"));
- }