[package]
# --- Bumpversion match - do not reorder
name = "veilid-tools"
version = "0.4.3"
# ---
description = "A collection of baseline tools for Rust development use by Veilid and Veilid-enabled Rust applications"
resolver = "2"
repository.workspace = true
authors.workspace = true
license.workspace = true
edition.workspace = true
rust-version.workspace = true

[lib]
# staticlib for iOS tests, cydlib for android tests, rlib for everything else
crate-type = ["cdylib", "staticlib", "rlib"]
path = "src/lib.rs"

[[bin]]
name = "virtual_router"
path = "src/bin/virtual_router/main.rs"
required-features = ["virtual-router-bin"]

[features]
default = ["rt-tokio"]
rt-async-std = [
    "async-std",
    "async_executors/async_std",
    "rtnetlink/smol_socket",
]
rt-tokio = [
    "tokio",
    "tokio-util",
    "tokio-stream",
    "rtnetlink/tokio_socket",
    "async_executors/tokio_tp",
    "async_executors/tokio_io",
    "async_executors/tokio_timer",
]
rt-wasm-bindgen = [
    "async_executors/bindgen",
    "async_executors/timer",
    "ws_stream_wasm",
]

veilid_tools_android_tests = ["dep:paranoid-android"]
veilid_tools_ios_tests = ["dep:tracing", "dep:oslog", "dep:tracing-oslog"]
tracing = ["dep:tracing", "dep:tracing-subscriber", "tokio/tracing"]
debug-locks = []
debug-duration-timeout = []

virtual-network = []
virtual-network-server = [
    "dep:async-tungstenite",
    "dep:indent",
    "dep:ipnet",
    "dep:serde_yaml",
    "dep:validator",
    "dep:ws_stream_tungstenite",
    "dep:rand_chacha",
]
virtual-router-bin = [
    "tracing",
    "virtual-network-server",
    "dep:clap",
    "dep:time",
    "dep:bugsalot",
]

[dependencies]
tracing = { version = "0.1.40", features = [
    "log",
    "attributes",
], optional = true }
tracing-subscriber = { version = "0.3.18", features = [
    "env-filter",
    "time",
], optional = true }
log = { version = "0.4.22" }
eyre = "0.6.12"
static_assertions = "1.1.0"
serde = { version = "1.0.214", features = ["derive", "rc"] }
postcard = { version = "1.0.10", features = ["use-std"] }
cfg-if = "1.0.0"
thiserror = "1.0.63"
futures-util = { version = "0.3.30", default-features = false, features = [
    "alloc",
] }
futures_codec = "0.4.1"
parking_lot = "0.12.3"
async-lock = "3.4.0"
once_cell = "1.19.0"
stop-token = { version = "0.7.0", default-features = false }
rand = "0.8.5"
rand_core = "0.6.4"
backtrace = "0.3.71"
fn_name = "0.1.0"
range-set-blaze = "0.1.16"
flume = { version = "0.11.0", features = ["async"] }
imbl = { version = "3.0.0", features = ["serde"] }


# Dependencies for native builds only
# Linux, Windows, Mac, iOS, Android
[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies]
async-io = { version = "1.13.0" }
async-std = { version = "1.12.0", features = ["unstable"], optional = true }
bugsalot = { package = "veilid-bugsalot", version = "0.2.0", optional = true }
time = { version = "0.3.36", features = [
    "local-offset",
    "formatting",
], optional = true }
chrono = "0.4.38"
ctrlc = "^3"
futures-util = { version = "0.3.30", default-features = false, features = [
    "async-await",
    "sink",
    "std",
    "io",
] }
indent = { version = "0.1.1", optional = true }
libc = "0.2.155"
nix = { version = "0.27.1", features = ["user"] }
socket2 = { version = "0.5.7", features = ["all"] }
tokio = { version = "1.38.1", features = ["full"], optional = true }
tokio-util = { version = "0.7.11", features = ["compat"], optional = true }
tokio-stream = { version = "0.1.15", features = ["net"], optional = true }

ws_stream_tungstenite = { version = "0.14.0", optional = true }
async-tungstenite = { version = "0.28.0", optional = true }
clap = { version = "4", features = ["derive"], optional = true }
ipnet = { version = "2", features = ["serde"], optional = true }
serde_yaml = { package = "serde_yaml_ng", version = "^0.10.0", optional = true }
validator = { version = "0.19.0", features = ["derive"], optional = true }
rand_chacha = { version = "0.3.1", optional = true }

# Dependencies for WASM builds only
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
wasm-bindgen = "0.2.92"
js-sys = "0.3.70"
wasm-bindgen-futures = "0.4.42"
async_executors = { version = "0.7.0", default-features = false }
getrandom = { version = "0.2", features = ["js"] }
ws_stream_wasm = { version = "0.7.4", optional = true }
send_wrapper = { version = "0.6.0", features = ["futures"] }

# Dependencies for Linux or Android
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
rtnetlink = { version = "=0.13.1", default-features = false }
netlink-sys = { version = "=0.8.5" }
netlink-packet-route = { version = "=0.17.1" }

# Dependencies for Android
[target.'cfg(target_os = "android")'.dependencies]
jni = "0.21.1"
jni-sys = "0.3.0"
ndk = { version = "0.7.0" }
ndk-glue = { version = "0.7.0", features = ["logger"] }
lazy_static = "1.5.0"
paranoid-android = { version = "0.2.2", optional = true }
android_logger = "0.13.3"

# Dependencies for Windows
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3.9", features = ["iptypes", "iphlpapi", "winerror"] }

# Dependencies for iOS
[target.'cfg(target_os = "ios")'.dependencies]
oslog = { version = "0.2.0", optional = true }
tracing-oslog = { version = "0.1.2", optional = true }

# Dependenices for all Unix (Linux, Android, MacOS, iOS)
[target.'cfg(unix)'.dependencies]
ifstructs = "0.1.1"

### DEV DEPENDENCIES

[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dev-dependencies]
simplelog = { version = "0.12.2", features = ["test"] }
serial_test = "2.0.0"

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
serial_test = { version = "2.0.0", default-features = false, features = [
    "async",
] }
console_error_panic_hook = "0.1.7"
wasm-bindgen-test = "0.3.42"
wee_alloc = "0.4.5"
wasm-logger = "0.2.0"
tracing-wasm = { version = "0.2.1" }

### BUILD OPTIONS

[package.metadata.wasm-pack.profile.release]
wasm-opt = ["-O", "--enable-mutable-globals"]

[package.metadata.ios]
build_targets = [
    "aarch64-apple-ios",
    "aarch64-apple-ios-sim",
    "x86_64-apple-ios",
]
deployment_target = "12.0"
build_id_prefix = "com.veilid.veilidtools"

[lints]
workspace = true
