void parse_options() { // Parse command line options, and update the environment to match the // specified options. argp->usage( "Usage: jgdoc [OPTIONS] FILE...\n" "Generates documentation from comments found in Jogo source files.\n\n" " -o, --output DIR Write output to DIR.\n" " -i, --include DIR Add the directory DIR to the search path.\n" " -h, --help Print this help message.\n" " -f, --format FORMAT Set output format to FORMAT.\n" " -v, --verbose Print extra information.\n" " --version Print the compiler version number.\n"); for (ArgToken tok = argp->next(); tok; tok = argp->next()) { // Convert abbreviated flags into the longer descriptive form (e.g., // convert -p to --path) if (ArgToken::SHORT == tok.type()) { parse_short_option(tok.value()); } else if (ArgToken::LONG == tok.type()) { parse_option(tok.value()); } else { env->input(tok.value()); } } std::string gen = env->generator(); if (gen != "Markdown") { argp->error("Invalid output format (options: Markdown"); } }
void load_options() { // Loads options from the options file. FIXME: This settings file loader // is pretty haggard. It should be replaced with JSON. std::ifstream opts(".jgmake"); int c = opts.get(); while (c != '\n' && !opts.fail()) { std::string include; while (c != ',' && c != '\n' && !opts.fail()) { include += c; c = opts.get(); } env->include(include); c = opts.get(); } c = opts.get(); while (c != '\n' && !opts.fail()) { std::string lib; while (c != ',' && c != '\n' && !opts.fail()) { lib += c; c = opts.get(); } env->lib(lib); c = opts.get(); } }
SchemeObject* SchemeObjectCreator::make_environment() { Environment::Ptr env = std::make_shared<Environment>(); setup_environment(env.get()); SchemeObject* obj = new SchemeEnvironment(env); SchemeGarbageCollector::the_gc().add(obj); return obj; }
void save_options() { // Saves options to the options file. std::ofstream opts(".jgmake"); for (int i = 0; i < env->includes(); ++i) { opts << env->include(i) << ","; } opts << std::endl; for (int i = 0; i < env->libs(); ++i) { opts << env->lib(i) << ","; } opts << std::endl; }
void parse_option(std::string const& flag) { if ("output" == flag) { env->output(argp->required_arg()); } else if ("include" == flag) { env->include(argp->required_arg()); } else if ("format" == flag) { env->generator(argp->required_arg()); } else if ("verbose" == flag) { env->verbose(true); } else { argp->bad_option(flag); } }
int main(int argc, char** argv) { // This program recursively finds and builds all files in the source // directory, and then generates the output in the lib/bin directory. env->workspace_load(); env->output("."); env->make(true); env->monolithic_build(false); argp = new ArgParser(env, argc, argv); load_options(); parse_options(); save_options(); Builder::Ptr builder(new Builder(env)); return builder->errors(); }
void parse_options() { // Parse command line options, and update the environment to match the // specified options. argp->usage( "Usage: jogo [OPTIONS] FILE...\n\n" "Compiles Jogo source files into a library or executable.\n\n" " -a, --assembly Compile, but do not assemble or link.\n" " -c, --compile Compile and assemble, but do not link.\n" " -e, --execute Execute program as a script.\n" " -d, --debug Emit debug information.\n" " -l, --library LIB Compile and link with native library LIB.\n" " -i, --include DIR Add the directory DIR to the search path.\n" " -o, --output FILE Write compiler output to FILE.\n" " -m, --make Compile input files and out-of-date dependencies.\n" " -h, --help Print this help message.\n" " -v, --verbose Print extra information during compilation.\n" " -g, --generator GEN Use code generator GEN.\n" " --build-dir DIR Output directory for object files.\n" " --dump-ir Output the intermediate representation.\n" " --dump-ast Output the abstract syntax tree.\n" " --dump-liveness Output liveness info when printing the IR.\n" " --dump-regalloc Dump register allocations.\n" " --dump-reggraph Dump register interference graphs.\n" " --version Print the compiler version number.\n"); for (ArgToken tok = argp->next(); tok; tok = argp->next()) { // Convert abbreviated flags into the longer descriptive form (e.g., // convert -p to --path) if (ArgToken::SHORT == tok.type()) { parse_short_option(tok.value()); } else if (ArgToken::LONG == tok.type()) { parse_option(tok.value()); } else { env->input(tok.value()); } } std::string gen = env->generator(); if (gen != "Intel64" && gen != "C" && gen != "Nasm64") { argp->error("Invalid code generator (options: Intel64, NAsm64, C)"); } if (!env->inputs()) { argp->error("No input files."); } }
void parse_option(std::string const& flag) { if ("library" == flag) { env->lib(argp->required_arg()); } else if ("include" == flag) { env->include(argp->required_arg()); } else if ("generator" == flag) { env->generator(argp->required_arg()); } else if ("debug" == flag) { env->debug(true); } else if ("optimize" == flag) { env->optimize(true); } else if ("verbose" == flag) { env->verbose(true); } else if ("clean" == flag) { clean(env->build_dir()); clean("bin"); clean("lib"); exit(0); } else if ("reset" == flag) { File::unlink(".jgmake"); exit(0); } else { argp->bad_option(flag); } }
int main(int argc, char** argv) { // Create a new empty environment to store the AST and symbols tables, and // set the options for compilation. argp = new ArgParser(env, argc, argv); env->output("doc"); env->generator("Markdown"); parse_options(); File::mkdir(env->output()); env->workspace_load(); // Run the compiler. Output to a temporary file if the compiler will // continue on to another stage; otherwise, output the file directly. Parser::Ptr parser(new Parser(env)); SemanticAnalyzer::Ptr semant(new SemanticAnalyzer(env)); MarkdownGenerator::Ptr md(new MarkdownGenerator(env)); return 0; }
void parse_options() { // Parse command line options, and update the environment to match the // specified options. argp->usage( "Usage: jgmake [OPTIONS] PACKAGE...\n\n" "Builds a Jogo project from the current working directory. Source files should\n" "be under ./src; output files go to ./build, ./lib, ./bin, and ./doc. Options\n" "given to jgmake are recorded. After an option is set, it will remain set the\n" "next time jgmake is run.\n\n" " -l, --library LIB Compile and link with native library LIB.\n" " -i, --include DIR Add the directory DIR to the search path.\n" " -d, --debug Emit debug information.\n" " -o, --optimize Enable compiler optimizations.\n" " -g, --generator GEN Use code generator GEN.\n" " -h, --help Print this help message.\n" " -v, --verbose Print extra information during compilation.\n" " -r, --reset Erase all build options.\n" " -c, --clean Remove all output directories.\n" " --version Print the program version number.\n"); for (ArgToken tok = argp->next(); tok; tok = argp->next()) { // Convert abbreviated flags into the longer descriptive form (e.g., // convert -p to --path) if (ArgToken::SHORT == tok.type()) { parse_short_option(tok.value()); } else if (ArgToken::LONG == tok.type()) { parse_option(tok.value()); } else { env->input(tok.value()); } } std::string gen = env->generator(); if (gen != "Intel64" && gen != "C" && gen != "Nasm64") { argp->error("Invalid code generator (options: Intel64, Nasm64, C)"); } }
void clean(std::string const& dir) { for(File::Iterator i(dir);i;++i) { std::string const path = dir + FILE_SEPARATOR + (*i); if((*i) == "." || (*i) == "..") { // Do nothing } else if(File::is_dir(path)) { clean(path); } else { if (env->verbose()) { std::cout << "Removing " << path << std::endl; } File::unlink(path); } } }
void parse_option(std::string const& flag) { // Parses an option and all the corresponding arguments to that option. if ("verbose" == flag) { env->verbose(true); } else if ("optimize" == flag) { env->optimize(true); } else if ("assembly" == flag) { env->assemble(false); env->link(false); } else if ("compile" == flag) { env->link(false); } else if ("make" == flag) { env->make(true); } else if ("debug" == flag) { env->debug(true); } else if ("dump-ir" == flag) { env->dump_ir(true); } else if ("dump-ast" == flag) { env->dump_ast(true); } else if ("dump-lex" == flag) { env->dump_lex(true); } else if ("dump-liveness" == flag) { env->dump_liveness(true); } else if ("dump-regalloc" == flag) { env->dump_regalloc(true); } else if ("dump-reggraph" == flag) { env->dump_reggraph(true); } else if ("execute" == flag) { env->execute(true); } else if ("no-default-libs" == flag) { env->no_default_libs(true); // Debugger flag that prevents default modules from getting // loaded automatically by the parser. } else if ("include" == flag) { env->include(argp->required_arg()); } else if ("output" == flag) { env->output(argp->required_arg()); } else if ("build-dir" == flag) { env->build_dir(argp->required_arg()); } else if ("library" == flag) { env->lib(argp->required_arg()); } else if ("generator" == flag) { env->generator(argp->required_arg()); } else { argp->bad_option(flag); } }
/** * @brief main function * * Uses boost program options to read file * Outputs to _sol.txt file */ int main(int argc, char** argv){ //some program options boilerplate namespace po = boost::program_options; po::options_description desc("Vanilla Navigation Planner Usage"); desc.add_options() ("vis,v","mode to rewrite the json files into readable format for matlab") ("env,e",po::value<string>()->required(),"input environment json file"); po::variables_map vm; po::store(po::command_line_parser(argc, argv).options(desc).run(), vm); po::notify(vm); //open the json boost::filesystem::path json_file( vm["env"].as<string>() ); ifstream input_json_file; if(boost::filesystem::exists(json_file)){ input_json_file.open( json_file.string().c_str() ); } else{ printf("File \"%s\" does not exist to be read!\n", json_file.string().c_str()); } if( input_json_file ){ //use the json file to construct the environment Environment::Ptr env = boost::make_shared<Environment>(); env->readDescription( input_json_file ); input_json_file.close(); if(vm.count("vis")){ boost::filesystem::path parent_dir = json_file.parent_path(); boost::filesystem::path solution_filename(json_file.stem().string()+"_vis.txt"); boost::filesystem::path solution_filepath = parent_dir / solution_filename; ofstream ofs; ofs.open( solution_filepath.string().c_str() ); ofs << *env; ofs.close(); } else{ //plan on the environment Graph::Ptr graph = boost::make_shared<Graph>(env); Planner::Ptr plnr = boost::make_shared<Planner>(env, graph); vector<GraphState::Ptr> path; //call planner bool plannerResult = plnr->plan(path); if(plannerResult){ //output plan to file boost::filesystem::path parent_dir = json_file.parent_path(); boost::filesystem::path solution_filename(json_file.stem().string()+"_sol.txt"); boost::filesystem::path solution_filepath = parent_dir / solution_filename; printf("Writing out solution to: %s\n", solution_filepath.string().c_str()); ofstream ofs; ofs.open( solution_filepath.string().c_str() ); for(size_t i=0; i<path.size(); i++){ ofs << *(path[i]) << endl; } ofs.close(); } else{ // cout << "No plan found!" << endl; } } } return 0; }
Fork::Fork(const Environment::Ptr parentEnv_, const RaveInstancePtr rave_, BulletInstance::Ptr bullet, OSGInstance::Ptr osg) : parentEnv(parentEnv_.get()), env(new Environment(bullet, osg)), rave(rave_) { copyObjects(); }