Skip to content

Instantly share code, notes, and snippets.

@richo
Created August 1, 2015 21:48
Show Gist options
  • Save richo/f750855a762804e2b3e9 to your computer and use it in GitHub Desktop.
Save richo/f750855a762804e2b3e9 to your computer and use it in GitHub Desktop.
#![feature(exit_status)]
#![feature(rustc_private)]
extern crate syntax;
extern crate rustc_back;
use rustc_back::svh::Svh;
use syntax::{parse,ast,diagnostic};
use std::path;
use std::io;
use std::env;
use context::{Ctx,Func};
fn load_file(name: &str) -> Result<ast::Crate, diagnostic::FatalError> {
let file = path::Path::new(name);
let sess = parse::ParseSess::new();
let cfg = vec![];
let mut parser = parse::new_parser_from_file(&sess, cfg, &file);
parser.parse_crate_mod()
}
fn main() {
let args: Vec<_> = ::std::env::args().collect();
let ref input = args[1];
let krate = match load_file(input) {
Ok(krate) => krate,
Err(_) => {
env::set_exit_status(1);
return;
},
};
let v = vec![];
let hash = Svh::calculate(&v, &krate);
println!("{}", hash.as_str());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment