[workspace]

members = [
    "libs/vector_tile",
    "libs/style_spec",
    "libs/tilejson_spec",
    "libs/wgsl_validate",
    "libs/mbtiles",
]

[package]
name = "mapr"
version = "0.1.0"
authors = ["Maximilian Ammann <max@maxammann.org>"]
edition = "2021"
resolver = "2"
build = "build.rs"
license = "MIT OR Apache-2.0"

[package.metadata.wasm-pack.profile.release]
wasm-opt = true

[profile.release]
lto = true
codegen-units = 1
opt-level = 's'
panic = "abort"

[profile.bench]
debug = true

[features]
web-webgl = ["wgpu/webgl"]
enable-tracing = [ "tracing-subscriber", "tracing-tracy", "tracy-client"]
default = []

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"
web-sys = { version = "0.3", features = [
    "Window",
    "Headers",
    "WorkerGlobalScope", "Request", "RequestInit", "RequestMode", "Response",
    "ErrorEvent", "DedicatedWorkerGlobalScope"
] }
js-sys = "0.3"
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
console_log = { version = "0.2", features = ["color"] }
# stdweb variant is way faster!
instant = { version = "0.1", features = ["stdweb"] } # FIXME: Untrusted dependency

[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "linux", target_os = "android"))'.dependencies]
tokio = { version = "1.17", features = ["macros", "rt", "rt-multi-thread", "sync", "time"] }
env_logger = "0.9"
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "gzip"] }
reqwest-middleware-cache = "0.1" # FIXME: Untrusted dependency
reqwest-middleware = { version = "0.1" } # FIXME: Untrusted dependency

[target.'cfg(target_os = "android")'.dependencies]
ndk-glue = "0.5.0" # version is required by winit
winit = { version = "0.26", default-features = false }
# Use rusttls on android because cross compiling is difficult
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "gzip"] }

[target.'cfg(target_os = "linux")'.dependencies]
winit = { version = "0.26", default-features = false, features = ["x11", "wayland"] }

[dependencies]
winit = { version = "0.26", default-features = false }

tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3", optional = true }
tracing-tracy = { version = "0.8", optional = true }
tracy-client = { git = "https://github.com/nagisa/rust_tracy_client.git", branch = "create-pull-request/patch", optional = true }

# Vector riles
vector-tile = { path = "./libs/vector_tile" }
style-spec = { path = "./libs/style_spec" }
tilejson-spec = { path = "./libs/tilejson_spec" }

# Math and geo
# https://docs.rs/euclid/0.22.6/euclid/index.html
#geo = "0.18.0"
#geo-types = "0.7"
# proj = "0.24" FIXME: Incompatible with wasm

cgmath = "0.18"

geo = { version = "0.19" }
geo-types = { version = "0.7", features = ["use-rstar_0_9"] }
rstar = { version = "0.9" }
prost = "0.9"
geozero = { git = "https://github.com/georust/geozero", rev = "24973aa", default-features = false, features = ["with-mvt", "with-geo"]}

# Rendering
wgpu = { version = "0.12" }
lyon = { version = "0.17", features = [] }

# cached = "0.32"

# Logging
log = "0.4"

# Utils
bytemuck = "1.2.0"
bytemuck_derive = "1.0"

include_dir = "0.7.2"

[patch.crates-io]
tracy-client = { git = "https://github.com/nagisa/rust_tracy_client.git", branch = "create-pull-request/patch", optional = true }

[dev-dependencies]
criterion = "0.3"
# Support logging in tests
test-env-log = "0.2"

[build-dependencies]
wgsl-validate = { path = "./libs/wgsl_validate" }
mbtiles = { path = "./libs/mbtiles" }

[lib]
crate-type = ["rlib", "cdylib", "staticlib"] # staticlib is used for apple

[[example]]
name = "desktop"
crate-type = ["bin"]

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

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

[package.metadata.android]
apk_name = "mapr-demo"
[[package.metadata.android.uses_permission]]
name = "android.permission.INTERNET"
[[package.metadata.android.uses_permission]]
name = "android.permission.ACCESS_NETWORK_STATE"