feat(`compilation`): allow selective compilation of sources with `--via-ir`, running tests and scripts without
Component
Forge
Describe the feature you would like
In a basic scenario I was able to selectively compile with --via-ir as follows using the --skip flag:
$ forge build --via-ir --skip tests scripts
or this should work in foundry.toml:
[profile.via-ir]
via-ir = true
skip = ["test/*", "script/*"]
[profile.test]
skip = ["src/*"]
and then:
$ FOUNDRY_PROFILE=via-ir forge build
$ FOUNDRY_PROFILE=test forge test
This appears to work in a basic Counter example but appears to not work in all cases e.g. https://github.com/uniswap/v4-core
cc @klkvr is there a better way to do this?
Additional context
Related: https://x.com/0xKaden/status/1846606449977532748 + https://x.com/emo_eth/status/1846645499358859469
$ FOUNDRY_PROFILE=via-ir forge build $ FOUNDRY_PROFILE=test forge test
this would work only if project is only deploying contracts through deployCode, otherwise during tests compilation contracts would still get compiled without via-ir
one approach which could allow such patterns is #8668 which would also require doing deployCode but without FOUNDRY_PROFILE stuff
and in combination with https://github.com/foundry-rs/compilers/issues/197 it could allow avoiding manual deployCode stuff
though both PRs are drafts which ended up quite complex so I've deprioritized them at some point
Marking as duplicate, there are other tickets that already capture this goal, see: https://github.com/foundry-rs/foundry/issues/7720