Git Product home page Git Product logo

Comments (8)

epage avatar epage commented on June 18, 2024 1

“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.

epage avatar epage commented on June 18, 2024 1

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.

weihanglo avatar weihanglo commented on June 18, 2024

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.

CamJN avatar CamJN commented on June 18, 2024

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.

weihanglo avatar weihanglo commented on June 18, 2024

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.

weihanglo avatar weihanglo commented on June 18, 2024

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.

weihanglo avatar weihanglo commented on June 18, 2024

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.

epage avatar epage commented on June 18, 2024

I concur

from cargo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.