mirror of
https://github.com/Xevion/smart-rgb.git
synced 2025-12-15 10:13:19 -06:00
Update source files
This commit is contained in:
74
Justfile
Normal file
74
Justfile
Normal file
@@ -0,0 +1,74 @@
|
||||
set shell := ["powershell"]
|
||||
|
||||
default:
|
||||
just --list
|
||||
|
||||
check:
|
||||
@echo "Running clippy (native)..."
|
||||
@cargo clippy --all-targets --all-features --workspace -- -D warnings
|
||||
@echo "Running cargo check (native)..."
|
||||
@cargo check --all-targets --all-features --workspace
|
||||
@echo "Running clippy (wasm32-unknown-unknown)..."
|
||||
@cargo clippy --target wasm32-unknown-unknown --all-features -p borders-wasm -- -D warnings
|
||||
@echo "Running cargo check (wasm32-unknown-unknown)..."
|
||||
@cargo check --target wasm32-unknown-unknown --all-features -p borders-wasm
|
||||
@echo "Running cargo machete..."
|
||||
@cargo machete --with-metadata
|
||||
@echo "All checks passed"
|
||||
|
||||
check-ts:
|
||||
@just _wasm-build wasm-dev
|
||||
@echo "Running frontend checks..."
|
||||
@pnpm run -C frontend check
|
||||
|
||||
fix:
|
||||
@echo "Running cargo fix..."
|
||||
cargo fix --all-targets --all-features --workspace --allow-dirty
|
||||
|
||||
wasm-dev: wasm-dev-build
|
||||
pnpm -C frontend dev:browser --port 1421
|
||||
|
||||
# Build WASM with the specified profile (wasm-dev or wasm-release)
|
||||
_wasm-build profile:
|
||||
@$profile = "{{ profile }}"; \
|
||||
$wasmFile = "target/wasm32-unknown-unknown/$profile/borders_wasm.wasm"; \
|
||||
$pkgJs = "pkg/borders.js"; \
|
||||
$pkgWasm = "pkg/borders_bg.wasm"; \
|
||||
$frontendPkgJs = "frontend/pkg/borders.js"; \
|
||||
$frontendPkgWasm = "frontend/pkg/borders_bg.wasm"; \
|
||||
$beforeTime = if (Test-Path $wasmFile) { (Get-Item $wasmFile).LastWriteTime } else { $null }; \
|
||||
cargo build -p borders-wasm --profile $profile --target wasm32-unknown-unknown; \
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }; \
|
||||
$afterTime = if (Test-Path $wasmFile) { (Get-Item $wasmFile).LastWriteTime } else { $null }; \
|
||||
$wasRebuilt = ($beforeTime -eq $null) -or ($afterTime -ne $beforeTime); \
|
||||
$pkgExists = (Test-Path $pkgJs) -and (Test-Path $pkgWasm); \
|
||||
$frontendPkgExists = (Test-Path $frontendPkgJs) -and (Test-Path $frontendPkgWasm); \
|
||||
$isRelease = $profile -eq "wasm-release"; \
|
||||
if ($wasRebuilt -or -not $pkgExists -or ($isRelease -and -not $frontendPkgExists)) { \
|
||||
Write-Host "Running wasm-bindgen..."; \
|
||||
wasm-bindgen --out-dir pkg --out-name borders --target web $wasmFile; \
|
||||
if ($isRelease) { \
|
||||
Write-Host "Running wasm-opt..."; \
|
||||
wasm-opt -Oz --enable-bulk-memory --enable-threads --all-features pkg/borders_bg.wasm -o pkg/borders_bg.wasm; \
|
||||
}; \
|
||||
} else { \
|
||||
Write-Host "WASM not rebuilt, skipping wasm-bindgen"; \
|
||||
} \
|
||||
New-Item -ItemType Directory -Force -Path 'frontend/pkg' | Out-Null; \
|
||||
Copy-Item -Recurse -Force 'pkg/*' 'frontend/pkg/'; \
|
||||
if ($isRelease) { \
|
||||
Write-Host "Running frontend build..."; \
|
||||
pnpm -C frontend build:browser; \
|
||||
}; \
|
||||
|
||||
# Development WASM build, unoptimized
|
||||
wasm-dev-build:
|
||||
@just _wasm-build wasm-dev
|
||||
|
||||
# Release WASM build, optimized
|
||||
wasm-release-build:
|
||||
@just _wasm-build wasm-release
|
||||
|
||||
wasm-release: wasm-release-build
|
||||
@echo "Visit http://localhost:8080 to play"
|
||||
caddy file-server --listen :8080 --root frontend/dist/browser/client --browse
|
||||
Reference in New Issue
Block a user