rust/src/fuzzer/fuzzer.rs

72 lines
2.1 KiB
Rust
Raw Normal View History

2011-07-08 02:16:46 -07:00
use std;
use rustc;
2011-05-20 21:06:05 -04:00
import std::fs;
import std::getopts;
import std::getopts::optopt;
import std::getopts::opt_present;
import std::getopts::opt_str;
import std::io;
import std::vec;
2011-07-08 02:16:46 -07:00
import std::ivec;
import std::str;
2011-05-20 21:06:05 -04:00
2011-07-08 02:16:46 -07:00
import rustc::back::link;
import rustc::syntax::ast;
import driver = rustc::driver::rustc; // see https://github.com/graydon/rust/issues/624
import rustc::driver::session;
2011-05-20 21:06:05 -04:00
2011-07-08 02:16:46 -07:00
fn find_rust_files(&mutable str[] files, str root) {
for (str filename in fs::list_dir(root)) {
if (str::ends_with(filename, ".rs")) {
files += ~[filename];
2011-05-20 21:06:05 -04:00
}
}
2011-07-08 02:16:46 -07:00
}
2011-05-20 21:06:05 -04:00
2011-07-08 02:16:46 -07:00
fn main(vec[str] args) {
auto files = ~[];
auto root = "/Users/jruderman/code/rust/src/lib/"; // XXX
find_rust_files(files, root); // not using driver::time here because that currently screws with passing-a-mutable-array
2011-05-20 21:06:05 -04:00
2011-07-08 02:16:46 -07:00
auto binary = vec::shift[str](args);
auto binary_dir = fs::dirname(binary);
2011-05-20 21:06:05 -04:00
2011-07-08 02:16:46 -07:00
let @session::options sopts =
@rec(library=false,
static=false,
optimize=0u,
debuginfo=false,
verify=true,
run_typestate=true,
save_temps=false,
stats=false,
time_passes=false,
time_llvm_passes=false,
output_type=link::output_type_bitcode,
library_search_paths=[binary_dir + "/lib"],
sysroot=driver::get_default_sysroot(binary),
cfg=~[],
test=false);
2011-05-20 21:06:05 -04:00
2011-07-08 02:16:46 -07:00
let session::session sess = driver::build_session(sopts);
2011-05-20 21:06:05 -04:00
2011-07-08 02:16:46 -07:00
log_err ivec::len(files);
for (str file in files) {
log_err file;
// Can't use parse_input here because of https://github.com/graydon/rust/issues/632 :(
//auto crate = driver::parse_input(sess, ~[], file);
//let @ast::crate crate = driver::time(true, "parsing " + file, bind driver::parse_input(sess, ~[], file));
}
2011-05-20 21:06:05 -04:00
}
// Local Variables:
// mode: rust;
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End: