Refactor crates (#12)

* Setup scaffolding for repository

* Add build run config

* Move root crate into maplibre-core

* Fix compilation of crates

* Fix CI

* Fix run configs

* Adjust project file

* Split platform module more

* Run fmt

* Fix compilation

* Fix checks with clippy

* Remove some crates and rename others

* Remove core crate

* Fix compilation

* Fix formatting

* Fix android build

* Refactor rust cache

* Update caches

* Change crate name for android

* Fix android build

* Optimize CI runtime by using a better cache

* Add comments

* Split web job

* Use just command for setting up toolchain

* Try to force different toolchains
This commit is contained in:
Max Ammann 2022-04-22 22:43:37 +02:00 committed by GitHub
commit 04ef557b42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
119 changed files with 417 additions and 4243 deletions

View File

@ -4,19 +4,13 @@ description: Build for android
runs:
using: "composite"
steps:
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install just
- uses: extractions/setup-just@v1
- name: Install nightly toolchain
shell: bash
run: cargo install just
run: just nightly-toolchain
- uses: Swatinem/rust-cache@v1
with:
toolchain: nightly
- name: Build
shell: bash
run: just build-apk

View File

@ -4,18 +4,17 @@ description: Check
runs:
using: "composite"
steps:
- name: Setup
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: |
rustup component add rustfmt
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Format
shell: bash
run: cargo fmt --all -- --check
run: just fmt-check
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Clippy
shell: bash
run: |
rustup component add clippy
cargo clippy --all-targets --all-features
run: just clippy

View File

@ -4,23 +4,18 @@ description: Build for desktop
runs:
using: "composite"
steps:
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Build
shell: bash
run: cargo build --example desktop
run: cargo build -p maplibre-demo
- uses: actions/upload-artifact@v2
with:
name: maplibre-rs
path: target/debug/maplibre
path: target/x86_64-unknown-linux-gnu/debug/maplibre-demo

View File

@ -4,16 +4,11 @@ description: Build documentation
runs:
using: "composite"
steps:
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1
- uses: extractions/setup-just@v1
- name: Install toolchain
shell: bash
run: just default-toolchain
- uses: Swatinem/rust-cache@v1
- name: Install mdbook
shell: bash
run: |
@ -27,4 +22,4 @@ runs:
run: mdbook build
- name: API Documentation
shell: bash
run: cargo doc --no-deps --workspace --lib --all-features --document-private-items
run: cargo doc -p maplibre --no-deps --lib --all-features --document-private-items

View File

@ -4,19 +4,13 @@ description: Build for webgl
runs:
using: "composite"
steps:
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install just
- uses: extractions/setup-just@v1
- name: Install nightly toolchain
shell: bash
run: cargo install just
run: just nightly-toolchain
- uses: Swatinem/rust-cache@v1
with:
toolchain: nightly
- name: Build
shell: bash
run: just webpack-webgl-production

View File

@ -4,19 +4,13 @@ description: Build for webgpu
runs:
using: "composite"
steps:
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install just
- uses: extractions/setup-just@v1
- name: Install nightly toolchain
shell: bash
run: cargo install just
run: just nightly-toolchain
- uses: Swatinem/rust-cache@v1
with:
toolchain: nightly
- name: Build
shell: bash
run: just webpack-production

View File

@ -8,51 +8,17 @@ on:
- cron: '0 17 * * 1'
jobs:
build-macos:
runs-on: macOS-11
build:
runs-on: macOS-12
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cargo Build
run: cargo build --target aarch64-apple-darwin --lib
- name: XCode Build
run: cd apple/mapr && xcodebuild -scheme "mapr (macOS)" -arch arm64 build
build-iphoneos:
runs-on: macOS-11
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cargo Build
run: cargo build --target aarch64-apple-ios --lib # First running `cargo build` before `xcodebuild` is REQUIRED!
# Else the rust compilation fails during linking. This is
# probably due to some weird environment variables set during
# xcodebuild execution
- name: XCode Build
run: cd apple/mapr && xcodebuild -scheme "mapr (iOS)" -arch arm64 -sdk iphoneos build CODE_SIGNING_ALLOWED=NO
- uses: extractions/setup-just@v1
- uses: actions-rs/toolchain@v1
- uses: Swatinem/rust-cache@v1
- name: Build xcframework
run: just xcodebuild-xcframework
- name: Build Example
run: cd apple/xcode && xcodebuild -scheme "example (iOS)" -arch arm64 -sdk iphoneos build CODE_SIGNING_ALLOWED=NO

View File

@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/android
build-deploy-web:
build-deploy-webgpu:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
@ -32,6 +32,10 @@ jobs:
source: web/dist/demo/.
destination: webgpu
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }}
build-deploy-webgl:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/webgl
- uses: ./.github/actions/deploy
with:

View File

@ -22,11 +22,15 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/android
build-web:
build-webgpu:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/webgpu
build-webgl:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/webgl
build-docs:
runs-on: ubuntu-20.04

3
.gitignore vendored
View File

@ -5,8 +5,7 @@ target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
# FIXME: remove lock file after it reached stability
# Cargo.lock
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk

15
.idea/maplibre-rs.iml generated
View File

@ -2,13 +2,20 @@
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/benches" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/libs/mbtiles/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/libs/style_spec/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/libs/tilejson_spec/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/libs/wgsl_validate/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/maplibre-build-tools/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/maplibre-style/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/maplibre-tilejson/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/maplibre/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/maplibre/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/android/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/apple/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/benchmarks/benches" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/benchmarks/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/maplibre-demo/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/web/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />

View File

@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Render" type="CargoCommandRunConfiguration" factoryName="Cargo Command" folderName="Benches">
<option name="command" value="bench --bench render" />
<configuration default="false" name="Build All" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="build" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />

View File

@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build Android" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="+nightly-2022-02-26 apk build -Zbuild-std" />
<option name="command" value="+nightly-2022-02-26 apk build -p maplibre-android -Zbuild-std" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />

View File

@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build WASM" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="build --features web-webgl --lib --release --target wasm32-unknown-unknown -Z build-std=std,panic_abort" />
<option name="command" value="build -p maplibre-web --features web-webgl --lib --release --target wasm32-unknown-unknown -Z build-std=std,panic_abort" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />

View File

@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Tesselation" type="CargoCommandRunConfiguration" factoryName="Cargo Command" folderName="Benches">
<option name="command" value="bench --bench tessellation" />
<configuration default="false" name="Run demo (debug+enable-tracing)" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="run -p maplibre-demo --features enable-tracing" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />

View File

@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run desktop (release)" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="run --release --example desktop" />
<configuration default="false" name="Run demo (release)" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="run -p maplibre-demo --release" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />

View File

@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run desktop (debug+enable-tracing)" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="run --example desktop --features enable-tracing" />
<configuration default="false" name="Run demo (release+enable-tracing)" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="run -p maplibre-demo --release --features enable-tracing" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />

View File

@ -1,18 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run desktop (release+enable-tracing)" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="run --release --example desktop --features enable-tracing" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="emulateTerminal" value="false" />
<option name="withSudo" value="false" />
<option name="backtrace" value="SHORT" />
<envs />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
</component>

View File

@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run web (webgl) " type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/web/package.json" />
<package-json value="$PROJECT_DIR$/maplibre-web/web/package.json" />
<command value="run" />
<scripts>
<script value="webgl-start" />

View File

@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run web (webgpu)" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/web/package.json" />
<package-json value="$PROJECT_DIR$/maplibre-web/web/package.json" />
<command value="run" />
<scripts>
<script value="start" />

3805
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +1,18 @@
[workspace]
members = [
"libs/style_spec",
"libs/tilejson_spec",
"libs/wgsl_validate",
"libs/mbtiles",
]
[package]
name = "maplibre"
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
members = [
"maplibre",
"maplibre-build-tools",
"maplibre-demo",
"android",
"apple",
"web",
"benchmarks",
]
[profile.release]
lto = true
@ -27,107 +22,3 @@ panic = "abort"
[profile.bench]
debug = true
[features]
web-webgl = ["wgpu/webgl"]
# Enable tracing using tracy on desktop/mobile and the chrome profiler on web
enable-tracing = [ "tracing-subscriber", "tracing-tracy", "tracy-client", "tracing-wasm"]
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"] }
tracing-wasm = { version = "0.2", optional = true } # FIXME: Low quality dependency
instant = { version = "0.1", features = ["wasm-bindgen"] } # 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
tracing-tracy = { version = "0.8", optional = true }
tracy-client = { version = "0.12.7", optional = true }
[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 }
raw-window-handle = "0.4"
tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3", optional = true }
style-spec = { path = "./libs/style_spec" }
tilejson-spec = { path = "./libs/tilejson_spec" }
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 = "373b731", default-features = false, features = ["with-mvt", "with-geo"]}
tile-grid = "0.3"
# 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"
[dev-dependencies]
criterion = "0.3"
[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 = "maplibre-rs-demo"
[[package.metadata.android.uses_permission]]
name = "android.permission.INTERNET"
[[package.metadata.android.uses_permission]]
name = "android.permission.ACCESS_NETWORK_STATE"

26
android/Cargo.toml Normal file
View File

@ -0,0 +1,26 @@
[package]
name = "maplibre-android" # Naming this "android" is not possible. Compilation fails.
version = "0.1.0"
description = ""
categories = []
edition = "2021"
publish = false
[dependencies]
maplibre = { path = "../maplibre" }
env_logger = "0.9"
[target.'cfg(target_os = "android")'.dependencies]
ndk-glue = "0.5.0" # version is required by winit
[lib]
#name = "maplibre_android" Currently not supported: https://github.com/rust-windowing/android-ndk-rs/issues/136
crate-type = ["rlib", "cdylib"]
[package.metadata.android]
apk_name = "maplibre-rs-demo"
[[package.metadata.android.uses_permission]]
name = "android.permission.INTERNET"
[[package.metadata.android.uses_permission]]
name = "android.permission.ACCESS_NETWORK_STATE"

View File

@ -1,10 +1,10 @@
use crate::io::scheduler::ScheduleMethod;
use crate::platform::schedule_method::TokioScheduleMethod;
use crate::window::FromWindow;
use crate::MapBuilder;
use maplibre::window::FromWindow;
use maplibre::{MapBuilder, ScheduleMethod, TokioScheduleMethod};
pub use std::time::Instant;
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8Unorm;
// TODO clippy
// #[cfg(not(target_os = "android"))]
// compile_error!("android works only on android.");
#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))]
pub fn main() {

15
apple/Cargo.toml Normal file
View File

@ -0,0 +1,15 @@
[package]
name = "apple"
version = "0.1.0"
description = ""
categories = []
edition = "2021"
publish = false
[dependencies]
maplibre = { path = "../maplibre" }
env_logger = "0.9"
[lib]
name = "maplibre_apple"
crate-type = ["staticlib"]

View File

@ -1,11 +1,10 @@
use crate::io::scheduler::ScheduleMethod;
use crate::platform::schedule_method::TokioScheduleMethod;
use crate::window::FromWindow;
use crate::MapBuilder;
use maplibre::window::FromWindow;
use maplibre::{MapBuilder, ScheduleMethod, TokioScheduleMethod};
pub use std::time::Instant;
// macOS and iOS (Metal)
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8UnormSrgb;
// TODO clippy
// #[cfg(not(any(target_os = "macos", target_os = "ios")))]
// compile_error!("apple works only on macOS and iOS.");
#[no_mangle]
pub fn maplibre_apple_main() {

12
benchmarks/Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "maplibre-benchmark"
version = "0.1.0"
description = ""
categories = []
edition = "2021"
[dependencies]
maplibre = { path = "../maplibre" }
[dev-dependencies]
criterion = "0.3"

View File

@ -5,8 +5,6 @@ use maplibre::{MapBuilder, ScheduleMethod, TokioScheduleMethod};
fn render(c: &mut Criterion) {
c.bench_function("render", |b| {
b.iter(|| {
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
MapBuilder::from_window("A fantastic window!")
.with_schedule_method(ScheduleMethod::Tokio(TokioScheduleMethod::new()))
.build()

View File

@ -1,5 +1,5 @@
use criterion::{criterion_group, criterion_main, Criterion};
use lyon::tessellation::VertexBuffers;
// use lyon::tessellation::VertexBuffers;
use maplibre::benchmarking::io::static_tile_fetcher::StaticTileFetcher;
use maplibre::benchmarking::tessellation::Tessellated;
use std::io::Cursor;

1
benchmarks/src/lib.rs Normal file
View File

@ -0,0 +1 @@

View File

@ -2,60 +2,78 @@
# ^ A shebang isn't required, but allows a justfile to be executed
# like a script, with `./justfile test`, for example.
export RUSTUP_TOOLCHAIN := "nightly-2022-04-04-x86_64-unknown-linux-gnu"
export NIGHTLY_TOOLCHAIN := "nightly-2022-04-04-x86_64-unknown-linux-gnu"
test:
cargo test
clippy:
cargo clippy --all-targets --all-features
install-clippy:
rustup component add clippy
fmt:
clippy: install-clippy
cargo clippy --all-targets --all-features --no-deps
install-rustfmt:
rustup component add rustfmt
fmt: install-rustfmt
cargo fmt --all --
fmt-check: install-rustfmt
cargo fmt --all -- --check
default-toolchain:
# Setups the toolchain from rust-toolchain.toml
cargo --version > /dev/null
nightly-toolchain:
rustup install $RUSTUP_TOOLCHAIN
rustup component add rust-src --toolchain $RUSTUP_TOOLCHAIN
rustup install $NIGHTLY_TOOLCHAIN
rustup component add rust-src --toolchain $NIGHTLY_TOOLCHAIN
rustup override set $NIGHTLY_TOOLCHAIN
webpack-webgl-production: nightly-toolchain
cd web && npm install && npm run webgl-production-build
cd web/web && npm install && npm run webgl-production-build
webpack-production: nightly-toolchain
cd web && npm install && npm run production-build
cd web/web && npm install && npm run production-build
wasm-pack-webgl: nightly-toolchain
./wasm-pack-v0.10.1-x86_64-unknown-linux-musl/wasm-pack build . \
--release --target web --out-dir web/dist/maplibre-rs -- \
--features "web-webgl" -Z build-std=std,panic_abort
wasm-pack: nightly-toolchain
./wasm-pack-v0.10.1-x86_64-unknown-linux-musl/wasm-pack build . \
--release --target web --out-dir web/dist/maplibre-rs -- \
-Z build-std=std,panic_abort
build-web-webgl: nightly-toolchain
cargo build --features web-webgl --target wasm32-unknown-unknown -Z build-std=std,panic_abort
build-web: nightly-toolchain
cargo build --features "" --target wasm32-unknown-unknown -Z build-std=std,panic_abort
wasm-bindgen:
cargo install wasm-bindgen-cli
# TODO: Untested: --reference-types
wasm-bindgen --target web --out-dir web/dist/maplibre-rs-plain-bindgen target/wasm32-unknown-unknown/debug/maplibre.wasm
build-wasm-bindgen: build-web wasm-bindgen
build-wasm-bindgen-webgpu: build-web wasm-bindgen
# TODO
# wasm-pack-webgl: nightly-toolchain
# ./wasm-pack-v0.10.1-x86_64-unknown-linux-musl/wasm-pack build . \
# --release --target web --out-dir web/dist/maplibre-rs -- \
# --features "web-webgl" -Z build-std=std,panic_abort
#
# wasm-pack: nightly-toolchain
# ./wasm-pack-v0.10.1-x86_64-unknown-linux-musl/wasm-pack build . \
# --release --target web --out-dir web/dist/maplibre-rs -- \
# -Z build-std=std,panic_abort
#
# build-web-webgl: nightly-toolchain
# cargo build --features web-webgl --target wasm32-unknown-unknown -Z build-std=std,panic_abort
#
# build-web: nightly-toolchain
# cargo build --features "" --target wasm32-unknown-unknown -Z build-std=std,panic_abort
#
# wasm-bindgen:
# cargo install wasm-bindgen-cli
# # TODO: Untested: --reference-types
# wasm-bindgen --target web --out-dir web/dist/maplibre-rs-plain-bindgen target/wasm32-unknown-unknown/debug/maplibre.wasm
#
# build-wasm-bindgen: build-web wasm-bindgen
#
# build-wasm-bindgen-webgpu: build-web wasm-bindgen
# TODO
#profile-bench:
# cargo flamegraph --bench render -- --bench
install-cargo-apk:
cargo install cargo-apk
run-apk: nightly-toolchain install-cargo-apk
cargo apk run --lib -Zbuild-std
cargo apk run -p maplibre-android --lib -Zbuild-std
build-apk: nightly-toolchain install-cargo-apk
cargo apk build --lib -Zbuild-std
cargo apk build -p maplibre-android --lib -Zbuild-std
# language=bash
print-android-env:
@ -63,11 +81,6 @@ print-android-env:
echo "ANDROID_SDK_ROOT: $ANDROID_SDK_ROOT"
echo "ANDROID_NDK_ROOT: $ANDROID_NDK_ROOT"
# FIXME
profile-bench:
cargo flamegraph --bench render -- --bench
# language=bash
extract-tiles:
#!/usr/bin/env bash

View File

@ -1,11 +0,0 @@
[package]
name = "mbtiles"
version = "0.1.0"
description = ""
edition = "2021"
[dependencies]
log = "0.4"
rusqlite = "0.26"
serde_json = "1.0"
flate2 = "1.0"

View File

View File

@ -1,19 +0,0 @@
[package]
name = "style-spec"
version = "0.1.0"
description = "A library for decoding style specs"
readme = "README.md"
categories = ["encoding"]
edition = "2021"
build = "build.rs"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
csscolorparser = { version = "0.5", features = ["serde", "cint"]}
cint = "0.2"
[build-dependencies]
serde_json = "1.0"
[dev-dependencies]
serde_json = "1.0"

View File

@ -1,25 +0,0 @@
/*use std::fs::File;
use std::io::BufReader;
use serde_json::Value;*/
fn generate_type_def() -> Option<u32> {
/* let f = File::open("style-spec-v8.json").unwrap();
let mut reader = BufReader::new(f);
let result = serde_json::from_reader::<_, Value>(&mut reader).unwrap();
let spec_root = result.as_object()?;
let version = &spec_root["$version"].as_i64()?;
let root = &spec_root["$root"].as_object()?;
for x in spec_root {
}
println!("cargo:warning={:?}", version);*/
Some(5)
}
fn main() {
generate_type_def();
}

View File

View File

@ -1,13 +0,0 @@
[package]
name = "tilejson-spec"
version = "0.1.0"
description = "A library for decoding and encoding tilejson specs"
readme = "README.md"
categories = ["encoding"]
edition = "2021"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
[dev-dependencies]
serde_json = "1.0"

View File

@ -1,3 +0,0 @@
mod tilejson;
pub use crate::tilejson::*;

View File

@ -1,11 +0,0 @@
[package]
name = "wgsl-validate"
version = "0.1.0"
description = "A library for validating WGSL shaders"
readme = "README.md"
categories = ["encoding"]
edition = "2021"
[dependencies]
naga = { version = "0.8", features = ["wgsl-in"] }
walkdir = "2.3"

View File

@ -0,0 +1,14 @@
[package]
name = "maplibre-build-tools"
version = "0.1.0"
description = "A library with build tools for maplibre-rs"
categories = []
edition = "2021"
[dependencies]
naga = { version = "0.8", features = ["wgsl-in"] }
walkdir = "2.3"
log = "0.4"
rusqlite = "0.26"
serde_json = "1.0"
flate2 = "1.0"

View File

@ -0,0 +1,2 @@
pub mod mbtiles;
pub mod wgsl;

19
maplibre-demo/Cargo.toml Normal file
View File

@ -0,0 +1,19 @@
[package]
name = "maplibre-demo"
version = "0.1.0"
description = ""
categories = []
edition = "2021"
[features]
web-webgl = ["maplibre/web-webgl"]
enable-tracing = ["maplibre/enable-tracing", "tracing-subscriber", "tracing-tracy", "tracy-client"]
[dependencies]
env_logger = "0.9"
maplibre = { path = "../maplibre" }
tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3", optional = true }
tracing-tracy = { version = "0.8", optional = true }
tracy-client = { version = "0.12.7", optional = true }

86
maplibre/Cargo.toml Normal file
View File

@ -0,0 +1,86 @@
[package]
name = "maplibre"
version = "0.1.0"
authors = ["Maximilian Ammann <max@maxammann.org>"]
edition = "2021"
build = "build.rs"
license = "MIT OR Apache-2.0"
[features]
web-webgl = ["wgpu/webgl"]
# Enable tracing using tracy on desktop/mobile and the chrome profiler on web
enable-tracing = [ "tracing-subscriber", "tracing-tracy", "tracy-client", "tracing-wasm"]
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"] }
tracing-wasm = { version = "0.2", optional = true } # FIXME: Low quality dependency
instant = { version = "0.1", features = ["wasm-bindgen"] } # 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
tracing-tracy = { version = "0.8", optional = true }
tracy-client = { version = "0.12.7", optional = true }
[target.'cfg(target_os = "android")'.dependencies]
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 }
raw-window-handle = "0.4"
tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3", optional = true }
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 = "373b731", default-features = false, features = ["with-mvt", "with-geo"]}
tile-grid = "0.3"
# 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"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
csscolorparser = { version = "0.5", features = ["serde", "cint"]}
cint = "0.2"
[build-dependencies]
maplibre-build-tools = { path = "../maplibre-build-tools" }

View File

@ -1,8 +1,8 @@
use std::path::{Path, PathBuf};
use std::{env, fs};
use mbtiles::extract;
use wgsl_validate::validate_project_wgsl;
use maplibre_build_tools::mbtiles::extract;
use maplibre_build_tools::wgsl::validate_project_wgsl;
const MUNICH_X: u32 = 17425;
const MUNICH_Y: u32 = 11365;
@ -21,6 +21,28 @@ fn clean_static_tiles() -> PathBuf {
out
}
/*use std::fs::File;
use std::io::BufReader;
use serde_json::Value;*/
fn generate_type_def() -> Option<u32> {
/* let f = File::open("style-spec-v8.json").unwrap();
let mut reader = BufReader::new(f);
let result = serde_json::from_reader::<_, Value>(&mut reader).unwrap();
let spec_root = result.as_object()?;
let version = &spec_root["$version"].as_i64()?;
let root = &spec_root["$root"].as_object()?;
for x in spec_root {
}
println!("cargo:warning={:?}", version);*/
Some(5)
}
fn embed_tiles_statically() {
let out = clean_static_tiles();

View File

@ -6,7 +6,7 @@ use std::fmt::Formatter;
use cgmath::num_traits::Pow;
use cgmath::{AbsDiffEq, Matrix4, Point3, Vector3};
use style_spec::source::TileAddressingScheme;
use crate::style::source::TileAddressingScheme;
use crate::util::math::{div_floor, Aabb2};
use crate::util::SignificantlyDifferent;
@ -500,7 +500,7 @@ impl fmt::Display for WorldCoords {
mod tests {
use cgmath::{Point2, Vector4};
use style_spec::source::TileAddressingScheme;
use crate::style::source::TileAddressingScheme;
use crate::coords::{
Quadkey, TileCoords, ViewRegion, WorldCoords, WorldTileCoords, Zoom, EXTENT,

View File

@ -1,6 +1,6 @@
use crate::coords::WorldTileCoords;
use crate::error::Error;
use style_spec::source::TileAddressingScheme;
use crate::style::source::TileAddressingScheme;
pub struct HttpSourceClient {
#[cfg(not(target_arch = "wasm32"))]

View File

@ -48,7 +48,7 @@ impl StaticTileFetcher {
#[cfg(test)]
mod tests {
use style_spec::source::TileAddressingScheme;
use crate::style::source::TileAddressingScheme;
use crate::coords::WorldTileCoords;

View File

@ -8,7 +8,9 @@ pub(crate) mod io;
pub(crate) mod map_state;
pub(crate) mod platform;
pub(crate) mod render;
pub(crate) mod style;
pub(crate) mod tessellation;
pub(crate) mod tilejson;
pub(crate) mod util;
pub(crate) mod winit;
@ -18,10 +20,10 @@ pub mod window;
use crate::map_state::{MapState, Runnable};
use crate::render::render_state::RenderState;
use crate::style::Style;
use crate::window::{WindowFactory, WindowSize};
pub use io::scheduler::ScheduleMethod;
pub use platform::schedule_method::*;
use style_spec::Style;
pub struct Map<W, E> {
map_state: MapState<W>,

View File

@ -17,7 +17,7 @@ use crate::io::source_client::{HttpSourceClient, SourceClient};
use crate::io::tile_cache::TileCache;
use crate::io::tile_request_state::TileRequestState;
use crate::io::{TessellateMessage, TileRequest, TileTessellateMessage};
use style_spec::Style;
use crate::style::Style;
use wgpu::SurfaceError;
pub trait Runnable<E> {

View File

@ -1,23 +1,27 @@
//! This module handles platform specific code. Depending on the compilation target different
//! parts of this module are used
#[cfg(target_arch = "wasm32")]
mod web;
// WebGPU
#[cfg(all(target_arch = "wasm32", not(feature = "web-webgl")))]
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8Unorm;
#[cfg(any(target_os = "macos", target_os = "ios"))]
mod apple;
// WebGL
#[cfg(all(target_arch = "wasm32", feature = "web-webgl"))]
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
// Vulkan Android
#[cfg(target_os = "android")]
mod android;
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8Unorm;
#[cfg(not(target_arch = "wasm32"))]
mod noweb;
// macOS and iOS (Metal)
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8UnormSrgb;
/// For Vulkan/OpenGL
#[cfg(not(any(
target_os = "android",
target_os = "macos",
target_os = "ios",
any(target_os = "macos", target_os = "ios"),
target_arch = "wasm32"
)))]
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8UnormSrgb;
@ -28,12 +32,15 @@ pub use web::*;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub use apple::*;
#[cfg(target_os = "android")]
pub use android::*;
#[cfg(not(target_arch = "wasm32"))]
pub use noweb::*;
// FIXME: This limit is enforced by WebGL. Actually this makes sense!
// FIXME: This can also be achieved by _pad attributes in shader_ffi.rs
pub const MIN_BUFFER_SIZE: u64 = 32;
#[cfg(not(target_arch = "wasm32"))]
mod noweb;
#[cfg(target_arch = "wasm32")]
mod web;

View File

@ -2,10 +2,10 @@ use std::panic;
use std::thread::Thread;
use super::schedule_method::WebWorkerPoolScheduleMethod;
use crate::style::source::TileAddressingScheme;
use console_error_panic_hook;
pub use instant::Instant;
use js_sys::{ArrayBuffer, Error as JSError, Uint8Array};
use style_spec::source::TileAddressingScheme;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen_futures::JsFuture;

View File

@ -1,9 +1,9 @@
use std::panic;
use crate::style::source::TileAddressingScheme;
use console_error_panic_hook;
pub use instant::Instant;
use schedule_method::WebWorkerPoolScheduleMethod;
use style_spec::source::TileAddressingScheme;
use wasm_bindgen::prelude::*;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
@ -20,14 +20,6 @@ pub mod legacy_webworker_fetcher;
mod pool;
pub mod schedule_method;
// WebGPU
#[cfg(not(feature = "web-webgl"))]
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8Unorm;
// WebGL
#[cfg(feature = "web-webgl")]
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
#[cfg(feature = "enable-tracing")]
fn enable_tracing() {
use tracing_subscriber::layer::SubscriberExt;

View File

@ -4,7 +4,7 @@ use std::marker::PhantomData;
use std::mem::size_of;
use std::ops::Range;
use style_spec::layer::StyleLayer;
use crate::style::layer::StyleLayer;
use wgpu::BufferAddress;
use crate::coords::{Quadkey, WorldTileCoords};
@ -522,8 +522,8 @@ impl RingIndex {
#[cfg(test)]
mod tests {
use crate::style::layer::StyleLayer;
use lyon::tessellation::VertexBuffers;
use style_spec::layer::StyleLayer;
use wgpu::BufferAddress;
use crate::render::buffer_pool::{

View File

@ -5,7 +5,7 @@ use std::{cmp, iter};
use tracing;
use wgpu::{Buffer, Limits, Queue};
use style_spec::Style;
use crate::style::Style;
use crate::coords::{ViewRegion, Zoom};

View File

@ -2,6 +2,6 @@ pub mod layer;
pub mod source;
mod style;
pub use crate::style::*;
pub use style::*;
pub use cint::*;

View File

@ -1,5 +1,5 @@
use crate::layer::{LayerPaint, LinePaint, StyleLayer};
use crate::source::Source;
use crate::style::layer::{LayerPaint, LinePaint, StyleLayer};
use crate::style::source::Source;
use csscolorparser::Color;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

View File

@ -0,0 +1,3 @@
mod tilejson;
pub use tilejson::*;

Some files were not shown because too many files have changed in this diff Show More