Comments (8)
“cleaner" syntax that requires hoops to use seems an odd trade off.
The new syntax was created to allow us to more easily add new directives. Using them will require MSRV bumps, so requiring an MSRV bump to use the new syntax seems fairly reasonable.
from cargo.
imo for #12432, there still wouldn't be reason to support both syntaxes. The situation isn't too different whether others do it or we do it. Instead, we'd likely support the old syntax for any pre-existing directives and new syntax for any new directives until we drop the old syntax from our MSRV.
The main thing I could see doing with version detection is letting users know if a directive is supported so they can fallback to an alternative.
from cargo.
so that I can output the correct syntax and not bump my required rust version to
1.77
.
Could you elaborate what do "I" refer to here, and who is going to consume the proposed environment? A more detailed use case would help.
Assuming it is a crate like cc
printing build script invocations. If cc
is going to emit new cargo::
syntax unconditionally, it might want to bump rust-version
to 1.77 as well. Alternatively it can have a cargo feature, say 1_77_new_syntax
, to enable it and any new build script invocations built upon the new syntax.
from cargo.
I is me, or I suppose anyone who wants to write a build.rs that emits the old syntax for versions of cargo < 1.77 and the new syntax for versions >= 1.77. In my case the build.rs' are for my *-sys crate, and its safe wrapper crate.
Cargo features must be manually enabled/disabled by users of the crate, if the default doesn't match their setup right? That's not very nice IMO, they shouldn't have to know about the internals of my build.rs and its cargo/rust version compatibility, I'd rather just make it automatic.
As for the use case, there's not really a lot more detail to provide, but I'll re-phrase it a bit in case that's useful:
I want to be able to write a build.rs that can emit the old syntax for old versions of cargo/rust and the new syntax for new versions. I don't want to use the old syntax when the new syntax is available because the new syntax is nice and clearer. However I also don't want to require users of my crate to use rust 1.77 right away, since this cargo syntax is the only thing that I use from 1.77, so I'd like to emit it conditionally, predicated on which version of cargo is going to parse the output of build.rs.
from cargo.
Thanks for the clarification!
This looks like an issue that could be addressed if Cargo provides a crate for build script with that ability. #12432 is the issue tracking it.
Today you could use some helper crates to detect the toolchain version, like https://crates.io/crates/rustversion.
from cargo.
The main thing I could see doing with version detection is letting users know if a directive is supported so they can fallback to an alternative.
Yes this is exactly what I meant.
from cargo.
Going to propose to close this. We will track the official build script API for version detection in #12432, and people for now can depend on crates like rustversion on crates.io.
from cargo.
I concur
from cargo.
Related Issues (20)
- `cargo add` should maintain sorting of features HOT 3
- Improve workspace resolver error message when root edition is missing HOT 9
- Improve Workspaces docs page HOT 1
- Normal dependencies get ignored if they're mentioned after platform specific dependencies HOT 2
- cargo new and VSC inconsistency HOT 2
- Not reproducible when a project is copied to another directory HOT 1
- Not reproducible when a project is copied to another directory HOT 2
- `cargo vendor --sync` fails inconsistently, depending on workspaces used or not.
- Support different versions of the same dependency within a workspace HOT 6
- `test` is not set when `crate-type` is `lib` or `rlib` HOT 3
- -Z build-std prevents build.rs recompilation HOT 5
- `cargo vendor` failed for git targets when realpath of`~/.cargo/git` includes softlink
- Exclude all non-members from workspace HOT 1
- Minor grammar error in `cargo --help` output
- Vendored crate with git submodule may have something wrong with gitignore
- cargo rustc --version should print the version of rustc called by cargo HOT 8
- Augment Cargo metadata and output for app-bundle post-processing
- Credential provider protocol fails with strings containing escaped characters
- Automatic `strip = "debuginfo"` in release mode does not work when using `--target` flag HOT 2
- Cargo shouldn't set `/WX` (`-Werror` for MSVC linker) outside of CI HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo.