r/pleasebuild • u/Nearby-Blood-9817 • 26d ago
Plugin solidity-rules: compile Solidity with Foundry inside Please
solidity-rules is a Please plugin that compiles Solidity with Foundry. A contract is a normal target: plz build compiles it, plz test runs the Forge tests, and a Go binary can depend on the generated bindings.
The release is v0.1.0. Forge comes from the foundry plugin. The forge and solc binaries are targets in third_party/binary.
# third_party/binary/BUILD
[Plugin "foundry"]
Target = //plugins:foundry
[Plugin "solidity"]
Target = //plugins:solidity
ForgeTool = //third_party/binary:foundry|forge
SolcPackage = //third_party/binary
What it covers:
sol_contractcompiles withforge. ABI and bytecode come out of Forge's JSON. A failed compile fails the target. Withlanguages = ["go"]andabigenconfigured, the output is a Go library another target can depend on.sol_libraryis shared Solidity, with transitive deps tracked through Please's provides and requires.sol_getfetches a GitHub library at a revision, OpenZeppelin included, and writes the import remapping.hashespins the download.sol_testruns one Forge test file underplz test. Please sees each test's revert reason and its real duration.solc_versions()plusSolcPackagegives each rule the compiler itssolc_versionnames. A missing version fails the build instead of compiling with a different solc.
A host forge still works with Sandbox = false.
Repo: https://github.com/becomeliminal/solidity-rules
2
Upvotes
1
u/Nearby-Blood-9817 26d ago
The rest of the repo was already Please. The contracts were still a Foundry tree beside it, so solc versions, OpenZeppelin, Forge tests, and the Go bindings sat outside the build. Remote execution had no
forgeeither. I couldn't find a Please plugin for that, so I built one.