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

Support passing feature flags to cargo invocation #160

Merged
merged 2 commits into from
May 3, 2024

Conversation

encody
Copy link
Contributor

@encody encody commented May 3, 2024

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.

@encody encody added the enhancement New feature or request label May 3, 2024
@encody encody requested a review from frol May 3, 2024 12:29
Copy link
Contributor

@frol frol left a comment

Choose a reason for hiding this comment

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

@encody Nice! Looks good to me. @dj8yfo Do you have any objections for merging it (given the context of #134)

@frol frol merged commit 358ce04 into main May 3, 2024
14 checks passed
@frol frol deleted the jacob/contract-features branch May 3, 2024 17:32
@frol frol mentioned this pull request May 3, 2024
@frol
Copy link
Contributor

frol commented May 4, 2024

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

let dylib_artifact = util::compile_project(
&crate_metadata.manifest_path,
&["--features", "near-sdk/__abi-generate"],

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

frol pushed a commit that referenced this pull request May 6, 2024
frol added a commit that referenced this pull request Jul 5, 2024
## 🤖 New release
* `cargo-near`: 0.6.2 -> 0.6.3

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.6.3](cargo-near-v0.6.2...cargo-near-v0.6.3)
- 2024-07-03

### Added
- Support passing feature flags to `cargo` invocation
([#160](#160))

### Fixed
- Also pass feature flags to ABI build step
([#161](#161))

### Other
- Updates near-cli-rs and cargo-near in the new project template to
latest versions ([#168](#168))
- Updated dependencies to the latest versions
([#167](#167))
- Updated "interactive_clap" to 0.2.10 (updated "flatten" parameter)
([#154](#154))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants