Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions dapptools/src/dapp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ fn main() -> eyre::Result<()> {
match opts.sub {
Subcommands::Test {
opts:
BuildOpts { contracts, remappings, remappings_env, lib_paths, out_path, evm_version },
BuildOpts {
contracts,
remappings,
remappings_env,
lib_paths,
out_path,
evm_version,
contracts_env,
},
env,
json,
pattern,
Expand All @@ -50,6 +58,13 @@ fn main() -> eyre::Result<()> {
} else {
remappings
};

let contracts = if let Some(env_defined_contracts) = contracts_env {
env_defined_contracts
} else {
contracts
};

let remappings = utils::merge(remappings, remappings_env);
let lib_paths = utils::default_path(lib_paths)?;

Expand Down Expand Up @@ -125,11 +140,24 @@ fn main() -> eyre::Result<()> {
}
Subcommands::Build {
opts:
BuildOpts { contracts, remappings, remappings_env, lib_paths, out_path, evm_version: _ },
BuildOpts {
contracts,
remappings,
remappings_env,
lib_paths,
out_path,
evm_version: _,
contracts_env,
},
} => {
// build the contracts
let remappings = utils::merge(remappings, remappings_env);
let lib_paths = utils::default_path(lib_paths)?;
let contracts = if let Some(env_defined_contracts) = contracts_env {
env_defined_contracts
} else {
contracts
};
Comment on lines +156 to +160
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should work as well, right?

Suggested change
let contracts = if let Some(env_defined_contracts) = contracts_env {
env_defined_contracts
} else {
contracts
};
let contracts = contracts_env.unwrap_or(contracts);

// TODO: Do we also want to include the file path in the contract map so
// that we're more compatible with dapptools' artifact?
let contracts = SolcBuilder::new(&contracts, &remappings, &lib_paths)?.build_all()?;
Expand Down
2 changes: 2 additions & 0 deletions dapptools/src/dapp_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ pub struct BuildOpts {
default_value = "./src/**/*.sol"
)]
pub contracts: String,
#[structopt(env = "DAPP_SRC")]
pub contracts_env: Option<String>,

#[structopt(help = "the remappings", long, short)]
pub remappings: Vec<String>,
Expand Down