#!/bin/bash
echo "=== OLD BUILD STATE ==="
if [ -d ~/pytorch-build ]; then
    echo "Dir exists: $(du -sh ~/pytorch-build)"
    ls ~/pytorch-build/
    
    if [ -d ~/pytorch-build/pytorch ]; then
        echo "--- PyTorch source dir ---"
        ls ~/pytorch-build/pytorch/ | head -20
        echo "..."
        cd ~/pytorch-build/pytorch
        echo "--- Git info ---"
        git log --oneline -1 2>/dev/null || echo "Not a git repo"
        git describe --tags 2>/dev/null || echo "No tags"
        echo "--- Submodule count ---"
        git submodule status 2>/dev/null | wc -l
        echo "--- Failed submodules ---"
        git submodule status 2>/dev/null | grep "^-" | head -10
        echo "--- Hipify check ---"
        [ -d "aten/src/ATen/hip" ] && echo "Hipify: DONE" || echo "Hipify: NOT DONE"
        [ -d "build" ] && echo "Build dir: $(du -sh build)" || echo "No build dir"
        ls dist/*.whl 2>/dev/null || echo "No wheel yet"
    fi
else
    echo "NO pytorch-build dir"
fi

echo "=== DEPS ==="
nproc
cmake --version 2>/dev/null | head -1
ninja --version 2>/dev/null || echo "No ninja"
hipcc --version 2>/dev/null | head -3
python3.11 -c "import numpy; print('numpy:', numpy.__version__)" 2>/dev/null || echo "No numpy"
df -h / | tail -1
echo "=== DONE ==="
