Skip to content

Parse artifacts after a custom build command - #701

Open
Eljees wants to merge 1 commit into
crytic:masterfrom
Eljees:fix/custom-build-artifacts
Open

Parse artifacts after a custom build command#701
Eljees wants to merge 1 commit into
crytic:masterfrom
Eljees:fix/custom-build-artifacts

Conversation

@Eljees

@Eljees Eljees commented Aug 8, 2026

Copy link
Copy Markdown

Fixes #423.

--compile-custom-build runs the user's command, but nothing ever reads what that command produced: compilation_units stays empty, so Slither and the other consumers see a project with no sources.

Cause

In CryticCompile._compile, the call that parses the artifacts sits in the else branch, so it is skipped whenever a custom build is requested:

custom_build: None | str = kwargs.get("compile_custom_build", None)
if custom_build:
    self._run_custom_build(custom_build)
else:
    if not kwargs.get("skip_clean", False) and not kwargs.get("ignore_compile", False):
        self._platform.clean(**kwargs)
    self._platform.compile(self, **kwargs)   # <- only reached without a custom build

Fix

Every platform already supports ignore_compile (foundry.py, hardhat.py, buidler.py, embark.py, truffle.py): do not invoke the build tool, but still read the artifacts from disk. A custom build has just produced those artifacts, so that is exactly the mode that applies here. The patch reuses it instead of adding a new code path, and no platform is touched.

ignore_compile is passed as "true" rather than True because **kwargs is typed str here; the platforms only test it for truthiness, and crytic_defer_compilation already uses the same string convention.

Cleaning is still skipped for custom builds, which is the previous behaviour.

Tests

New tests/test_custom_build.py. It needs no compiler: it uses a stub AbstractPlatform, the same approach as tests/test_stale_cache_hint.py. The custom build command writes a marker file, so the test can distinguish "the command did not run" from "the artifacts were not parsed".

Before the fix (the marker assert passes, so the command did run):

>       assert platform.compile_calls, "platform.compile() was never called: no compilation units"
E       AssertionError: platform.compile() was never called: no compilation units
E       assert []
1 failed in 0.18s

After the fix: 1 passed.

Also run: ruff check crytic_compile/ tests/ (clean), ruff format --check (clean), ty check crytic_compile/ (no new diagnostics compared to master), and the compiler-independent part of the suite (test_stale_cache_hint.py, test_naming.py, test_locate_framework_root.py) - 25 passed.

Signed-off-by: Eljees <3.14hell@gmail.com>
@CLAassistant

CLAassistant commented Aug 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Eljees

Eljees commented Aug 14, 2026

Copy link
Copy Markdown
Author

Ping — this one and #702 have been open since 8 August with no review.

The CLA check is signed and green on both, but that is the only check that has run: the github-actions suites are at action_required, waiting on a maintainer to approve a workflow run. Neither PR has been through your test suite yet, and I cannot trigger that from my side.

The two are independent of each other and can be taken in either order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

run_custom_build does not create source/compilation units

2 participants