Skip to content

Commit 5af9cbb

Browse files
authored
Merge pull request #346 from bohendo/master
335 dup: Fix for redundant compiles and incorrect version selection when running with solc_solcs_select flag
2 parents aebea8d + cd52336 commit 5af9cbb

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

crytic_compile/platform/solc.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ def _run_solcs_path(
584584
targets_json = None
585585
if isinstance(solcs_path, dict):
586586
guessed_solcs = _guess_solc(filename, working_dir)
587+
compilation_errors = []
587588
for guessed_solc in guessed_solcs:
588589
if not guessed_solc in solcs_path:
589590
continue
@@ -624,12 +625,14 @@ def _run_solcs_path(
624625
working_dir=working_dir,
625626
force_legacy_json=force_legacy_json,
626627
)
627-
except InvalidCompilation:
628-
pass
628+
break
629+
except InvalidCompilation as ic:
630+
compilation_errors.append(solc_bin + ": " + ic.args[0])
629631

630632
if not targets_json:
631633
raise InvalidCompilation(
632-
"Invalid solc compilation, none of the solc versions provided worked"
634+
"Invalid solc compilation, none of the solc versions provided worked:\n"
635+
+ "\n".join(compilation_errors)
633636
)
634637

635638
return targets_json
@@ -672,6 +675,7 @@ def _run_solcs_env(
672675
env = dict(os.environ) if env is None else env
673676
targets_json = None
674677
guessed_solcs = _guess_solc(filename, working_dir)
678+
compilation_errors = []
675679
for guessed_solc in guessed_solcs:
676680
if solcs_env and not guessed_solc in solcs_env:
677681
continue
@@ -688,6 +692,7 @@ def _run_solcs_env(
688692
working_dir=working_dir,
689693
force_legacy_json=force_legacy_json,
690694
)
695+
break
691696
except InvalidCompilation:
692697
pass
693698

@@ -708,12 +713,14 @@ def _run_solcs_env(
708713
working_dir=working_dir,
709714
force_legacy_json=force_legacy_json,
710715
)
711-
except InvalidCompilation:
712-
pass
716+
break
717+
except InvalidCompilation as ic:
718+
compilation_errors.append(version_env + ": " + ic.args[0])
713719

714720
if not targets_json:
715721
raise InvalidCompilation(
716-
"Invalid solc compilation, none of the solc versions provided worked"
722+
"Invalid solc compilation, none of the solc versions provided worked:\n"
723+
+ "\n".join(compilation_errors)
717724
)
718725

719726
return targets_json

0 commit comments

Comments
 (0)