[package]
name = "tuwunel"
default-run = "tuwunel"
authors.workspace = true
categories.workspace = true
description.workspace = true
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true
metadata.crane.workspace = true

[package.metadata.deb]
name = "tuwunel"
maintainer = "Jason Volk <jason@zemos.net>"
copyright = "2025, Tuwunel Contributors"
license-file = ["../../LICENSE", "3"]
depends = "$auto, ca-certificates"
extended-description = """\
High performance Matrix homeserver written in Rust"""
section = "net"
priority = "optional"
conf-files = ["/etc/tuwunel/tuwunel.toml"]
maintainer-scripts = "../../debian/"
systemd-units = { unit-name = "tuwunel", start = false }
assets = [
	["../../debian/README.md", "usr/share/doc/tuwunel/README.Debian", "644"],
	["../../README.md", "usr/share/doc/tuwunel/", "644"],
	["target/release/tuwunel", "usr/sbin/tuwunel", "755"],
	["../../tuwunel-example.toml", "etc/tuwunel/tuwunel.toml", "640"],
]

[package.metadata.generate-rpm]
name = "tuwunel"
summary = """\
High performance Matrix homeserver written in Rust"""
require-sh = false
post_install_script = "rpm/postinst"
assets = [
	{ source = "target/release/tuwunel", dest = "/usr/sbin/tuwunel", mode = "755" },
	{ source = "README.md", dest = "/usr/share/doc/tuwunel/", mode = "644", doc = true },
	{ source = "tuwunel-example.toml", dest = "/etc/tuwunel/tuwunel.toml", mode = "640", config = "noreplace" },
	{ source = "rpm/tuwunel.service", dest = "/etc/systemd/system/", mode = "644" },
]

[package.metadata.arch]
name = "tuwunel"
pkgdesc = "High performance Matrix homeserver written in Rust"

[features]
default = [
	"brotli_compression",
	"element_hacks",
	"gzip_compression",
	"io_uring",
	"jemalloc",
	"jemalloc_conf",
	"media_thumbnail",
	"release_max_log_level",
	"systemd",
	"url_preview",
	"zstd_compression",
]

blurhashing = [
	"tuwunel-service/blurhashing",
]
brotli_compression = [
	"tuwunel-admin/brotli_compression",
	"tuwunel-api/brotli_compression",
	"tuwunel-core/brotli_compression",
	"tuwunel-router/brotli_compression",
	"tuwunel-service/brotli_compression",
]
bzip2_compression = [
	"tuwunel-admin/bzip2_compression",
	"tuwunel-api/bzip2_compression",
	"tuwunel-database/bzip2_compression",
	"tuwunel-router/bzip2_compression",
	"tuwunel-service/bzip2_compression",
]
console = [
	"tuwunel-service/console",
]
direct_tls = [
    "tuwunel-router/direct_tls"
]
element_hacks = [
	"tuwunel-api/element_hacks",
	"tuwunel-service/element_hacks",
]
gzip_compression = [
	"tuwunel-admin/gzip_compression",
	"tuwunel-api/gzip_compression",
	"tuwunel-core/gzip_compression",
	"tuwunel-router/gzip_compression",
	"tuwunel-service/gzip_compression",
]
hardened_malloc = [
	"tuwunel-core/hardened_malloc",
]
io_uring = [
	"tuwunel-admin/io_uring",
	"tuwunel-api/io_uring",
	"tuwunel-database/io_uring",
	"tuwunel-router/io_uring",
	"tuwunel-service/io_uring",
]
jemalloc = [
	"tuwunel-admin/jemalloc",
	"tuwunel-api/jemalloc",
	"tuwunel-core/jemalloc",
	"tuwunel-database/jemalloc",
	"tuwunel-router/jemalloc",
	"tuwunel-service/jemalloc",
]
jemalloc_conf = [
	"tuwunel-admin/jemalloc_conf",
	"tuwunel-api/jemalloc_conf",
	"tuwunel-core/jemalloc_conf",
	"tuwunel-database/jemalloc_conf",
	"tuwunel-router/jemalloc_conf",
	"tuwunel-service/jemalloc_conf",
]
jemalloc_prof = [
	"tuwunel-core/jemalloc_prof",
]
jemalloc_stats = [
	"tuwunel-core/jemalloc_stats",
]
ldap = [
	"tuwunel-api/ldap",
	"tuwunel-service/ldap",
]
lz4_compression = [
	"tuwunel-admin/lz4_compression",
	"tuwunel-api/lz4_compression",
	"tuwunel-database/lz4_compression",
	"tuwunel-router/lz4_compression",
	"tuwunel-service/lz4_compression",
]
media_thumbnail = [
	"tuwunel-service/media_thumbnail",
]
perf_measurements = [
	"dep:opentelemetry",
	"dep:tracing-flame",
	"dep:tracing-opentelemetry",
	"dep:opentelemetry_sdk",
	#"dep:opentelemetry-jaeger",
	"tuwunel-core/perf_measurements",
	"tuwunel-core/sentry_telemetry",
]
# increases performance, reduces build times, and reduces binary size by not compiling or
# genreating code for log level filters that users will generally not use (debug and trace)
release_max_log_level = [
	"tracing/max_level_trace",
	"tracing/release_max_level_info",
	"log/max_level_trace",
	"log/release_max_level_info",
	"tuwunel-admin/release_max_log_level",
	"tuwunel-api/release_max_log_level",
	"tuwunel-core/release_max_log_level",
	"tuwunel-database/release_max_log_level",
	"tuwunel-router/release_max_log_level",
	"tuwunel-service/release_max_log_level",
]
sentry_telemetry = [
	"dep:sentry",
	"dep:sentry-tracing",
	"dep:sentry-tower",
	"tuwunel-core/sentry_telemetry",
	"tuwunel-router/sentry_telemetry",
]
systemd = [
	"tuwunel-router/systemd",
]
# enable the tokio_console server ncompatible with release_max_log_level
tokio_console = [
	#"dep:console-subscriber",
	"tokio/tracing",
]
url_preview = [
	"tuwunel-service/url_preview",
]
zstd_compression = [
	"tuwunel-admin/zstd_compression",
	"tuwunel-api/zstd_compression",
	"tuwunel-core/zstd_compression",
	"tuwunel-database/zstd_compression",
	"tuwunel-router/zstd_compression",
	"tuwunel-service/zstd_compression",
]
tuwunel_mods = [
	"tuwunel-core/tuwunel_mods",
]

[dependencies]
tuwunel-admin.workspace = true
tuwunel-api.workspace = true
tuwunel-core.workspace = true
tuwunel-database.workspace = true
tuwunel-macros.workspace = true
tuwunel-router.workspace = true
tuwunel-service.workspace = true

clap.workspace = true
#console-subscriber.optional = true
#console-subscriber.workspace = true
const-str.workspace = true
ctor.workspace = true
log.workspace = true
#opentelemetry-jaeger.optional = true
#opentelemetry-jaeger.workspace = true
opentelemetry.optional = true
opentelemetry.workspace = true
opentelemetry_sdk.optional = true
opentelemetry_sdk.workspace = true
sentry-tower.optional = true
sentry-tower.workspace = true
sentry-tracing.optional = true
sentry-tracing.workspace = true
sentry.optional = true
sentry.workspace = true
tokio-metrics.optional = true
tokio-metrics.workspace = true
tokio.workspace = true
tracing-flame.optional = true
tracing-flame.workspace = true
tracing-opentelemetry.optional = true
tracing-opentelemetry.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true

[target.'cfg(all(not(target_env = "msvc"), target_os = "linux"))'.dependencies]
hardened_malloc-rs.workspace = true
hardened_malloc-rs.optional = true

[lints]
workspace = true

[[bin]]
name = "tuwunel"
path = "main.rs"
