diff --git a/.github/actions/android/action.yml b/.github/actions/android/action.yml deleted file mode 100644 index 13da6c7a..00000000 --- a/.github/actions/android/action.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: android -description: Build for android - -runs: - using: "composite" - steps: - - uses: extractions/setup-just@v1 - - name: Install nightly toolchain - shell: bash - run: just nightly-toolchain-android - - uses: Swatinem/rust-cache@v1 - - name: Build - shell: bash - run: just build-android - # TODO: Additional clippy checks for different targets - - name: Check x86_64 - shell: bash - run: | - env "AR_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" \ - env "CC_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android30-clang" \ - just check maplibre-android x86_64-linux-android - - name: Check aarch64 - shell: bash - run: | - env "AR_aarch64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" \ - env "CC_aarch64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang" \ - just check maplibre-android aarch64-linux-android - # FIXME: Requires cross-compilation - #- name: Test - # shell: bash - # # TODO: Additional test runs for different targets - # run: just test maplibre-android aarch64-linux-android \ No newline at end of file diff --git a/.github/actions/apple/action.yml b/.github/actions/apple/action.yml deleted file mode 100644 index d0913ff1..00000000 --- a/.github/actions/apple/action.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: macOS -description: Build for macOS - -inputs: - GITHUB_TOKEN: - required: true - description: On macos runners we often hit API limits. Using this token avoid this. - -runs: - using: "composite" - steps: - - uses: extractions/setup-just@v1 - env: - GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} - - name: Install toolchain - shell: bash - run: just default-toolchain - - uses: Swatinem/rust-cache@v1 - - name: Build - shell: bash - run: just xcodebuild-xcframework - - name: Check x86_64 darwin - shell: bash - run: just check apple x86_64-apple-darwin - - name: Check x86_64 darwin - shell: bash - # TODO: Additional clippy checks for different targets (iOS) - run: just check apple x86_64-apple-darwin - - name: Test x86_64 darwin - shell: bash - # TODO: Additional test runs for different targets (Different targets might require emulation) - run: just test apple x86_64-apple-darwin - - name: Build Example - shell: bash - run: cd apple/xcode && xcodebuild -scheme "example (iOS)" -arch arm64 -sdk iphoneos build CODE_SIGNING_ALLOWED=NO - - name: Build Swift Package (arm64) - shell: bash - run: cd apple/MapLibreRs && swift build --arch=arm64 - - name: Build Swift Package (x86_64) - shell: bash - run: cd apple/MapLibreRs && swift build --arch=x86_64 - diff --git a/.github/actions/benchmarks/action.yml b/.github/actions/benchmarks/action.yml deleted file mode 100644 index 875e6ff5..00000000 --- a/.github/actions/benchmarks/action.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: benchmarks -description: Run benchmarks - -runs: - using: "composite" - steps: - - 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: Check - shell: bash - run: just check benchmarks x86_64-unknown-linux-gnu diff --git a/.github/actions/check/action.yml b/.github/actions/check/action.yml deleted file mode 100644 index e5432699..00000000 --- a/.github/actions/check/action.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: check -description: Check - -runs: - using: "composite" - steps: - - uses: extractions/setup-just@v1 - - name: Install toolchain - shell: bash - run: just default-toolchain - - uses: Swatinem/rust-cache@v1 - - name: Format - shell: bash - run: just fmt-check diff --git a/.github/actions/demo/linux/action.yml b/.github/actions/demo/linux/action.yml deleted file mode 100644 index 825dc60a..00000000 --- a/.github/actions/demo/linux/action.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: linux-demo -description: Build linux-demo for linux - -runs: - using: "composite" - steps: - - 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 -p maplibre-demo - - name: Check - shell: bash - run: just check maplibre-demo x86_64-unknown-linux-gnu - - name: Test x86_64 linux - shell: bash - run: just test maplibre-demo x86_64-unknown-linux-gnu - - uses: actions/upload-artifact@v2 - with: - name: maplibre-rs - path: target/x86_64-unknown-linux-gnu/debug/maplibre-demo \ No newline at end of file diff --git a/.github/actions/demo/macos/action.yml b/.github/actions/demo/macos/action.yml deleted file mode 100644 index 769b8b6d..00000000 --- a/.github/actions/demo/macos/action.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: macOS -description: Build for macOS - -inputs: - GITHUB_TOKEN: - required: true - description: On macos runners we often hit API limits. Using this token avoid this. - -runs: - using: "composite" - steps: - - uses: extractions/setup-just@v1 - env: - GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} - - name: Install toolchain - shell: bash - run: just default-toolchain - - uses: Swatinem/rust-cache@v1 - - name: Build - shell: bash - run: cd apple/xcode && xcodebuild -scheme "example (macOS)" build CODE_SIGNING_ALLOWED=NO MACOSX_DEPLOYMENT_TARGET=10.9 -derivedDataPath build - - name: Check x86_64 darwin - shell: bash - run: just check maplibre-demo x86_64-apple-darwin - - name: Test x86_64 darwin - shell: bash - run: just test maplibre-demo x86_64-apple-darwin - - uses: actions/upload-artifact@v3 - with: - name: maplibre-x86_64-apple-darwin-demo - path: apple/xcode/build/Build/Products/Debug/*.app - if-no-files-found: error \ No newline at end of file diff --git a/.github/actions/demo/windows/action.yml b/.github/actions/demo/windows/action.yml deleted file mode 100644 index 05eaa866..00000000 --- a/.github/actions/demo/windows/action.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: windows-demo -description: Build windows-demo for windows - -runs: - using: "composite" - steps: - - uses: extractions/setup-just@v1 - - name: Install toolchain - shell: bash - run: just default-toolchain - - uses: Swatinem/rust-cache@v1 - - uses: ilammy/msvc-dev-cmd@v1 # Provide access to lib.exe - - name: Install SQLite - shell: powershell - run: choco install sqlite -y --params "/NoTools" - - name: Build SQLite lib - shell: powershell - run: | - cd "C:\ProgramData\chocolatey\lib\SQLite\tools" - lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:x64 - echo "SQLITE3_LIB_DIR=C:\ProgramData\chocolatey\lib\SQLite\tools" >> $env:GITHUB_ENV - - name: Build - shell: bash - run: cargo build -p maplibre-demo --release --target x86_64-pc-windows-msvc - - name: Check x86_64 windows - shell: bash - run: just check maplibre-demo x86_64-pc-windows-msvc - - name: Test x86_64 windows - shell: bash - run: just test maplibre-demo x86_64-pc-windows-msvc - - uses: actions/upload-artifact@v3 - with: - name: maplibre-x86_64-windows-demo - path: target/x86_64-pc-windows-msvc/release/maplibre-demo.exe - if-no-files-found: error \ No newline at end of file diff --git a/.github/actions/docs/action.yml b/.github/actions/docs/action.yml deleted file mode 100644 index 8b1e8b0b..00000000 --- a/.github/actions/docs/action.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: docs -description: Build documentation - -runs: - using: "composite" - steps: - - uses: extractions/setup-just@v1 - - name: Install toolchain - shell: bash - run: just default-toolchain - - uses: Swatinem/rust-cache@v1 - - name: Setup mdBook - uses: peaceiris/actions-mdbook@v1 - - name: Install Dependencies - shell: bash - run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit - - name: Build - working-directory: docs - shell: bash - run: mdbook build - - name: API Documentation - shell: bash - run: cargo doc -p maplibre --no-deps --lib --document-private-items diff --git a/.github/actions/tests/action.yml b/.github/actions/tests/action.yml deleted file mode 100644 index 61327ab9..00000000 --- a/.github/actions/tests/action.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: tests -description: Run tests - -runs: - using: "composite" - steps: - - 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: Test - shell: bash - # TODO: Additional test runs for different targets - run: just test maplibre x86_64-unknown-linux-gnu diff --git a/.github/actions/webgl/action.yml b/.github/actions/webgl/action.yml deleted file mode 100644 index f2cfec1a..00000000 --- a/.github/actions/webgl/action.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: webgl -description: Build for webgl - -runs: - using: "composite" - steps: - - uses: extractions/setup-just@v1 - - name: Install nightly toolchain - shell: bash - run: just nightly-toolchain - - uses: Swatinem/rust-cache@v1 - - name: Build lib - shell: bash - run: just web-lib esbuild-webgl - - name: Build demo - shell: bash - run: just web-demo build - - name: Check - shell: bash - run: just check web wasm32-unknown-unknown - - name: Test - shell: bash - run: | - cargo install wasm-bindgen-cli --version "0.2.80" - just web-test "web-webgl" diff --git a/.github/actions/webgpu/action.yml b/.github/actions/webgpu/action.yml deleted file mode 100644 index 43618cb0..00000000 --- a/.github/actions/webgpu/action.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: webgpu -description: Build for webgpu - -runs: - using: "composite" - steps: - - uses: extractions/setup-just@v1 - - name: Install nightly toolchain - shell: bash - run: just nightly-toolchain - - uses: Swatinem/rust-cache@v1 - - name: Build lib - shell: bash - run: just web-lib esbuild - - name: Build demo - shell: bash - run: just web-demo build - - name: Check - shell: bash - run: just check web wasm32-unknown-unknown - - name: Test - shell: bash - run: | - cargo install wasm-bindgen-cli --version "0.2.80" - just web-test "" diff --git a/.github/workflows/build-deploy-docs.yml b/.github/workflows/build-deploy-docs.yml new file mode 100644 index 00000000..461d27ce --- /dev/null +++ b/.github/workflows/build-deploy-docs.yml @@ -0,0 +1,66 @@ +name: Build documentation + +on: + workflow_call: + secrets: + SSH_KEY_MAXAMMANN_ORG: + required: false + inputs: + deploy: + required: true + type: boolean + + +jobs: + build-docs: + name: Build + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: extractions/setup-just@v1 + - name: Install toolchain + shell: bash + run: just default-toolchain + - uses: Swatinem/rust-cache@v1 + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v1 + - name: Install Dependencies + shell: bash + run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit + - name: Build + working-directory: docs + shell: bash + run: mdbook build + - name: API Documentation + shell: bash + run: cargo doc -p maplibre --no-deps --lib --document-private-items + - uses: actions/upload-artifact@v2 + with: + name: api-docs + path: target/doc/ + - uses: actions/upload-artifact@v2 + with: + name: book + path: docs/book/ + deploy-docs: + needs: build-docs + if: inputs.deploy + name: Deploy + runs-on: ubuntu-20.04 + steps: + - uses: actions/download-artifact@v2 + with: + name: api-docs + - uses: actions/download-artifact@v2 + with: + name: book + - uses: ./.github/actions/deploy + with: + source: . + destination: api-docs + key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} + - uses: ./.github/actions/deploy + with: + source: . + destination: docs + key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} \ No newline at end of file diff --git a/.github/workflows/demo-linux.yml b/.github/workflows/demo-linux.yml new file mode 100644 index 00000000..15dddacc --- /dev/null +++ b/.github/workflows/demo-linux.yml @@ -0,0 +1,32 @@ +name: Build demo for Linux + +on: + workflow_call: + +jobs: + demo-linux: + name: Build + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - 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 -p maplibre-demo + - name: Check + shell: bash + run: just check maplibre-demo x86_64-unknown-linux-gnu + - name: Test x86_64 linux + shell: bash + run: just test maplibre-demo x86_64-unknown-linux-gnu + - uses: actions/upload-artifact@v2 + with: + name: maplibre-rs + path: target/x86_64-unknown-linux-gnu/debug/maplibre-demo \ No newline at end of file diff --git a/.github/workflows/demo-macos.yml b/.github/workflows/demo-macos.yml new file mode 100644 index 00000000..e2ab2fce --- /dev/null +++ b/.github/workflows/demo-macos.yml @@ -0,0 +1,32 @@ +name: Build demo for macOS + +on: + workflow_call: + +jobs: + demo-macos: + name: Build + runs-on: macos-11 + steps: + - uses: actions/checkout@v2 + - uses: extractions/setup-just@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Install toolchain + shell: bash + run: just default-toolchain + - uses: Swatinem/rust-cache@v1 + - name: Build + shell: bash + run: cd apple/xcode && xcodebuild -scheme "example (macOS)" build CODE_SIGNING_ALLOWED=NO MACOSX_DEPLOYMENT_TARGET=10.9 -derivedDataPath build + - name: Check x86_64 darwin + shell: bash + run: just check maplibre-demo x86_64-apple-darwin + - name: Test x86_64 darwin + shell: bash + run: just test maplibre-demo x86_64-apple-darwin + - uses: actions/upload-artifact@v3 + with: + name: maplibre-x86_64-apple-darwin-demo + path: apple/xcode/build/Build/Products/Debug/*.app + if-no-files-found: error \ No newline at end of file diff --git a/.github/workflows/demo-windows.yml b/.github/workflows/demo-windows.yml new file mode 100644 index 00000000..b73e1582 --- /dev/null +++ b/.github/workflows/demo-windows.yml @@ -0,0 +1,40 @@ +name: Build demo for Windows + +on: + workflow_call: + +jobs: + demo-windows: + name: Build + runs-on: windows-2022 + steps: + - uses: actions/checkout@v2 + - uses: extractions/setup-just@v1 + - name: Install toolchain + shell: bash + run: just default-toolchain + - uses: Swatinem/rust-cache@v1 + - uses: ilammy/msvc-dev-cmd@v1 # Provide access to lib.exe + - name: Install SQLite + shell: powershell + run: choco install sqlite -y --params "/NoTools" + - name: Build SQLite lib + shell: powershell + run: | + cd "C:\ProgramData\chocolatey\lib\SQLite\tools" + lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:x64 + echo "SQLITE3_LIB_DIR=C:\ProgramData\chocolatey\lib\SQLite\tools" >> $env:GITHUB_ENV + - name: Build + shell: bash + run: cargo build -p maplibre-demo --release --target x86_64-pc-windows-msvc + - name: Check x86_64 windows + shell: bash + run: just check maplibre-demo x86_64-pc-windows-msvc + - name: Test x86_64 windows + shell: bash + run: just test maplibre-demo x86_64-pc-windows-msvc + - uses: actions/upload-artifact@v3 + with: + name: maplibre-x86_64-windows-demo + path: target/x86_64-pc-windows-msvc/release/maplibre-demo.exe + if-no-files-found: error \ No newline at end of file diff --git a/.github/workflows/library-android.yml b/.github/workflows/library-android.yml new file mode 100644 index 00000000..99a5c6e8 --- /dev/null +++ b/.github/workflows/library-android.yml @@ -0,0 +1,44 @@ +name: Build android library + +on: + workflow_call: + +jobs: + library-android: + name: Build + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: extractions/setup-just@v1 + - name: Install nightly toolchain + shell: bash + run: just nightly-toolchain-android + - uses: Swatinem/rust-cache@v1 + - name: Set NDK Version + shell: bash + run: | + ANDROID_ROOT=/usr/local/lib/android + ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk + ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle + ln -sfn $ANDROID_SDK_ROOT/ndk/23.2.8568313 $ANDROID_NDK_ROOT + - name: Build + shell: bash + run: just build-android + # TODO: Additional clippy checks for different targets + - name: Check x86_64 + shell: bash + run: | + env "AR_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" \ + env "CC_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android30-clang" \ + just check maplibre-android x86_64-linux-android + - name: Check aarch64 + shell: bash + run: | + env "AR_aarch64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" \ + env "CC_aarch64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang" \ + just check maplibre-android aarch64-linux-android + # FIXME: Requires cross-compilation + #- name: Test + # shell: bash + # # TODO: Additional test runs for different targets + # run: just test maplibre-android aarch64-linux-android \ No newline at end of file diff --git a/.github/workflows/library-apple.yml b/.github/workflows/library-apple.yml new file mode 100644 index 00000000..084667c1 --- /dev/null +++ b/.github/workflows/library-apple.yml @@ -0,0 +1,43 @@ +name: Build apple library + +on: + workflow_call: + + +jobs: + library-apple: + name: Build + runs-on: macos-11 + steps: + - uses: actions/checkout@v2 + - uses: extractions/setup-just@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Install toolchain + shell: bash + run: just default-toolchain + - uses: Swatinem/rust-cache@v1 + - name: Build + shell: bash + run: just xcodebuild-xcframework + - name: Check x86_64 darwin + shell: bash + run: just check apple x86_64-apple-darwin + - name: Check x86_64 darwin + shell: bash + # TODO: Additional clippy checks for different targets (iOS) + run: just check apple x86_64-apple-darwin + - name: Test x86_64 darwin + shell: bash + # TODO: Additional test runs for different targets (Different targets might require emulation) + run: just test apple x86_64-apple-darwin + - name: Build Example + shell: bash + run: cd apple/xcode && xcodebuild -scheme "example (iOS)" -arch arm64 -sdk iphoneos build CODE_SIGNING_ALLOWED=NO + - name: Build Swift Package (arm64) + shell: bash + run: cd apple/MapLibreRs && swift build --arch=arm64 + - name: Build Swift Package (x86_64) + shell: bash + run: cd apple/MapLibreRs && swift build --arch=x86_64 + diff --git a/.github/workflows/library-web.yml b/.github/workflows/library-web.yml new file mode 100644 index 00000000..35c6d9ea --- /dev/null +++ b/.github/workflows/library-web.yml @@ -0,0 +1,84 @@ +name: Build library for WebGL + +on: + workflow_call: + secrets: + SSH_KEY_MAXAMMANN_ORG: + required: false + inputs: + deploy: + required: true + type: boolean + webgl: + required: true + type: boolean + +jobs: + library-web: + name: Build + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: extractions/setup-just@v1 + - name: Install nightly toolchain + shell: bash + run: just nightly-toolchain + - uses: Swatinem/rust-cache@v1 + - name: Build lib + if: inputs.webgl + shell: bash + run: just web-lib esbuild-webgl + - name: Build lib + if: "!inputs.webgl" + shell: bash + run: just web-lib esbuild + - name: Build demo + shell: bash + run: just web-demo build + - name: Check + if: inputs.webgl + shell: bash + run: just web-check "web-webgl" + - name: Check + if: "!inputs.webgl" + shell: bash + run: just web-check "" + - name: Test + if: inputs.webgl + shell: bash + run: | + cargo install wasm-bindgen-cli --version "0.2.80" + just web-test "web-webgl" + - name: Test + if: "!inputs.webgl" + shell: bash + run: | + cargo install wasm-bindgen-cli --version "0.2.80" + just web-test "" + - uses: actions/upload-artifact@v2 + with: + name: webgpu-demo + path: web/demo/dist/ + deploy: + needs: library-web + if: inputs.deploy + name: Deploy + runs-on: ubuntu-20.04 + steps: + - uses: actions/download-artifact@v2 + with: + name: webgpu-demo + - name: Deploy + if: "!inputs.webgl" + uses: ./.github/actions/deploy + with: + source: . + destination: webgl + key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} + - name: Deploy + if: "!inputs.webgl" + uses: ./.github/actions/deploy + with: + source: . + destination: webgpu + key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} diff --git a/.github/workflows/on_main_push.yml b/.github/workflows/on_main_push.yml index a1633e7c..5d4a518b 100644 --- a/.github/workflows/on_main_push.yml +++ b/.github/workflows/on_main_push.yml @@ -8,82 +8,37 @@ on: jobs: run-check: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/check + uses: ./.github/workflows/run-checks.yml run-benchmarks: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/benchmarks + uses: ./.github/workflows/run-benchmarks.yml run-tests: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/tests - build-android: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/android - build-deploy-webgpu: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/webgpu - - uses: ./.github/actions/deploy - with: - source: web/demo/dist/. - 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: - source: web/demo/dist/. - destination: webgl - key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} + uses: ./.github/workflows/run-tests.yml build-deploy-docs: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/docs - - uses: ./.github/actions/deploy - with: - source: target/doc/. - destination: api-docs - key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} - - uses: ./.github/actions/deploy - with: - source: docs/book/. - destination: docs - key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }} - build-apple: - runs-on: macos-11 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/apple - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - build-demo-linux: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/demo/linux - build-demo-windows: - runs-on: windows-2022 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/demo/windows - build-demo-macos: - runs-on: macos-11 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/demo/macos - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: ./.github/workflows/build-deploy-docs.yml + with: + deploy: true + secrets: inherit + library-android: + uses: ./.github/workflows/library-android.yml + library-webgpu: + uses: ./.github/workflows/library-web.yml + with: + deploy: true + webgl: false + secrets: inherit + library-webgl: + uses: ./.github/workflows/library-web.yml + with: + deploy: true + webgl: true + secrets: inherit + library-apple: + uses: ./.github/workflows/library-apple.yml + demo-linux: + uses: ./.github/workflows/demo-linux.yml + demo-windows: + uses: ./.github/workflows/demo-windows.yml + demo-macos: + uses: ./.github/workflows/demo-macos.yml + secrets: inherit diff --git a/.github/workflows/on_pull_request.yml b/.github/workflows/on_pull_request.yml index 65b86dfd..c5a827f9 100644 --- a/.github/workflows/on_pull_request.yml +++ b/.github/workflows/on_pull_request.yml @@ -8,61 +8,33 @@ on: jobs: run-check: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/check + uses: ./.github/workflows/run-checks.yml run-benchmarks: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/benchmarks + uses: ./.github/workflows/run-benchmarks.yml run-tests: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/tests - build-android: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/android - 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 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/docs - build-apple: - runs-on: macos-11 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/apple - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - build-demo-linux: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/demo/linux - build-demo-windows: - runs-on: windows-2022 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/demo/windows - build-demo-macos: - runs-on: macos-11 - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/demo/macos - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: ./.github/workflows/run-tests.yml + build-deploy-docs: + uses: ./.github/workflows/build-deploy-docs.yml + with: + deploy: false + library-android: + uses: ./.github/workflows/library-android.yml + library-webgpu: + uses: ./.github/workflows/library-web.yml + with: + deploy: false + webgl: false + library-webgl: + uses: ./.github/workflows/library-web.yml + with: + deploy: false + webgl: true + library-apple: + uses: ./.github/workflows/library-apple.yml + demo-linux: + uses: ./.github/workflows/demo-linux.yml + demo-windows: + uses: ./.github/workflows/demo-windows.yml + demo-macos: + uses: ./.github/workflows/demo-macos.yml + secrets: inherit diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml new file mode 100644 index 00000000..cebc9b5a --- /dev/null +++ b/.github/workflows/run-benchmarks.yml @@ -0,0 +1,22 @@ +name: Run benchmarks + +on: + workflow_call: + +jobs: + run-benchmarks: + name: Benchmark + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - 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: Check + shell: bash + run: just check benchmarks x86_64-unknown-linux-gnu diff --git a/.github/workflows/run-checks.yml b/.github/workflows/run-checks.yml new file mode 100644 index 00000000..52d1ffc4 --- /dev/null +++ b/.github/workflows/run-checks.yml @@ -0,0 +1,19 @@ +name: Run checks + +on: + workflow_call: + +jobs: + run-checks: + name: Check + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: extractions/setup-just@v1 + - name: Install toolchain + shell: bash + run: just default-toolchain + - uses: Swatinem/rust-cache@v1 + - name: Format + shell: bash + run: just fmt-check diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 00000000..7d3cfda6 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,34 @@ +name: Run tests of "maplibre" + +on: + workflow_call: + +jobs: + run-tests: + name: Test + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: extractions/setup-just@v1 + - name: Install toolchain + shell: bash + run: just default-toolchain + - uses: Swatinem/rust-cache@v1 + - name: Install Mesa Dependencies + shell: bash + run: sudo apt install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers + - name: wgpu info + shell: bash + run: | + cargo install --git "https://github.com/gfx-rs/wgpu" wgpu-info + wgpu-info + - name: Test Vulkan + shell: bash + # TODO: Additional test runs for different targets + run: | + WGPU_BACKEND=vulkan just test maplibre x86_64-unknown-linux-gnu + - name: Test EGL + shell: bash + # TODO: Additional test runs for different targets + run: | + EGL_LOG_LEVEL=debug WGPU_BACKEND=gl just test maplibre x86_64-unknown-linux-gnu diff --git a/android/gradle/lib/build.gradle b/android/gradle/lib/build.gradle index cab3e794..2fbe4803 100644 --- a/android/gradle/lib/build.gradle +++ b/android/gradle/lib/build.gradle @@ -7,7 +7,7 @@ plugins { apply plugin: 'kotlin-android' android { - ndkVersion "23.1.7779620" + ndkVersion "23.2.8568313" compileSdkVersion 29 diff --git a/justfile b/justfile index de95a609..8bcb0c87 100644 --- a/justfile +++ b/justfile @@ -5,10 +5,15 @@ set shell := ["bash", "-c"] export NIGHTLY_TOOLCHAIN := "nightly-2022-04-04-x86_64-unknown-linux-gnu" +export CARGO_TERM_COLOR := "always" +export RUST_BACKTRACE := "1" install-clippy: rustup component add clippy +install-nightly-clippy: + rustup component add clippy --toolchain $NIGHTLY_TOOLCHAIN + check PROJECT ARCH: install-clippy cargo clippy --no-deps -p {{PROJECT}} --target {{ARCH}} @@ -45,6 +50,9 @@ web-lib TARGET: nightly-toolchain (web-install "lib") web-demo TARGET: (web-install "demo") cd web/demo && npm run {{TARGET}} +web-check FEATURES: nightly-toolchain install-nightly-clippy + export RUSTUP_TOOLCHAIN=$NIGHTLY_TOOLCHAIN && cargo clippy --no-deps -p web --features "{{FEATURES}}" --target wasm32-unknown-unknown -Z build-std=std,panic_abort + web-test FEATURES: nightly-toolchain export RUSTUP_TOOLCHAIN=$NIGHTLY_TOOLCHAIN && cargo test -p web --features "{{FEATURES}}" --target wasm32-unknown-unknown -Z build-std=std,panic_abort diff --git a/maplibre-build-tools/Cargo.toml b/maplibre-build-tools/Cargo.toml index c7469d92..e44f51fe 100644 --- a/maplibre-build-tools/Cargo.toml +++ b/maplibre-build-tools/Cargo.toml @@ -12,7 +12,7 @@ readme = "../README.md" sqlite = ["rusqlite"] [dependencies] -naga = { version = "0.8", features = ["wgsl-in"] } +naga = { git = "https://github.com/gfx-rs/naga", branch = "master", features = ["wgsl-in"] } walkdir = "2.3" log = "0.4" rusqlite = {version= "0.26", optional=true} diff --git a/maplibre-build-tools/src/wgsl.rs b/maplibre-build-tools/src/wgsl.rs index eb5a1156..e7fd5e00 100644 --- a/maplibre-build-tools/src/wgsl.rs +++ b/maplibre-build-tools/src/wgsl.rs @@ -4,7 +4,7 @@ use std::process::exit; use naga::front::wgsl; use naga::valid::{Capabilities, ValidationFlags, Validator}; -use naga::{front::wgsl::ParseError, valid::ValidationError}; +use naga::{front::wgsl::ParseError, valid::ValidationError, SourceLocation}; use walkdir::WalkDir; #[derive(Debug)] @@ -12,8 +12,7 @@ pub enum WgslError { ValidationErr(ValidationError), ParserErr { error: String, - line: usize, - pos: usize, + location: Option, }, IoErr(std::io::Error), } @@ -26,9 +25,9 @@ impl From for WgslError { impl WgslError { pub fn from_parse_err(err: ParseError, src: &str) -> Self { - let (line, pos) = err.location(src); + let location = err.location(src); let error = err.emit_to_string(src); - Self::ParserErr { error, line, pos } + Self::ParserErr { error, location } } } @@ -72,8 +71,17 @@ pub fn validate_project_wgsl() { path.to_str().unwrap(), match err { WgslError::ValidationErr(error) => format!(": {:?}", error), - WgslError::ParserErr { error, line, pos } => - format!(":{}:{} {}", line, pos, error), + WgslError::ParserErr { error, location } => + if let Some(SourceLocation { + line_number, + line_position, + .. + }) = location + { + format!(":{}:{} {}", line_number, line_position, error) + } else { + format!("{}", error) + }, WgslError::IoErr(error) => format!(": {:?}", error), } ); diff --git a/maplibre/Cargo.toml b/maplibre/Cargo.toml index ac9de778..35ffbcb2 100644 --- a/maplibre/Cargo.toml +++ b/maplibre/Cargo.toml @@ -50,7 +50,9 @@ geozero = { version = "0.9.4", default-features = false, features = ["with-mvt", tile-grid = "0.3" # Rendering -wgpu = { version = "0.12" } +wgpu = { git = "https://github.com/gfx-rs/wgpu.git", branch = "master" } +wgpu-core = { git = "https://github.com/gfx-rs/wgpu.git", branch = "master" } +wgpu-hal = { git = "https://github.com/gfx-rs/wgpu.git", branch = "master" } lyon = { version = "0.17", features = [] } raw-window-handle = "0.4" diff --git a/maplibre/src/render/mod.rs b/maplibre/src/render/mod.rs index 7f38200e..7f136cac 100644 --- a/maplibre/src/render/mod.rs +++ b/maplibre/src/render/mod.rs @@ -384,6 +384,7 @@ mod tests { use crate::render::graph_runner::RenderGraphRunner; use crate::render::resource::Surface; use crate::{MapWindow, MapWindowConfig, RenderState, Renderer, RendererSettings, WindowSize}; + use log::LevelFilter; pub struct HeadlessMapWindowConfig { size: WindowSize, @@ -409,18 +410,16 @@ mod tests { #[cfg(not(target_arch = "wasm32"))] #[tokio::test] - #[ignore] // FIXME: We do not have a GPU in CI async fn test_render() { + let _ = env_logger::builder() + .filter_level(LevelFilter::Trace) + .is_test(true) + .try_init(); let graph = RenderGraph::default(); - let instance = wgpu::Instance::new(wgpu::Backends::all()); - - let adapter = instance - .request_adapter(&wgpu::RequestAdapterOptions { - power_preference: Default::default(), - force_fallback_adapter: false, - compatible_surface: None, - }) + let backends = wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::all()); + let instance = wgpu::Instance::new(backends); + let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, backends, None) .await .unwrap(); diff --git a/maplibre/src/render/resource/surface.rs b/maplibre/src/render/resource/surface.rs index e18c3f83..3e56237d 100644 --- a/maplibre/src/render/resource/surface.rs +++ b/maplibre/src/render/resource/surface.rs @@ -71,42 +71,40 @@ impl BufferedTextureHead { ) { // Note that we're not calling `.await` here. let buffer_slice = self.output_buffer.slice(..); - let buffer_future = buffer_slice.map_async(wgpu::MapMode::Read); + let buffer_future = buffer_slice.map_async(wgpu::MapMode::Read, |_| ()); // Poll the device in a blocking manner so that our future resolves. // In an actual application, `device.poll(...)` should // be called in an event loop or on another thread. device.poll(wgpu::Maintain::Wait); - if let Ok(()) = buffer_future.await { - let padded_buffer = buffer_slice.get_mapped_range(); + let padded_buffer = buffer_slice.get_mapped_range(); - let mut png_encoder = png::Encoder::new( - File::create(png_output_path).unwrap(), - self.buffer_dimensions.width as u32, - self.buffer_dimensions.height as u32, - ); - png_encoder.set_depth(png::BitDepth::Eight); - png_encoder.set_color(png::ColorType::Rgba); - let mut png_writer = png_encoder - .write_header() - .unwrap() - .into_stream_writer_with_size(self.buffer_dimensions.unpadded_bytes_per_row) + let mut png_encoder = png::Encoder::new( + File::create(png_output_path).unwrap(), + self.buffer_dimensions.width as u32, + self.buffer_dimensions.height as u32, + ); + png_encoder.set_depth(png::BitDepth::Eight); + png_encoder.set_color(png::ColorType::Rgba); + let mut png_writer = png_encoder + .write_header() + .unwrap() + .into_stream_writer_with_size(self.buffer_dimensions.unpadded_bytes_per_row) + .unwrap(); + + // from the padded_buffer we write just the unpadded bytes into the image + for chunk in padded_buffer.chunks(self.buffer_dimensions.padded_bytes_per_row) { + png_writer + .write_all(&chunk[..self.buffer_dimensions.unpadded_bytes_per_row]) .unwrap(); - - // from the padded_buffer we write just the unpadded bytes into the image - for chunk in padded_buffer.chunks(self.buffer_dimensions.padded_bytes_per_row) { - png_writer - .write_all(&chunk[..self.buffer_dimensions.unpadded_bytes_per_row]) - .unwrap(); - } - png_writer.finish().unwrap(); - - // With the current interface, we have to make sure all mapped views are - // dropped before we unmap the buffer. - drop(padded_buffer); - - self.output_buffer.unmap(); } + png_writer.finish().unwrap(); + + // With the current interface, we have to make sure all mapped views are + // dropped before we unmap the buffer. + drop(padded_buffer); + + self.output_buffer.unmap(); } } diff --git a/maplibre/src/render/shaders/tile.fragment.wgsl b/maplibre/src/render/shaders/tile.fragment.wgsl index 62305297..977de422 100644 --- a/maplibre/src/render/shaders/tile.fragment.wgsl +++ b/maplibre/src/render/shaders/tile.fragment.wgsl @@ -1,8 +1,8 @@ struct Output { - [[location(0)]] out_color: vec4; + @location(0) out_color: vec4, }; -[[stage(fragment)]] -fn main([[location(0)]] v_color: vec4) -> Output { +@fragment +fn main(@location(0) v_color: vec4) -> Output { return Output(v_color); } diff --git a/maplibre/src/render/shaders/tile.vertex.wgsl b/maplibre/src/render/shaders/tile.vertex.wgsl index 74232d23..fd3ed512 100644 --- a/maplibre/src/render/shaders/tile.vertex.wgsl +++ b/maplibre/src/render/shaders/tile.vertex.wgsl @@ -1,31 +1,31 @@ struct ShaderCamera { - view_proj: mat4x4; - view_position: vec4; + view_proj: mat4x4, + view_position: vec4, }; struct ShaderGlobals { - camera: ShaderCamera; + camera: ShaderCamera, }; -[[group(0), binding(0)]] var globals: ShaderGlobals; +@group(0) @binding(0) var globals: ShaderGlobals; struct VertexOutput { - [[location(0)]] v_color: vec4; - [[builtin(position)]] position: vec4; + @location(0) v_color: vec4, + @builtin(position) position: vec4, }; -[[stage(vertex)]] +@vertex fn main( - [[location(0)]] position: vec2, - [[location(1)]] normal: vec2, - [[location(4)]] translate1: vec4, - [[location(5)]] translate2: vec4, - [[location(6)]] translate3: vec4, - [[location(7)]] translate4: vec4, - [[location(8)]] color: vec4, - [[location(9)]] zoom_factor: f32, - [[location(10)]] z_index: f32, - [[builtin(instance_index)]] instance_idx: u32 // instance_index is used when we have multiple instances of the same "object" + @location(0) position: vec2, + @location(1) normal: vec2, + @location(4) translate1: vec4, + @location(5) translate2: vec4, + @location(6) translate3: vec4, + @location(7) translate4: vec4, + @location(8) color: vec4, + @location(9) zoom_factor: f32, + @location(10) z_index: f32, + @builtin(instance_index) instance_idx: u32 // instance_index is used when we have multiple instances of the same "object" ) -> VertexOutput { let z = 0.0; let width = 3.0 * zoom_factor; diff --git a/maplibre/src/render/shaders/tile_mask.fragment.wgsl b/maplibre/src/render/shaders/tile_mask.fragment.wgsl index 62305297..977de422 100644 --- a/maplibre/src/render/shaders/tile_mask.fragment.wgsl +++ b/maplibre/src/render/shaders/tile_mask.fragment.wgsl @@ -1,8 +1,8 @@ struct Output { - [[location(0)]] out_color: vec4; + @location(0) out_color: vec4, }; -[[stage(fragment)]] -fn main([[location(0)]] v_color: vec4) -> Output { +@fragment +fn main(@location(0) v_color: vec4) -> Output { return Output(v_color); } diff --git a/maplibre/src/render/shaders/tile_mask.vertex.wgsl b/maplibre/src/render/shaders/tile_mask.vertex.wgsl index 5f899fdd..5d866e56 100644 --- a/maplibre/src/render/shaders/tile_mask.vertex.wgsl +++ b/maplibre/src/render/shaders/tile_mask.vertex.wgsl @@ -1,29 +1,29 @@ struct ShaderCamera { - view_proj: mat4x4; - view_position: vec4; + view_proj: mat4x4, + view_position: vec4, }; struct ShaderGlobal { - camera: ShaderCamera; + camera: ShaderCamera, }; -[[group(0), binding(0)]] var globals: ShaderGlobal; +@group(0) @binding(0) var globals: ShaderGlobal; struct VertexOutput { - [[location(0)]] v_color: vec4; - [[builtin(position)]] position: vec4; + @location(0) v_color: vec4, + @builtin(position) position: vec4, }; let EXTENT = 4096.0; -[[stage(vertex)]] +@vertex fn main( - [[location(4)]] translate1: vec4, - [[location(5)]] translate2: vec4, - [[location(6)]] translate3: vec4, - [[location(7)]] translate4: vec4, - [[builtin(vertex_index)]] vertex_idx: u32, - [[builtin(instance_index)]] instance_idx: u32 // instance_index is used when we have multiple instances of the same "object" + @location(4) translate1: vec4, + @location(5) translate2: vec4, + @location(6) translate3: vec4, + @location(7) translate4: vec4, + @builtin(vertex_index) vertex_idx: u32, + @builtin(instance_index) instance_idx: u32 // instance_index is used when we have multiple instances of the same "object" ) -> VertexOutput { let z = 0.0;