Musings from the mountains himwant.org

Add Depth Anything v3 Burn WASM

+57 -2
+57 -2
.tangled/workflows/deploy.yaml
··· 7 7 nixpkgs: 8 8 - nodejs 9 9 - bash 10 + - git 11 + - cacert 12 + - cargo 13 + - rustc 14 + - wasm-pack 15 + - clang # Compiler 16 + - llvm # Provides llvm-ar and other tools often needed by burn 10 17 11 18 steps: 12 19 - name: install dependencies 13 20 command: npm install 14 21 22 + - name: build external wasm models 23 + environment: 24 + MODEL_REPOS: >- 25 + https://tangled.org/akshitgaur2005.tngl.sh/depth_anything_v3_burn|depth 26 + command: | 27 + # --- FIX START --- 28 + # 1. Completely clear Nix wrapper flags 29 + # These variables are what force the compiler to look at Linux headers 30 + unset NIX_CFLAGS_COMPILE 31 + unset NIX_LDFLAGS 32 + unset C_INCLUDE_PATH 33 + unset CPATH 34 + unset LIBRARY_PATH 35 + 36 + # 2. Configure Clang for WASM 37 + export CC_wasm32_unknown_unknown=clang 38 + 39 + # 3. Force "No Standard Includes" (-nostdinc) 40 + # This stops Clang from looking at /nix/store/.../glibc/include 41 + # But we must manually add back Clang's internal headers (stddef.h, limits.h, etc.) 42 + CLANG_RES_DIR=$(clang -print-resource-dir)/include 43 + export CFLAGS_wasm32_unknown_unknown="-nostdinc -I${CLANG_RES_DIR} -Wno-macro-redefined" 44 + # --- FIX END --- 45 + 46 + mkdir -p public/wasm 47 + mkdir -p temp_build 48 + cd temp_build 49 + 50 + for entry in $MODEL_REPOS; do 51 + url="${entry%%|*}" 52 + name="${entry##*|}" 53 + 54 + echo "--- Processing: $name from $url ---" 55 + git clone "$url" "$name" 56 + 57 + cd "$name" 58 + echo "Checking out 'web' branch..." 59 + git checkout web 60 + 61 + echo "Building WASM..." 62 + wasm-pack build --target web --out-dir ../../public/wasm/$name --no-typescript --release 63 + 64 + rm -f ../../public/wasm/$name/.gitignore 65 + cd .. 66 + done 67 + 68 + cd .. 69 + rm -rf temp_build 70 + 15 71 - name: build site 16 - # Use 'npm run build' which runs 'astro build' 17 72 command: npm run build 18 73 19 74 - name: deploy 20 75 command: | 21 - npx --yes wrangler pages deploy dist --project-name himwant --branch main 76 + npx --yes wrangler pages deploy dist --project-name himwant --branch main