]> git.lizzy.rs Git - rust.git/blob - src/fuzzer/fuzzer.rs
f7bc514a700a85385c85101e1827946933545bb8
[rust.git] / src / fuzzer / fuzzer.rs
1 use std;
2 use rustc;
3
4 import std::fs;
5 import std::getopts;
6 import std::getopts::optopt;
7 import std::getopts::opt_present;
8 import std::getopts::opt_str;
9 import std::io;
10 import std::vec;
11 import std::ivec;
12 import std::str;
13
14 import rustc::back::link;
15 import rustc::syntax::ast;
16 import driver = rustc::driver::rustc; // see https://github.com/graydon/rust/issues/624
17 import rustc::driver::session;
18
19
20 fn find_rust_files(&mutable str[] files, str root) {
21     for (str filename in fs::list_dir(root)) {
22         if (str::ends_with(filename, ".rs")) {
23            files += ~[filename];
24         }
25     }
26 }
27
28 fn main(vec[str] args) {
29     auto files = ~[];
30     auto root = "/Users/jruderman/code/rust/src/lib/"; // XXX
31     find_rust_files(files, root); // not using driver::time here because that currently screws with passing-a-mutable-array
32
33     auto binary = vec::shift[str](args);
34     auto binary_dir = fs::dirname(binary);
35
36     let @session::options sopts =
37         @rec(library=false,
38              static=false,
39              optimize=0u,
40              debuginfo=false,
41              verify=true,
42              run_typestate=true,
43              save_temps=false,
44              stats=false,
45              time_passes=false,
46              time_llvm_passes=false,
47              output_type=link::output_type_bitcode,
48              library_search_paths=[binary_dir + "/lib"],
49              sysroot=driver::get_default_sysroot(binary),
50              cfg=~[],
51              test=false);
52
53     let session::session sess = driver::build_session(sopts);
54
55     log_err ivec::len(files);
56     for (str file in files) {
57         log_err file;
58         // Can't use parse_input here because of https://github.com/graydon/rust/issues/632 :(
59         //auto crate = driver::parse_input(sess, ~[], file);
60         //let @ast::crate crate = driver::time(true, "parsing " + file, bind driver::parse_input(sess, ~[], file));
61     }
62 }
63
64 // Local Variables:
65 // mode: rust;
66 // fill-column: 78;
67 // indent-tabs-mode: nil
68 // c-basic-offset: 4
69 // buffer-file-coding-system: utf-8-unix
70 // compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
71 // End: