Skip to content

Commit 6104232

Browse files
committed
feat: no force
1 parent 3c83210 commit 6104232

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

crytic_compile/cryticparser/cryticparser.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,3 +456,11 @@ def _init_foundry(parser: ArgumentParser) -> None:
456456
dest="foundry_compile_all",
457457
default=DEFAULTS_FLAG_IN_CONFIG["foundry_compile_all"],
458458
)
459+
460+
group_foundry.add_argument(
461+
"--foundry-no-force",
462+
help="Do not use --force flag for incremental compilation",
463+
action="store_true",
464+
dest="foundry_no_force",
465+
default=DEFAULTS_FLAG_IN_CONFIG["foundry_no_force"],
466+
)

crytic_compile/cryticparser/defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"foundry_ignore_compile": False,
4747
"foundry_out_directory": "out",
4848
"foundry_compile_all": False,
49+
"foundry_no_force": False,
4950
"export_dir": "crytic-export",
5051
"compile_libraries": None,
5152
}

crytic_compile/platform/foundry.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
6161
]
6262

6363
compile_all = kwargs.get("foundry_compile_all", False)
64+
no_force = kwargs.get("foundry_no_force", False)
65+
66+
# When no_force is enabled, we must compile all files (including tests)
67+
# to ensure test changes are detected. Otherwise tests would be skipped
68+
# and test modifications wouldn't trigger recompilation.
69+
# We also clean build-info to prevent multiple compilation units from accumulating.
70+
if no_force:
71+
compile_all = True
72+
build_info_dir = Path(self._target, out_directory, "build-info")
73+
if build_info_dir.exists():
74+
import shutil
75+
shutil.rmtree(build_info_dir)
76+
LOGGER.info(f"Cleaned {build_info_dir} for fresh build-info generation")
6477

6578
if not compile_all:
6679
foundry_config = self.config(self._target)

0 commit comments

Comments
 (0)