rust-cargo

cargo ssl download error behind proxy on windows

六眼飞鱼酱① 提交于 2019-12-05 04:52:42
问题 I cannot get cargo to commence any downloads under windows behind an authenticated proxy. Here are my proxy settings:- C:\Users\ukb99427\Downloads λ set | grep http https_proxy=http://user:pass@corporate.proxy:8080 http_proxy=http://user:pass@corporate.proxy:8080 Note the http s _proxy has a http address. This allows something like git and incidentally rustup-init and rustup to work fine. Output from those are λ rustup update info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'

How to generate Cargo.lock based on last month's crates.io?

安稳与你 提交于 2019-12-05 03:28:49
I want to create a Cargo.lock file in a Rust project from Cargo.toml based on what was available on 22 Feb 2017. I need to make version selection compatible to what would happen on that specific day. (No, don't have a version controlled Cargo.lock around somewhere.) I tried this to no avail: Clone the crates.io index into a local directory and check out an older commit that matches the desired date. Use the following lines in .cargo/config: [source.mycrates] registry = "file:///path/to/crates.io-index" # contains old checkout [source.crates-io] replace-with = "mycrates" Nevertheless, cargo

Copy files to the target directory after build

时光怂恿深爱的人放手 提交于 2019-12-05 02:53:15
Let's assume I have a game with the following directory structure: /src /resources Cargo.toml I would like cargo build to copy the files in the resources directory and paste them in the same directory as the executable file. I know it is possible to do this using a custom build script, but this seems to be a common case that deserves special treatment. So the question is: does cargo provide a standard way of copying files to the target directory (using just Cargo.toml )? 来源: https://stackoverflow.com/questions/31080757/copy-files-to-the-target-directory-after-build

How to emit LLVM-IR from Cargo

我的未来我决定 提交于 2019-12-05 01:05:00
How can I get cargo to emit LLVM-IR instead of a binary for my project? I know that you can use the --emit=llvm-ir flag in rustc , but I've read some Github issues that show it's impossible to pass arbitrary compiler flags to cargo. Is there any way I can get cargo to emit LLVM-IR directly? Jacob There is cargo rustc to pass arbitrary compiler flags through Cargo to rustc . So I think: cargo rustc -- --emit=llvm-ir is what you want! EDIT: You should use Jacob's answer instead; a lot easier and less hacky. Build the project with cargo normally but add on the -v flag to show verbose output. The

How to tell Cargo to use a git repository as source for an indirect dependency instead of crates.io?

巧了我就是萌 提交于 2019-12-05 00:44:15
A few days ago , cross-compiling to JavaScript via Emscripten has finally hit nightly. I wanted to compile a project using glium in that manner. However, there are still many Emscripten-related bugs in many crates. While maintainers usually fix those bugs quickly, they don't necessarily release those bug fixes to crates.io immediately. In my case, glium depends on glutin . glutin had a bug which is fixed now, but only in the git repository, not on crates.io . Note : glutin is not a direct dependency of my project; only an indirect one through glium ! How do I tell Cargo to use the glutin

Consolidating cargo dependencies

試著忘記壹切 提交于 2019-12-05 00:27:59
I have a project that has a dependency (a cookie utility) that has a dependency on iron >= 0.3, <= 0.4 . My project has a dependency on iron 0.3 (so I can use the router middleware that hasn't yet been updated to the latest iron). When I try to compile my project, the cookie utility pulls the 0.4 version of iron, and I get errors since different versions of iron are being used. However, I can do: cargo update -p <cookie utility> which (usually) changes that package's dependency on iron to match the one I am using, and removes the extraneous dependency on iron 0.4 . (Bizarrely, I sometimes have

How to get assembly output from building with Cargo?

廉价感情. 提交于 2019-12-04 08:19:11
问题 While I've seen docs on using rustc directly to output assembly, having to manually extract commands used by Cargo and edit them to write assembly is tedious. Is there a way to run Cargo that writes out assembly files? 回答1: You can use Cargo's cargo rustc command to send arguments to rustc directly: cargo rustc -- --emit asm ls target/debug/deps/crate_name.s For optimized assembly: cargo rustc --release -- --emit asm ls target/release/deps/crate_name.s 回答2: In addition to kennytm's answer,

How can I force `build.rs` to run again without cleaning my whole project?

半城伤御伤魂 提交于 2019-12-04 07:30:45
How can I force build.rs to run again without cleaning my whole project? I checked cargo build --help but I couldn't find anything related to build.rs . If you print "cargo:rerun-if-changed=<FILE>" the build will be triggered every time the file has changed. rerun-if-changed=PATH is a path to a file or directory which indicates that the build script should be re-run if it changes (detected by a more-recent last-modified timestamp on the file). Normally build scripts are re-run if any file inside the crate root changes, but this can be used to scope changes to just a small set of files. --

Should end user utilities/applications be registered on crates.io?

萝らか妹 提交于 2019-12-04 07:29:51
Is it acceptable to register generally useful (utilities / applications) on crates.io ? The FAQ doesn't address this and from browsing, there are examples of end-user applications (mostly command line tools). Or is crates.io? meant only for libraries? I'm asking this because the documentation hints at library use, semantic versioning for API's etc. but doesn't reference the case for packaging applications explicitly. Yes, because you can use cargo install to install and manage those applications system-wide. If this use were discouraged, I would suspect that command to not exist at all, or at

How difficult is it to allow parallel compilation of code with the Rust stable and nightly channels?

社会主义新天地 提交于 2019-12-04 03:03:47
问题 The default file-tree created by Cargo allows parallel compilation of release and debug builds as they are located in their own directories; target/release and target/debug , respectively. How difficult is it to also allow parallel compilation of stable / nightly -compiler. For example using the directories target/debug/stable target/debug/nightly I am aware it can be done with jails/containers, but I was hoping for a somewhat more Cargo-ish solution. 回答1: Modern Rust I believe that your main