-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vibranium::compiler): introduce simple Solcjs strategy
With this commit it's possible to use `solcjs` with the compile command: ``` $ vibranium compile --compiler solcjs ``` While this was possible before, it only worked when applying compiler options manually as there wasn't built-in support: ``` $ vibranium compile --compiler solcjs -- --abi -o file1 file2... ```
- Loading branch information
Showing
6 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod default; | ||
pub mod solcjs; | ||
pub mod solc; | ||
|
||
use std::path::{PathBuf}; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use super::{Strategy, StrategyConfig}; | ||
use std::process::{Command, Child, Stdio}; | ||
use glob::glob; | ||
|
||
pub const SOLC_JS_COMPILER_BINARY: &str = "solcjs"; | ||
|
||
pub struct SolcJsStrategy<'a> { | ||
config: StrategyConfig<'a> | ||
} | ||
|
||
impl<'a> SolcJsStrategy<'a> { | ||
pub fn new(config: StrategyConfig) -> SolcJsStrategy { | ||
SolcJsStrategy { | ||
config | ||
} | ||
} | ||
} | ||
|
||
impl<'a> Strategy for SolcJsStrategy<'a> { | ||
|
||
fn execute(&self) -> Result<Child, std::io::Error> { | ||
let mut args: Vec<String> = vec![ | ||
"--abi".to_string(), | ||
"-o".to_string(), | ||
self.config.output_path.to_string_lossy().to_string() | ||
]; | ||
|
||
for pattern in &self.config.smart_contract_sources { | ||
let mut full_pattern = self.config.input_path.clone(); | ||
full_pattern.push(&pattern); | ||
for entry in glob(&full_pattern.to_str().unwrap()).unwrap().filter_map(Result::ok) { | ||
args.push(entry.to_string_lossy().to_string()); | ||
} | ||
} | ||
|
||
Command::new(SOLC_JS_COMPILER_BINARY) | ||
.args(args) | ||
.args(&self.config.compiler_options) | ||
.stdout(Stdio::piped()) | ||
.stderr(Stdio::piped()) | ||
.spawn() | ||
} | ||
} |
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