Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add skip key to foundry.toml #8061

Merged
merged 14 commits into from
Jun 6, 2024
Merged

feat: add skip key to foundry.toml #8061

merged 14 commits into from
Jun 6, 2024

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented Jun 4, 2024

Motivation

In Vyper 0.4 some of the .vy files should be excluded from compiler input because they are not valid compilation targets. While we don't perform code analysis to detect those files automatically, the proposed workaround is to exclude them manually by specifying such files in foundry.toml.

For example, to compile snekmate, you'd have to add something like skip = ["**/*[!mock].vy"].

Solution

Move skip to CoreBuildArgs and respect configuration when constructing filter in forge test and forge build.

forge script and forge create should be fine as they only compile specific target, but will do some more testing around it, so marking as wip

cc @pcaversaccio

klkvr added a commit to foundry-rs/compilers that referenced this pull request Jun 5, 2024
better approach for foundry-rs/foundry#8061

We already keep all compilation settings on `Project` (paths, compier
settings, compiler itself), so this PR moves `sparse_output` to
`Project` as well to allow us to just configure it in `Config::project`
instead of adding it to compiler on every invocation in multiple places.

Also this PR gets rid of separate `SparseOutputFileFilter<D>` trait and
makes `sparse_output` filter just a `FileFilter` again. Instead, we now
have `ParsedSource::compilation_dependencies` which determines which of
the source imports must be compiled along with it.

Simplified some sparse output related logic along with changes.

Due to `Box<dyn FileFilter>` on `Project` this PR adds `dyn-clone` to
keep `Clone` impl and `derivative` to avoid manually implementing
`Debug`
@klkvr klkvr marked this pull request as ready for review June 5, 2024 23:02
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, having skip support in foundry.toml is nice

/// Matches file only if the filter does not apply.
///
/// This returns the inverse of `file.name.contains(pattern) || matcher.is_match(file)`.
fn is_match_exclude(matcher: &GlobMatcher, path: &Path) -> bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be moved in impl GlobMatcher ?

crates/forge/bin/cmd/build.rs Outdated Show resolved Hide resolved
@klkvr klkvr merged commit 729a766 into master Jun 6, 2024
20 checks passed
@klkvr klkvr deleted the klkvr/skip-in-config branch June 6, 2024 17:06
pcaversaccio added a commit to pcaversaccio/snekmate that referenced this pull request Jun 9, 2024
### 🕓 Changelog

The Foundry PR foundry-rs/foundry#8061 added the
`skip` key to `foundry.toml`, which can be used to configure skipping
compilation of non-compilable files. We use this new feature to only
compile 🐍 snekmate mock contracts. In addition, the Foundry PR
foundry-rs/foundry#8086 added a Vyper
configuration section `vyper` to `foundry.toml` which allows to
configure the attributes `optimize` and `path`. We set the `optimize`
mode to the compiler default value `gas`.

---------

Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
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.

2 participants