
rust - Could not find `Cargo.toml` when building a dependent …
2015年7月22日 · It turns out I had created all my rust packages(aka projects) up to that point using cargo new project-name --bin as shown here, thus by default including Cargo.lock, Cargo.toml, and src folder. Hopefully, it is clear by now that mine was just a simple rookie mistake; I simply, quite literally, didn't have Cargo.toml in my project
How do I use conditional compilation with `cfg` and Cargo?
2014年12月24日 · Alternatively, you could create a cargo configuration file in your project, by creating a .cargo subdir in your project main folder, adding in it a config.toml file, then inserting this section in .cargo/config.toml: [build] rustflags = "--cfg my_cfg_flag" This will make cargo call rustc with flags --cfg my_cfg_flag
How do I set environment variables with Cargo? - Stack Overflow
2019年7月13日 · This is not the same file as Cargo.toml, but it can still be set per project: [env] FOO = "bar" PATH_TO_SOME_TOOL = { value = "bin/tool", relative = true } USERNAME = { value = "test_user", force = true } Environment variables set in this section will be applied to the environment of any processes executed by Cargo.
rust - How to specify the path to a Cargo.toml - Stack Overflow
2016年2月1日 · The --manifest-path path/to/Cargo.toml option to almost all cargo subcommands allows pointing it to a specific Cargo.toml file to use, overriding the default of searching the current directory and its parents for a file called Cargo.toml (this file is the "manifest").
Cargo.toml OS Dependency for Crate - Stack Overflow
2016年10月27日 · This looks like a cargo bug to me. One related issue is Cannot declare different version of dependencies in mutually exclusive targets #3195 Edit: It is more of an unsupported feature than a bug according to the code .
How can I build multiple binaries with Cargo? - Stack Overflow
2016年4月13日 · You can run individual binaries with the cargo run command with the --bin <bin-name> option. Tip: If you instead put these files in src/bin/daemon.rs and src/bin/client.rs , you'll get two executables named daemon and client as Cargo compiles all files in src/bin into executables with the same name automatically.
How can I set default build target for Cargo? - Stack Overflow
2018年3月23日 · If you're able to use unstable features, following documentation and especially per-package-target feature add this to you crate manifest that usually named Cargo.toml. cargo-features = ["per-package-target"] [package] forced-target = "wasm32-unknown-unknown" # and/or: default-target = "wasm32-unknown-unknown" This requires nightly toolchain.
How to specify the exact version of a dependency?
$ cargo --version cargo 0.21.0-beta (7e00b82d9 2017-07-17) I created a simple project with cargo new --bin test1, and then I added a dependency: [dependencies] lazy_static = "0.2.2" to Cargo.toml (according to this such version exists) and #[macro_use] extern crate lazy_static; to src/main.rs. When I run cargo build:
rust - How to pass rustc flags to cargo? - Stack Overflow
2016年6月26日 · cargo rustc, which only affects your crate and not its dependencies. The RUSTFLAGS environment variable, which affects dependencies as well. Some flags have a proper Cargo option, e.g., -C lto and -C panic=abort can be specified in the Cargo.toml file. Add flags in .cargo/config using one of the rustflags= keys.
rust - How to define test-only dependencies? - Stack Overflow
2015年4月24日 · From the Cargo docs: You can add a [dev-dependencies] section to your Cargo.toml whose format is equivalent to [dependencies]: [dev-dependencies] tempdir = "0.3" Dev-dependencies are not used when compiling a package for building, but are used for compiling tests, examples, and benchmarks.