near / cargo-near

Cargo extension for building Rust smart contracts on NEAR
Apache License 2.0
33 stars 16 forks source link

Support passing feature flags to `cargo` invocation #160

Closed encody closed 4 months ago

encody commented 4 months ago

Adds support for passing feature flags to cargo.

Motivation

Smart contract developers will sometimes use feature flags to enable/disable certain portions of code during compilation (e.g. enable certain debugging features for the testnet version which are not available in the production version).

Usage

cargo near build --features feat1,feat2
cargo near build --no-default-features

Implementation Notes

It does no validation of the input received to the flag, transparently forwarding it as an opaque string directly to cargo, after appending near-sdk/__abi-embed if necessary.

frol commented 4 months ago

@encody Hey, @dj8yfo flagged that this PR forgot to pass the feature flags to the ABI generation code:

https://github.com/near/cargo-near/blob/358ce04ba0383e2a837c1c6fc99ec512379b061e/cargo-near/src/commands/abi_command/abi.rs#L87-L89

Could you contribute the fix, so this feature is complete?