Skip to content

Commit c5b2c97

Browse files
GalloDaSballodguido
authored andcommitted
feat: no force
1 parent 079330f commit c5b2c97

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

crytic_compile/cryticparser/cryticparser.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,3 +473,11 @@ def _init_foundry(parser: ArgumentParser) -> None:
473473
dest="foundry_deny",
474474
default=DEFAULTS_FLAG_IN_CONFIG["foundry_deny"],
475475
)
476+
477+
group_foundry.add_argument(
478+
"--foundry-no-force",
479+
help="Do not use --force flag for incremental compilation",
480+
action="store_true",
481+
dest="foundry_no_force",
482+
default=DEFAULTS_FLAG_IN_CONFIG["foundry_no_force"],
483+
)

crytic_compile/cryticparser/defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"foundry_build_info_directory": None,
4848
"foundry_compile_all": False,
4949
"foundry_deny": None,
50+
"foundry_no_force": False,
5051
"export_dir": "crytic-export",
5152
"compile_libraries": None,
5253
}

crytic_compile/platform/foundry.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
6868
Args:
6969
crytic_compile (CryticCompile): CryticCompile object to populate
7070
**kwargs: optional arguments. Used: "foundry_ignore_compile", "foundry_out_directory",
71-
"foundry_build_info_directory", "foundry_deny"
71+
"foundry_build_info_directory", "foundry_deny", "foundry_no_force"
7272
7373
"""
7474

@@ -105,9 +105,24 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
105105
]
106106

107107
compile_all = kwargs.get("foundry_compile_all", False)
108+
no_force = kwargs.get("foundry_no_force", False)
108109

109110
foundry_config = self.config(self._project_root)
110111

112+
# When no_force is enabled, we must compile all files (including tests)
113+
# to ensure test changes are detected. Otherwise tests would be skipped
114+
# and test modifications wouldn't trigger recompilation.
115+
# We also clean build-info to prevent multiple compilation units from accumulating.
116+
if no_force:
117+
compile_all = True
118+
out_dir = foundry_config.out_path if foundry_config else "out"
119+
build_info_dir = Path(self._project_root, out_dir, "build-info")
120+
if build_info_dir.exists():
121+
import shutil
122+
123+
shutil.rmtree(build_info_dir)
124+
LOGGER.info("Cleaned %s for fresh build-info generation", build_info_dir)
125+
111126
if not targeted_build and not compile_all and foundry_config:
112127
compilation_command += [
113128
"--skip",

0 commit comments

Comments
 (0)