This commit is contained in:
AlexK 2022-03-07 10:41:08 +04:00
parent 061695a2ab
commit 3e314638c3
3 changed files with 11 additions and 6 deletions

View File

@ -67,10 +67,14 @@ impl CompilerInput {
solidity_sources.insert(path, source);
}
}
vec![
Self { language: "Solidity".to_string(), sources: solidity_sources, settings: Default::default() },
Self { language: "Yul".to_string(), sources: yul_sources, settings: Default::default() }
]
let mut res = Vec::new();
if !solidity_sources.is_empty() {
res.push(Self { language: "Solidity".to_string(), sources: solidity_sources, settings: Default::default() });
}
if !yul_sources.is_empty() {
res.push(Self { language: "Yul".to_string(), sources: yul_sources, settings: Default::default() });
}
res
}
/// Sets the settings for compilation

View File

@ -571,8 +571,8 @@ impl Solc {
/// use ethers_solc::{CompilerInput, Solc};
/// let solc1 = Solc::default();
/// let solc2 = Solc::default();
/// let input1 = CompilerInput::new("contracts").unwrap();
/// let input2 = CompilerInput::new("src").unwrap();
/// let input1 = CompilerInput::new("contracts").unwrap()[0].clone();
/// let input2 = CompilerInput::new("src").unwrap()[0].clone();
///
/// let outputs = Solc::compile_many([(solc1, input1), (solc2, input2)], 2).await.flattened().unwrap();
/// # }

View File

@ -740,6 +740,7 @@ mod tests {
.build()
.unwrap();
let compiled = project.compile().unwrap();
dbg!(compiled.clone());
assert!(!compiled.has_compiler_errors());
let contracts = compiled.output().contracts;
assert_eq!(contracts.contracts().count(), 3);