[package]
name = "cyme"
authors = ["John Whittington <john@jbrengineering.co.uk>"]
description = "List system USB buses and devices. A modern cross-platform lsusb"
repository = "https://github.com/tuna-f1sh/cyme"
readme = "README.md"
license = "GPL-3.0-or-later"
rust-version = "1.82"
version = "2.2.11"
edition = "2021"
keywords = ["usb", "lsusb", "system_profiler", "macos", "libusb"]
categories = ["command-line-utilities"]
exclude = [".github", "scripts"]

[dependencies]
clap = { version = "4.0.22", features = ["derive", "wrap_help"] } # CLI argument parsing
clap_complete = { version = "4.0.6", optional = true } # CLI completions
clap_mangen = { version = "0.2.5", optional = true } # for generating man - could manually do this
colored = "3.0.0" # terminal colouring helper
cansi = { version = "=2.2.1", optional = true } # ANSI escape code helper; decolored - no dependencies
itertools = "0.10.5" # iterator methods used for building device tree
rusb = { version = "0.9.4", optional = true } # libusb bindings
nusb = { version = "0.2.1", optional = true } # pure Rust USB library
serde = { version = "1.0", features = ["derive"] } # --json serialisation and --from-json deserialisation
serde_json = "1.0.87"
serde_with = "2.0.1"
log = "0.4.17"
simple_logger = { version = "4.0.0", features = ["stderr"], optional = false } # perhaps make this optional in the future; only required by bin targets
usb-ids = { version = "1" } # USB ID database
heck = "0.4.0" # common case conversions - could be internal but simple crate with no dependencies
dirs = "6.0.0" # cross-platform XDG_CONFIG_HOME - could be internal since only this path
fastrand = "2.1.1" # fast random number generator for masking serials
terminal_size = "0.2.5" # terminal size for automatic column width during display
strum = "0.26" # enum to string conversion
strum_macros = "0.26" # enum to string conversion
regex = { version = "1.10.5", optional = true } # icon name lookup with regex
uuid = { version = "1.9.1", features = ["serde"] } # descriptor UUID field support as type
pci-ids = "0.2.5" # PCI ID database
unicode-width = "0.2.0" # ensure USB device table is printed with equal width columns - zero dependencies
crossterm = { version = "0.28.1", optional = true } # watch: terminal manipulation
futures-lite = { version = "2.6.0", optional = true } # watch: async helper
chrono = { version = "0.4.39", features = ["serde"] } # watch: event times as human readable

[dev-dependencies]
diff = "0.1"
assert-json-diff = "2.0.2"
criterion = "0.5.1"

[target.'cfg(target_os="linux")'.dependencies]
glob = "0.3.3" # find block devices in USB syspath
udevrs = { version = "^0.4.0", optional = true }
udevlib = { package = "udev", version = "^0.8.0", optional = true }

[target.'cfg(target_os="macos")'.dependencies]
core-foundation = "0.10.1"
core-foundation-sys = "0.8.4"
io-kit-sys = "0.4.0"

[features]
libusb = ["dep:rusb"] # libusb bindings rather than nusb Rust
udev = ["dep:udevrs"] # udev device info lookup
udev_hwdb = ["udevlib?/hwdb"] # udev hardware database lookup rather than usb-ids
udevlib = ["dep:udevlib"] # udev libc bindings rather than Rust
usb_test = [] # testing with physical USB devices
regex_icon = ["dep:regex"] # icon name lookup with regex
cli_generate = ["dep:clap_complete", "dep:clap_mangen"] # for generating man and completions
native = ["nusb", "udev"] # pure Rust USB and udev bindings
ffi = ["libusb", "udevlib"] # C bindings for libusb and libudev
watch = ["crossterm", "futures-lite", "nusb", "cansi"] # watch mode
bin = []
default = ["native", "regex_icon", "watch", "bin"] # default native Rust USB (nusb, udevrs) with regex icon name lookup

[[bin]]
name = "cyme"
path = "src/main.rs"

[[bench]]
name = "get"
harness = false

[[bench]]
name = "profile"
harness = false

[profile.release]
lto = true
strip = true
panic = "abort"
codegen-units = 1 # quicker binary, slower build

[package.metadata.cross.target.arm-unknown-linux-gnueabihf]
pre-build = ["dpkg --add-architecture armhf && apt-get update && apt-get install --assume-yes libusb-1.0-0-dev:armhf libudev-dev:armhf"]

[package.metadata.cross.target.aarch64-unknown-linux-gnu]
pre-build = ["dpkg --add-architecture arm64 && apt-get update && apt-get install --assume-yes libusb-1.0-0-dev:arm64 libudev-dev:arm64"]

[package.metadata.cross.target.i686-unknown-linux-gnu]
pre-build = ["dpkg --add-architecture i386 && apt-get update && apt-get install --assume-yes libusb-1.0-0-dev:i386 libudev-dev:i386"]

[package.metadata.cross.target.x86_64-unknown-linux-gnu]
pre-build = ["apt-get update && apt-get install --assume-yes libusb-1.0-0-dev libudev-dev"]

[package.metadata.cross.target.aarch64-linux-android]
image = "ghcr.io/cross-rs/aarch64-linux-android:main"

[package.metadata.deb]
section = "utility"
copyright = "2024, John Whittington <john@jbrengineering.co.uk>"
changelog = "CHANGELOG.md"
extended-description = """Profiles system USB buses and the devices on those buses, including full device descriptors. Compatible with lsusb arguments and output whilst adding new features."""
assets = [
  ["target/release/cyme", "usr/bin/", "755"],
  ["README.md", "usr/share/doc/cyme/README", "644"],
  ["doc/cyme.1", "/usr/share/man/man1/cyme.1", "644"],
]
