From a97085e8ad61d39096693728b6480b7b06785de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Mon, 26 Sep 2022 14:20:53 -0300 Subject: [PATCH] Compilation check --- slither/tools/doctor/__main__.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/slither/tools/doctor/__main__.py b/slither/tools/doctor/__main__.py index 410fabd33..74f854672 100644 --- a/slither/tools/doctor/__main__.py +++ b/slither/tools/doctor/__main__.py @@ -1,4 +1,5 @@ import argparse +import logging from pathlib import Path from crytic_compile import cryticparser @@ -62,15 +63,39 @@ def detect_platform(project: str, **kwargs): ) elif platform_qty > 1: print(red("More than one platform was detected! This doesn't sound right.")) - print(red("Please use `--compile-force-framework` in Slither to force the correct framework.")) + print( + red("Please use `--compile-force-framework` in Slither to force the correct framework.") + ) else: print(green("A single platform was detected."), yellow("Is it the one you expected?")) + print(end="\n\n") + + +def compile_project(project: str, **kwargs): + print("## Project compilation") + print() + + print("Invoking crytic-compile on the project, please wait...") + + try: + crytic_compile.CryticCompile(project, **kwargs) + except Exception as e: + print(red("Project compilation failed :( The following error was generated:"), end="\n\n") + print(yellow("---- snip 8< ----")) + logging.exception(e) + print(yellow("---- >8 snip ----")) + + print(end="\n\n") + def main(): args = parse_args() - detect_platform(args.project) + kwargs = vars(args) + + detect_platform(**kwargs) + compile_project(**kwargs) # TODO other checks