Skip to content

Commit

Permalink
Conditionally compile creusot-contracts dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudgolfouse committed Nov 28, 2024
1 parent 036325a commit 3a27ed7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions creusot-contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ description = "Provides contracts and logic helpers for Creusot"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
[target.'cfg(creusot)'.dependencies]
num-rational = "0.3.2"
creusot-contracts-proc = { path = "../creusot-contracts-proc", version = "0.3.0" }

[target.'cfg(not(creusot))'.dependencies]
creusot-contracts-dummy = { path = "../creusot-contracts-dummy", version = "0.3.0" }
num-rational = "0.3.2"

[features]
default = []
Expand Down
7 changes: 5 additions & 2 deletions creusot-rustc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc_driver::RunCompiler;
use rustc_session::{config::ErrorOutputType, EarlyDiagCtxt};
use std::{env, panic, process::Command};

const BUG_REPORT_URL: &'static str = &"https://github.com/creusot-rs/creusot/issues/new";
const BUG_REPORT_URL: &str = "https://github.com/creusot-rs/creusot/issues/new";

struct DefaultCallbacks;
impl rustc_driver::Callbacks for DefaultCallbacks {}
Expand Down Expand Up @@ -75,7 +75,10 @@ fn setup_plugin() {
};
RunCompiler::new(&args, &mut ToWhy::new(opts)).run().unwrap();
}
_ => RunCompiler::new(&args, &mut DefaultCallbacks).run().unwrap(),
_ => {
args.push("--cfg=creusot".to_string());
RunCompiler::new(&args, &mut DefaultCallbacks).run().unwrap()
}
}
}

Expand Down

0 comments on commit 3a27ed7

Please sign in to comment.