[workspace]
members = ["petname-macros"]

[workspace.package]
authors = ["Gavin Panella <gavin@allenap.me>"]
edition = "2021"
license = "Apache-2.0"
version = "3.0.1"
repository = "https://github.com/allenap/rust-petname"

[package]
name = "petname"
categories = ["command-line-utilities", "no-std"]
description = "Generate human readable random names. Usable as a library and from the command-line."
keywords = ["pet", "name", "rand", "random", "generator"]
readme = "README.md"
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true

[lib]
name = "petname"
path = "src/lib.rs"

[[bin]]
doc = false
name = "petname"
path = "src/main.rs"
required-features = ["clap", "default-rng", "default-words"]

[features]
# `clap` is NOT required for the library but is required for the command-line
# binary. Omitting it from the `default` list means that it must be specified
# _every time_ you want to build the binary, so it's here as a convenience.
default = ["clap", "default-rng", "default-words", "macros"]
# Allows generating petnames with thread rng.
default-rng = ["rand/thread_rng"]
# Allows the default word lists to be used.
default-words = ["macros"]
# Provides the `petnames!` proc macro.
macros = ["dep:petname-macros"]
# Compiles the Turkish generator and enables `--language turkish`. The built-in
# Turkish word lists (`Turkish::small`) are embedded only when `default-words` is
# also enabled, just like the English lists.
lang-turkish = []

[dev-dependencies]
anyhow = "1"
rand_core = "0.10"
tempfile = "3"

[dependencies]
petname-macros = { version = "3.0.0", path = "petname-macros", optional = true }
clap = { version = "4", features = ["cargo", "derive"], optional = true }
rand = { version = "0.10", default-features = false }

[package.metadata.binstall]
pkg-fmt = "bin"

[package.metadata.docs.rs]
# Build with every feature so that gated items (e.g. the Turkish generator) are
# documented, and set `--cfg docsrs` so that `doc_cfg` (see `src/lib.rs`) labels
# each with the feature that enables it.
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
# Limit docs.rs builds to a single tier one target, because they're identical on
# all. https://blog.rust-lang.org/2020/03/15/docs-rs-opt-into-fewer-targets.html
targets = ["x86_64-unknown-linux-gnu"]

# `docsrs` is a custom cfg set only by the docs.rs build (and local doc builds
# that opt in); declare it so that the `unexpected_cfgs` lint stays quiet.
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs)'] }

# Follow some of the advice from https://github.com/johnthagen/min-sized-rust on
# how to minimise the compiled (release build) binary size. At the time of
# writing this reduces the binary from ~6MiB to ~2MiB.
[profile.release]
lto = true
opt-level = "z"
strip = true
