📜 BUILD SCRIPTS - GUÍA DE USO¶
Scripts automatizados para compilar y limpiar AudioLab en todas las plataformas.
📦 SCRIPTS DISPONIBLES¶
| Script | Plataforma | Propósito |
|---|---|---|
build.sh |
Unix/macOS | Compilar proyecto |
build.ps1 |
Windows | Compilar proyecto |
clean.sh |
Unix/macOS | Limpiar builds |
clean.ps1 |
Windows | Limpiar builds |
🔨 BUILD SCRIPTS¶
Unix/macOS: build.sh¶
Uso Básico¶
# Build debug (default)
./build.sh
# Build release
./build.sh --config Release
# Clean + build
./build.sh --clean
# Build verboso
./build.sh --verbose
# Parallelismo personalizado
./build.sh --parallel 16
Todas las Opciones¶
./build.sh [opciones]
Opciones:
--config <type> Build type (Debug|Release|RelWithDebInfo)
--preset <name> CMake preset name
--clean Clean before building
--parallel <n> Number of parallel jobs (0 = auto-detect)
--verbose Show detailed output
--help Show help message
Ejemplos¶
# Development build
./build.sh --config Debug
# Release optimizado
./build.sh --config Release --parallel 8
# Clean build con preset
./build.sh --clean --preset release
# Debug verboso para troubleshooting
./build.sh --verbose --config Debug
Windows: build.ps1¶
Uso Básico¶
# Build debug (default)
.\build.ps1
# Build release
.\build.ps1 -Config Release
# Clean + build
.\build.ps1 -Clean
# Build verboso
.\build.ps1 -Verbose
Todas las Opciones¶
.\build.ps1 [opciones]
Opciones:
-Config <type> Build type (Debug|Release|RelWithDebInfo)
-Preset <name> CMake preset name
-Clean Clean before building
-Parallel <n> Number of parallel jobs (0 = auto)
-Verbose Show detailed output
-Help Show help message
Ejemplos¶
# Development build
.\build.ps1 -Config Debug
# Release optimizado
.\build.ps1 -Config Release -Parallel 8
# Clean build con preset
.\build.ps1 -Clean -Preset release
# Debug verboso
.\build.ps1 -Verbose -Config Debug
🧹 CLEAN SCRIPTS¶
Unix/macOS: clean.sh¶
Uso Básico¶
# Limpiar build directory (con confirmación)
./clean.sh
# Limpiar TODO (force, sin confirmación)
./clean.sh --all --force
# Solo limpiar cache de CMake
./clean.sh --cache
# Solo limpiar downloads de vcpkg
./clean.sh --vcpkg
Todas las Opciones¶
./clean.sh [opciones]
Opciones:
--all Limpiar TODO (build + cache + vcpkg)
--build Limpiar solo build directory
--cache Limpiar solo CMake cache
--vcpkg Limpiar solo vcpkg downloads
--force No pedir confirmación
¿Qué Limpia Cada Opción?¶
| Opción | Limpia | Tamaño Liberado | Tiempo para Rebuild |
|---|---|---|---|
| (default) | build/ |
100-500 MB | 2-5 min |
--cache |
CMakeCache.txt |
< 1 MB | Instant |
--vcpkg |
vcpkg/downloads/ |
500+ MB | N/A (re-descarga) |
--all |
Todo lo anterior | 600+ MB | 2-5 min + re-download |
Ejemplos¶
# Limpiar build (con confirmación)
./clean.sh
# Limpiar build sin preguntar
./clean.sh --build --force
# Limpiar cache para reconfigurar
./clean.sh --cache
# Limpiar TODO (nuclear option)
./clean.sh --all --force
Windows: clean.ps1¶
Mismo comportamiento que clean.sh pero para Windows PowerShell.
# Limpiar build directory
.\clean.ps1
# Limpiar TODO
.\clean.ps1 -All -Force
# Solo cache
.\clean.ps1 -Cache
🎯 CASOS DE USO COMUNES¶
Caso 1: Build Diario (Development)¶
# Primer build del día
./build.sh --config Debug
# Rebuilds incrementales (automáticamente solo recompila cambios)
./build.sh
Caso 2: Build de Release para Distribución¶
# Clean release build
./build.sh --clean --config Release
# Con optimizaciones usando preset
./build.sh --preset release
Caso 3: Algo Salió Mal - Rebuild Completo¶
Caso 4: Cambios en CMakeLists.txt¶
# Solo limpiar cache para reconfigurar
./clean.sh --cache
# Rebuild (CMake reconfigurará)
./build.sh
Caso 5: Liberar Espacio en Disco¶
# Eliminar downloads de vcpkg (se re-descargarán si es necesario)
./clean.sh --vcpkg --force
# O limpiar builds viejos
./clean.sh --build --force
🔍 QUÉ HACE CADA SCRIPT¶
build.sh / build.ps1¶
Internamente ejecuta:
- Verificación de Requisitos
- Verifica que CMake esté instalado
- Verifica que compilador esté disponible
-
Detecta Ninja (opcional pero recomendado)
-
Configuración (si no existe CMakeCache.txt)
-
Compilación
-
Resultado
- Binarios en:
build/<config>/bin/ - Librerías en:
build/<config>/lib/
Output del Script:
╔════════════════════════════════════════════╗
║ 🚀 AudioLab Build Script ║
╚════════════════════════════════════════════╝
📁 Project Root: /path/to/audio-lab
🔍 Verificando herramientas...
✓ CMake: 3.27.0
✓ Ninja: Available
📦 Build Directory: build/Debug
⚙️ Configurando proyecto...
Comando: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
✓ Configuración exitosa
🔨 Compilando proyecto...
Config: Debug
Parallel: 8 jobs
[compilation output...]
╔════════════════════════════════════════════╗
║ ✅ Build exitoso ║
╚════════════════════════════════════════════╝
⏱️ Tiempo: 45s
📦 Binarios: build/Debug/bin
clean.sh / clean.ps1¶
Opciones de Limpieza:
╔════════════════════════════════════════════╗
║ 🧹 AudioLab Clean Script ║
╚════════════════════════════════════════════╝
📁 Project Root: /path/to/audio-lab
🗑️ Build directory: /path/to/build
Eliminar? (y/N): y
✓ Build directory eliminado
✅ Limpieza completa
💡 TIPS Y TRICKS¶
Tip 1: Alias para Builds Rápidos¶
Agrega a tu ~/.bashrc o ~/.zshrc:
# AudioLab build aliases
alias abuild='cd /path/to/audio-lab && ./2\ -\ FOUNDATION/03_INFRA/03_02_build_infrastructure/03_02_03_build_scripts/build.sh'
alias aclean='cd /path/to/audio-lab && ./2\ -\ FOUNDATION/03_INFRA/03_02_build_infrastructure/03_02_03_build_scripts/clean.sh'
alias arebuild='aclean --force && abuild'
Uso:
Tip 2: Hacer Scripts Ejecutables (Primera Vez)¶
Unix/macOS:
Windows: No necesario, PowerShell ejecuta .ps1 directamente.
Tip 3: Build en Background¶
# Build en background con output a log
./build.sh --config Release > build.log 2>&1 &
# Monitorear progreso
tail -f build.log
Tip 4: Múltiples Configuraciones Paralelas¶
# Terminal 1
./build.sh --config Debug &
# Terminal 2
./build.sh --config Release &
# Ambos usan directorios separados, no hay conflicto
Tip 5: Integración con IDEs¶
VSCode (tasks.json):
{
"version": "2.0.0",
"tasks": [
{
"label": "Build AudioLab",
"type": "shell",
"command": "./2 - FOUNDATION/03_INFRA/03_02_build_infrastructure/03_02_03_build_scripts/build.sh",
"args": ["--config", "Debug"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
🚨 TROUBLESHOOTING¶
Problema: "Permission denied"¶
Solución:
Problema: "CMake not found"¶
Solución: Instalar CMake:
# macOS
brew install cmake
# Ubuntu/Debian
sudo apt install cmake
# Windows
winget install Kitware.CMake
Problema: Build falla sin mensaje claro¶
Solución: Usar --verbose para ver comandos exactos:
Esto mostrará el comando de compilación que falló.
Problema: Build muy lento¶
Soluciones:
-
Usar Ninja:
-
Más paralelismo:
-
Limpiar y rebuild:
📊 TIEMPOS ESPERADOS¶
Con SSD, CPU moderno (8+ cores):
| Operación | Tiempo | Notas |
|---|---|---|
| First configure | 5-30s | Detecta toolchain, dependencies |
| Clean build (Debug) | 2-5 min | Todo desde cero |
| Clean build (Release) | 3-8 min | Optimizaciones toman tiempo |
| Incremental rebuild | 5-60s | Solo cambios |
| Clean operation | < 5s | Borrar archivos |
Si tu build toma >15 min: Algo está mal, ver optimizaciones arriba.
📚 RECURSOS¶
- Comandos CMake manual: CMAKE_CHEAT_SHEET.md
- Tutorial completo: QUICK_START.md
- Troubleshooting: BUILD_TROUBLESHOOTING_PHILOSOPHY.md
Última actualización: 2025-10-09