Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crytic_compile/cryticparser/cryticparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,11 @@ def _init_foundry(parser: ArgumentParser) -> None:
dest="foundry_compile_all",
default=DEFAULTS_FLAG_IN_CONFIG["foundry_compile_all"],
)

group_foundry.add_argument(
"--foundry-no-force",
help="Do not use --force flag for incremental compilation",
action="store_true",
dest="foundry_no_force",
default=DEFAULTS_FLAG_IN_CONFIG["foundry_no_force"],
)
1 change: 1 addition & 0 deletions crytic_compile/cryticparser/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"foundry_ignore_compile": False,
"foundry_out_directory": "out",
"foundry_compile_all": False,
"foundry_no_force": False,
"export_dir": "crytic-export",
"compile_libraries": None,
}
13 changes: 13 additions & 0 deletions crytic_compile/platform/foundry.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
]

compile_all = kwargs.get("foundry_compile_all", False)
no_force = kwargs.get("foundry_no_force", False)

# When no_force is enabled, we must compile all files (including tests)
# to ensure test changes are detected. Otherwise tests would be skipped
# and test modifications wouldn't trigger recompilation.
# We also clean build-info to prevent multiple compilation units from accumulating.
if no_force:
compile_all = True
build_info_dir = Path(self._target, out_directory, "build-info")
if build_info_dir.exists():
import shutil
shutil.rmtree(build_info_dir)
LOGGER.info(f"Cleaned {build_info_dir} for fresh build-info generation")

if not compile_all:
foundry_config = self.config(self._target)
Expand Down