Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Commit

Permalink
Merge pull request #99 from paritytech/snd-issue-98
Browse files Browse the repository at this point in the history
fix for #98: helpful error if solc is not in $PATH
  • Loading branch information
debris authored Jan 25, 2018
2 parents 7d9a875 + bc0ebb8 commit ceaf22f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ by `value`.

### build

requires `solc` to be in `$PATH`. [installation instructions](https://solidity.readthedocs.io/en/develop/installing-solidity.html)

```
cargo build -p bridge-cli --release
```
Expand Down Expand Up @@ -207,7 +209,7 @@ checked_withdraw_confirm = 121

### truffle tests

[requires yarn to be installed](https://yarnpkg.com/lang/en/docs/install/)
requires `yarn` to be `$PATH`. [installation instructions](https://yarnpkg.com/lang/en/docs/install/)

```
cd truffle
Expand Down
45 changes: 31 additions & 14 deletions bridge/build.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
use std::process::Command;

fn main() {
// rerun build script if bridge contract has changed.
// without this cargo doesn't since the bridge contract
// is outside the crate directories
println!("cargo:rerun-if-changed=../contracts/bridge.sol");
let exit_status = Command::new("solc")
.arg("--abi")
.arg("--bin")
.arg("--optimize")
.arg("--output-dir").arg("../compiled_contracts")
.arg("--overwrite")
.arg("../contracts/bridge.sol")
.status()
.unwrap_or_else(|e| panic!("Error compiling solidity contracts: {}", e));
assert!(exit_status.success(), "There was an error while compiling contracts code.");
// rerun build script if bridge contract has changed.
// without this cargo doesn't since the bridge contract
// is outside the crate directories
println!("cargo:rerun-if-changed=../contracts/bridge.sol");

match Command::new("solc")
.arg("--abi")
.arg("--bin")
.arg("--optimize")
.arg("--output-dir").arg("../compiled_contracts")
.arg("--overwrite")
.arg("../contracts/bridge.sol")
.status()
{
Ok(exit_status) => {
if !exit_status.success() {
if let Some(code) = exit_status.code() {
panic!("`solc` exited with error exit status code `{}`", code);
} else {
panic!("`solc` exited because it was terminated by a signal");
}
}
},
Err(err) => {
if let std::io::ErrorKind::NotFound = err.kind() {
panic!("`solc` executable not found in `$PATH`. `solc` is required to compile the bridge contracts. please install it: https://solidity.readthedocs.io/en/develop/installing-solidity.html");
} else {
panic!("an error occurred when trying to spawn `solc`: {}", err);
}
}
}
}

0 comments on commit ceaf22f

Please sign in to comment.