Skip to content

Commit f5bbd38

Browse files
committed
Make llvm backend opt in as feature "llvm-backend"
Resolve #36.
1 parent 9b45b72 commit f5bbd38

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ peg = { version = "0.5" }
1313
[features]
1414
cargo-clippy = []
1515
file-tests = []
16+
llvm-backend = ["llvm-sys", "libc", "itertools"]
1617

1718
[dependencies]
1819
ansi_term = "0.9.0"
1920
rustyline = "1.0.0"
2021
fnv = "1.0.5"
2122
linear-map = "1.1.0"
2223
hyper = "0.10"
23-
llvm-sys = "40.0.0"
24-
itertools = "0.6.0"
25-
libc = "0.2"
24+
llvm-sys = {version = "40.0.0", optional = true}
25+
itertools = {version = "0.6.0", optional = true}
26+
libc = {version = "0.2", optional = true}
2627
clippy = {version = "*", optional = true}

src/main.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ extern crate linear_map;
1313

1414
extern crate hyper;
1515

16+
#[cfg(feature = "llvm-backend")]
1617
extern crate llvm_sys;
17-
18+
#[cfg(feature = "llvm-backend")]
1819
extern crate itertools;
19-
20+
#[cfg(feature = "llvm-backend")]
2021
extern crate libc;
2122

2223
// include output of rust-peg given grammar.rustpeg
@@ -28,6 +29,7 @@ mod parser {
2829
mod ast;
2930
mod runtime;
3031
mod ast_walk_interpreter;
32+
#[cfg(feature = "llvm-backend")]
3133
mod llvm_interpreter;
3234
mod value;
3335
mod operations;
@@ -47,17 +49,21 @@ mod file_test {
4749

4850
use runtime::*;
4951
use ast_walk_interpreter::AstWalkInterpreter;
52+
#[cfg(feature = "llvm-backend")]
5053
use llvm_interpreter::LLVMInterpreter;
5154

5255
use error::*;
5356

5457
// FIXME: How do you represent the usage style in POSIX notation?
5558
fn print_usage() {
56-
println!("usage: balloon [--repl-llvm | [MODE] FILE ]
57-
58-
59-
--repl-llvm launches the experimental REPL
59+
if cfg!(feature = "llvm-backend") {
60+
println!("usage: balloon [--repl-llvm | [MODE] FILE ]
6061
62+
--repl-llvm launches the experimental REPL");
63+
} else {
64+
println!("usage: balloon [MODE] FILE");
65+
}
66+
println!("
6167
where MODE is one of:
6268
--run (default) runs the file [FILE]
6369
--check type check the file [FILE]
@@ -71,6 +77,7 @@ fn main() {
7177
1 => repl::run_repl(AstWalkInterpreter::new()),
7278
2 => {
7379
match args[1].as_str() {
80+
#[cfg(feature = "llvm-backend")]
7481
"--repl-llvm" => repl::run_repl(LLVMInterpreter::new()),
7582
filepath => run_file(filepath, AstWalkInterpreter::new()),
7683
}

0 commit comments

Comments
 (0)