-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement dependency information output like GCC to rustc #7633
Comments
I'm reopening this because I think this is worth a separate issue, since file dependencies (detecting when a recompile is needed) is different to function dependencies and incremental recompilation. I could imagine this being a subtool of That said, |
I'm sorry to be unaware of duplication. I think it's nice to get rustpkg faster first, thus I'm happy with the direction. However I doubt whether rustpkg suitable for every areas where Rust will be used. I'll use rustpkg and reopen this when I really need dependency export. |
@omasanori It's actually not that hard to do (or at least, an approximation to it) as an external binary, since the parser is a normal crate (called extern mod syntax;
extern mod extra;
use std::hashmap::HashSet;
use syntax::{parse, visit};
fn main() {
let filename = match std::os::args() {
[_, name] => name,
_ => {
println("Expected the file path");
fail!()
}
};
let path = Path(filename);
let parsesess = parse::new_parse_sess(None);
let mut crate = parse::parse_crate_from_file(&path, ~[], parsesess);
crate = syntax::ext::expand::expand_crate(parsesess, ~[], crate);
let files = @mut HashSet::new();
let visitor = visit::mk_vt(@visit::Visitor {
visit_mod: |m, sp, id, tup| {
let fname = parsesess.cm.span_to_filename(sp);
if "<core-macros>" != fname {
(*files).insert(fname);
}
visit::visit_mod(m, sp, id, tup)
},
.. *visit::default_visitor()
});
visit::visit_crate(crate, ((), visitor));
let mut v = ~[];
do files.consume |s| { v.push(s); }
extra::sort::tim_sort(v);
println(v.connect(" "));
}
|
@huonw Thank you for your suggestion. I just remember what LLVM people said: make it as a set of modular library, and we will be happy. 😃 |
I'm working on this. |
@metajack I really appreciate your work. Thank you! |
Dependency information from compilers is useful to build incrementally. Without that, build process will be incorrect and/or slow.
GCC and Clang can emit such information in (a subset of) Makefile syntax. AFAIK that can be used from
make
(of cource) and ninja. It might be nice if rustc provides similar feature, I think.The text was updated successfully, but these errors were encountered: