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

New: Allow skipping the clap dependency via the cli feature. #39

Merged
merged 3 commits into from
Jun 4, 2022

Conversation

dbanty
Copy link
Contributor

@dbanty dbanty commented Jun 2, 2022

No description provided.

@dbanty
Copy link
Contributor Author

dbanty commented Jun 2, 2022

I actually don't know if the cfg is required here... or what would happen if you tried to build the binary without the feature enabled.

@dbanty dbanty requested review from nilslice and kalzoo June 2, 2022 23:45
@nilslice
Copy link
Contributor

nilslice commented Jun 3, 2022

Good call making this optional.

I actually don't know if the cfg is required here... or what would happen if you tried to build the binary without the feature enabled.

I think we'd want cargo build to fail if the cli feature is disabled, with some way of informing the user of the fix. Now, this would fail, but with a message like "consider adding a 'main' function" or somehting.

We could technically do something like this in main.rs:

#[cfg(not(feature = "cli"))]
compile_error!("the feature 'cli' must be enabled to build the qcs-sdk-qir CLI");

I've tested & pushed up this addition, but feel free to change as you see fit.

Copy link
Contributor

@nilslice nilslice left a comment

Choose a reason for hiding this comment

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

Looks good to me, pending any different ideas/thoughts for the compile_error! usage from @dbanty or @kalzoo

@Shadow53
Copy link
Contributor

Shadow53 commented Jun 3, 2022

FWIW, there is a way to specify that a certain target (e.g. a binary) requires certain features. Maybe that is better here?

@nilslice
Copy link
Contributor

nilslice commented Jun 3, 2022

@Shadow53 - good call, & TIL! If you'd like to update the PR, please feel free 👍

@Shadow53
Copy link
Contributor

Shadow53 commented Jun 3, 2022

Updated:

$ cargo build --bin main --no-default-features
error: target `main` in package `qcs-sdk-qir` requires the features: `cli`
Consider enabling them by passing, e.g., `--features="cli"`

@dbanty dbanty merged commit 8c620f3 into main Jun 4, 2022
@dbanty dbanty deleted the make-cli-optional branch June 4, 2022 17:07
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.

3 participants