- 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", 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('P', "progress", show_progress, GetOpt::NO_ARG);
- getopt.add_option('W', "what-if", what_if, GetOpt::REQUIRED_ARG);
- getopt.add_option( "conf-only", conf_only, GetOpt::NO_ARG);
- getopt.add_option( "full-paths", full_paths, GetOpt::NO_ARG);
- //getopt.add_option( "makefile", create_makefile, 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 if(!clean && !create_makefile)
- build=true;
-
- const vector<string> &args=getopt.get_args();
- for(vector<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=getcwd();
-
- Architecture &native_arch=archs.insert(ArchMap::value_type("native", Architecture(*this, "native"))).first->second;
- native_arch.set_tool("CC", "gcc");
- native_arch.set_tool("CXX", "g++");
- native_arch.set_tool("LD", "gcc");
- native_arch.set_tool("LXX", "g++");
- native_arch.set_tool("AR", "ar");
-
- const char *home=getenv("HOME");
- if(home)
- load_build_file((Path(home)/".builderrc").str());