Example #1
0
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();
}
Example #2
0
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);
    }
}