Originally posted by lowflyer
View Post
Originally posted by lowflyer
View Post
Here is an example `Cargo.toml` adapted from https://github.com/cargo-bins/cargo-...in/Cargo.toml:
Code:
[package] name = "cargo-binstall" description = "Rust binary package installer for CI integration" repository = "https://github.com/cargo-bins/cargo-binstall" version = "0.23.1" rust-version = "1.65.0" authors = ["ryan <[email protected]>"] edition = "2021" license = "GPL-3.0" [dependencies] binstalk = { path = "../binstalk", version = "0.12.1", default-features = false } binstalk-manifests = { path = "../binstalk-manifests", version = "0.5.0" } clap = { version = "4.3.0", features = ["derive", "env"] } compact_str = "0.7.0" dirs = "5.0.1" file-format = { version = "0.17.0", default-features = false } fs-lock = { version = "0.1.0", path = "../fs-lock" } gh-token = "0.1.2" log = { version = "0.4.18", features = ["std"] } miette = "5.9.0" mimalloc = { version = "0.1.37", default-features = false, optional = true } once_cell = "1.18.0" semver = "1.0.17" strum = "0.24.1" strum_macros = "0.24.3" supports-color = "2.0.0" tempfile = "3.5.0" tokio = { version = "1.28.2", features = ["rt-multi-thread"], default-features = false } tracing-core = "0.1.31" tracing = { version = "0.1.37", default-features = false } tracing-log = { version = "0.1.3", default-features = false } tracing-subscriber = { version = "0.3.17", features = ["fmt", "json", "ansi"], default-features = false } [features] default = ["static", "rustls", "trust-dns", "fancy-no-backtrace", "zstd-thin"] mimalloc = ["dep:mimalloc"] static = ["binstalk/static"] pkg-config = ["binstalk/pkg-config"] zlib-ng = ["binstalk/zlib-ng"] rustls = ["binstalk/rustls"] native-tls = ["binstalk/native-tls"] trust-dns = ["binstalk/trust-dns"] zstd-thin = ["binstalk/zstd-thin"] cross-lang-fat-lto = ["binstalk/cross-lang-fat-lto"] fancy-no-backtrace = ["miette/fancy-no-backtrace"] fancy-with-backtrace = ["fancy-no-backtrace", "miette/fancy"] log_max_level_info = ["log/max_level_info", "tracing/max_level_info", "log_release_max_level_info"] log_max_level_debug = ["log/max_level_debug", "tracing/max_level_debug", "log_release_max_level_debug"] log_release_max_level_info = ["log/release_max_level_info", "tracing/release_max_level_info"] log_release_max_level_debug = ["log/release_max_level_debug", "tracing/release_max_level_debug"] [profile.release] opt-level = "z" lto = true codegen-units = 1 panic = "abort" strip = "symbols"
Some dependencies have both `path` and `version` because they are developed in the same repository, so in the CI, they would use the version found in path.
When installing from crates.io on end-user machine, they will use the `version` pulled from crates.io
You might also notice some dependencies have `features` and `default-features` to control what feature is provided.
In cargo, features are designed to be addictive and all features enabled on the same package will be merged, so the package will built once with all features enabled across all dependencies and current package.
`features` section describes features provided by the current package, it can be used to either enable optional dependencies or features of dependencies, or include more code using the `cfg(features = "...")` conditional compilation, which can also use `all(feature = ..., feature = ...)`, `any(...)` plus `cfg(unix)`, `cfg(windows)`, etc.
Finally, section `profile.release` specifies the compilation flags for release, including optimization level, whether to use lto ("lto = true" enables fat lto, 'lto = "thin"' enables thin lto).
Comment