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

Add no_cargo feature to disable Cargo-env-var-dependent macros #786

Merged
merged 1 commit into from
Dec 28, 2016
Merged

Add no_cargo feature to disable Cargo-env-var-dependent macros #786

merged 1 commit into from
Dec 28, 2016

Conversation

nabijaczleweli
Copy link
Contributor

For example, given:

clap = { path = "t:/clap-rs" }

The macros crate_version!() and crate_authors!() exist, so the crate compiles without errors:

   Compiling https v0.2.0 (file:///P:/Rust/http)
    Finished debug [unoptimized + debuginfo] target(s) in 6.93 secs
    Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
[Finished in 7.5s]

But, adding the no_cargo feature:

clap = { path = "t:/clap-rs", features = ["no_cargo"] }

The macros are removed, so the crate fails to compile:

   Compiling clap v2.19.2 (file:///T:/clap-rs)
   Compiling https v0.2.0 (file:///P:/Rust/http)
error: macro undefined: 'crate_version!'
  --> src\options.rs:40:22
   |
40 |             .version(crate_version!())
   |                      ^^^^^^^^^^^^^

error: macro undefined: 'crate_authors!'
  --> src\options.rs:41:21
   |
41 |             .author(crate_authors!())
   |                     ^^^^^^^^^^^^^

error: aborting due to 2 previous errors

error: Could not compile `https`.

Closes #783

a.p.meta.author = Some(crate_authors!());
a.p.meta.version = Some(crate_version!());
a.p.meta.author = Some("Kevin K. <kbknapp@gmail.com>");
a.p.meta.version = Some("2.19.2");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Set these values to what they'd evaluate to anyway, BTW.

@nabijaczleweli
Copy link
Contributor Author

?r @kbknapp

Paging @acmcarther, too, because he requested the feature

@nabijaczleweli nabijaczleweli changed the title feat(no_cargo): add no_cargo feature to disable Cargo-env-var-dependent macros Add no_cargo feature to disable Cargo-env-var-dependent macros Dec 27, 2016
@coveralls
Copy link

coveralls commented Dec 27, 2016

Coverage Status

Coverage increased (+0.05%) to 91.166% when pulling 907bba5 on nabijaczleweli:feat/783-no_cargo into eb1d79d on kbknapp:master.

@kbknapp
Copy link
Member

kbknapp commented Dec 27, 2016

Excellent! I hadn't thought of doing the reverse (the feature removes something), that's a mistake on my part.

For the 3.x changes I'd still like to make this feature additive, but for now this works great.

@coveralls
Copy link

coveralls commented Dec 27, 2016

Coverage Status

Coverage increased (+0.05%) to 91.166% when pulling 907bba5 on nabijaczleweli:feat/783-no_cargo into eb1d79d on kbknapp:master.

@acmcarther
Copy link

This is great! Yes, actually what I'd had in mind was something like this, but I figured I could wait for whatever form would be most appropriate for this project.

Thanks @nabijaczleweli!

@kbknapp
Copy link
Member

kbknapp commented Dec 27, 2016

@homu r+

@homu
Copy link
Contributor

homu commented Dec 27, 2016

📌 Commit 907bba5 has been approved by kbknapp

homu added a commit that referenced this pull request Dec 27, 2016
Add no_cargo feature to disable Cargo-env-var-dependent macros

For example, given:

```toml
clap = { path = "t:/clap-rs" }
```

The macros `crate_version!()` and `crate_authors!()` exist, so the crate compiles without errors:

```
   Compiling https v0.2.0 (file:///P:/Rust/http)
    Finished debug [unoptimized + debuginfo] target(s) in 6.93 secs
    Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
[Finished in 7.5s]
```

But, adding the `no_cargo` feature:

```toml
clap = { path = "t:/clap-rs", features = ["no_cargo"] }
```

The macros are removed, so the crate fails to compile:

```
   Compiling clap v2.19.2 (file:///T:/clap-rs)
   Compiling https v0.2.0 (file:///P:/Rust/http)
error: macro undefined: 'crate_version!'
  --> src\options.rs:40:22
   |
40 |             .version(crate_version!())
   |                      ^^^^^^^^^^^^^

error: macro undefined: 'crate_authors!'
  --> src\options.rs:41:21
   |
41 |             .author(crate_authors!())
   |                     ^^^^^^^^^^^^^

error: aborting due to 2 previous errors

error: Could not compile `https`.
```

Closes #783
@homu
Copy link
Contributor

homu commented Dec 27, 2016

⌛ Testing commit 907bba5 with merge 598ba6c...

homu added a commit that referenced this pull request Dec 27, 2016
Add no_cargo feature to disable Cargo-env-var-dependent macros

For example, given:

```toml
clap = { path = "t:/clap-rs" }
```

The macros `crate_version!()` and `crate_authors!()` exist, so the crate compiles without errors:

```
   Compiling https v0.2.0 (file:///P:/Rust/http)
    Finished debug [unoptimized + debuginfo] target(s) in 6.93 secs
    Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
[Finished in 7.5s]
```

But, adding the `no_cargo` feature:

```toml
clap = { path = "t:/clap-rs", features = ["no_cargo"] }
```

The macros are removed, so the crate fails to compile:

```
   Compiling clap v2.19.2 (file:///T:/clap-rs)
   Compiling https v0.2.0 (file:///P:/Rust/http)
error: macro undefined: 'crate_version!'
  --> src\options.rs:40:22
   |
40 |             .version(crate_version!())
   |                      ^^^^^^^^^^^^^

error: macro undefined: 'crate_authors!'
  --> src\options.rs:41:21
   |
41 |             .author(crate_authors!())
   |                     ^^^^^^^^^^^^^

error: aborting due to 2 previous errors

error: Could not compile `https`.
```

Closes #783
@homu
Copy link
Contributor

homu commented Dec 27, 2016

☀️ Test successful - status

@homu
Copy link
Contributor

homu commented Dec 27, 2016

👀 Test was successful, but fast-forwarding failed: 422 Required status check "coverage/coveralls" is pending.

@kbknapp kbknapp merged commit 6fdd2f9 into clap-rs:master Dec 28, 2016
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.

None yet

5 participants