Created
November 18, 2014 16:23
-
-
Save jaredly/089b60e0649c4bda3cd9 to your computer and use it in GitHub Desktop.
simple example of compiling rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate rustc; | |
extern crate syntax; | |
use rustc::driver::config::{basic_options, build_configuration}; | |
use rustc::driver::session::{build_session}; | |
use rustc::driver::driver::{StrInput, compile_input}; | |
use syntax::diagnostics; | |
fn main() { | |
let src = "fn main() {println!(\"Awesome\");}"; | |
let opts = basic_options(); | |
let inp = StrInput(src.to_string()); | |
let descriptions = diagnostics::registry::Registry::new(rustc::DIAGNOSTICS); | |
let sess = build_session(opts, None, descriptions); | |
let cfg = build_configuration(&sess); | |
compile_input(sess, cfg, &inp, &None, &None, None); | |
println!("Hello, world!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment