Skip to content

Commit

Permalink
Merge pull request #1411 from danhper/fix-incremental-compilation
Browse files Browse the repository at this point in the history
Fix incremental compilation
  • Loading branch information
iamdefinitelyahuman authored Feb 5, 2022
2 parents 3895c0b + 56e4afa commit 41c3406
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Improve support for Ganache 7 reverted transactions
- Fix incremental compilation failing because of mismatching compiler versions

## [1.17.2](https://github.com/eth-brownie/brownie/tree/v1.17.2) - 2021-12-04
### Changed
Expand Down
24 changes: 21 additions & 3 deletions brownie/project/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,19 @@ def _compare_build_json(self, contract_name: str) -> bool:
if build_json["sha1"] != sha1(source.encode()).hexdigest():
return True
# compare compiler settings
if _compare_settings(config, build_json["compiler"]):
return True
if build_json["language"] == "Solidity":
# compare solc-specific compiler settings
solc_config = config["solc"].copy()
solc_config["remappings"] = None
if _compare_settings(solc_config, build_json["compiler"]):
if not _solidity_compiler_equal(solc_config, build_json["compiler"]):
return True
# compare solc pragma against compiled version
if Version(build_json["compiler"]["version"]) not in get_pragma_spec(source):
return True
else:
vyper_config = config["vyper"].copy()
if not _vyper_compiler_equal(vyper_config, build_json["compiler"]):
return True
return False

def _compile_interfaces(self, compiled_hashes: Dict) -> None:
Expand Down Expand Up @@ -950,6 +952,22 @@ def _compare_settings(left: Dict, right: Dict) -> bool:
)


def _normalize_solidity_version(version: str) -> str:
return version.split("+")[0]


def _solidity_compiler_equal(config: dict, build: dict) -> bool:
return (
config["version"] is None
or _normalize_solidity_version(config["version"])
== _normalize_solidity_version(build["version"])
) and config["optimizer"] == build["optimizer"]


def _vyper_compiler_equal(config: dict, build: dict) -> bool:
return config["version"] is None or config["version"] == build["version"]


def _load_sources(project_path: Path, subfolder: str, allow_json: bool) -> Dict:
contract_sources: Dict = {}
suffixes: Tuple = (".sol", ".vy")
Expand Down

0 comments on commit 41c3406

Please sign in to comment.