π BUILD INFRASTRUCTURE - GUΓA MAESTRA¶
Sistema de ConstrucciΓ³n para AudioLab¶
"Un build system transforma potencial (cΓ³digo fuente) en realidad (software ejecutable)"
π TABLA DE CONTENIDOS¶
- VisiΓ³n General
- Quick Start
- Rutas de Aprendizaje
- Estructura de DocumentaciΓ³n
- Scripts de Build
- Troubleshooting
- Recursos
π― VISIΓN GENERAL¶
Este directorio contiene la infraestructura completa para construir proyectos AudioLab. No es solo "cΓ³mo compilar"βes un sistema completo de transformaciΓ³n de cΓ³digo a software distribuible.
π ΒΏQuΓ© AprenderΓ‘s AquΓ?¶
π NIVEL 1: Fundamentos
ββ ΒΏQuΓ© es un build? ΒΏPor quΓ© es complejo?
π NIVEL 2: Herramientas
ββ CMake, compiladores, linkers, toolchains
π NIVEL 3: OptimizaciΓ³n
ββ LTO, PGO, SIMD, compilation speeds
π NIVEL 4: Cross-Platform
ββ Windows, macOS, Linux builds unificados
π NIVEL 5: Troubleshooting
ββ Diagnosticar y resolver errores de build
ποΈ Pipeline de Build¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β π CΓ³digo C++ β π TransformaciΓ³n β
β (.cpp, .h) (build system) β
β β β
β 1οΈβ£ Preprocessing β
β 2οΈβ£ Compilation β
β 3οΈβ£ Linking β
β 4οΈβ£ Post-processing β
β β β
β π― Software β π¦ Empaquetado β
β (.exe, .vst3) (deployment) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π QUICK START¶
Para Usuarios (Solo quiero compilar)¶
# 1. Clonar el repositorio
git clone https://github.com/audiolab/audio-lab.git
cd audio-lab
# 2. Build rΓ‘pido
./2 - FOUNDATION/03_INFRA/03_02_build_infrastructure/03_02_03_build_scripts/build.sh
# Windows: .\build.ps1
# 3. Ejecutar
./build/Debug/bin/your-app
ΒΏProblemas? β Ver QUICK_START.md
Para Desarrolladores (Quiero entender)¶
# 1. Leer filosofΓa (30 min)
BUILD_SYSTEMS_PHILOSOPHY.md
# 2. Tutorial prΓ‘ctico (1 hora)
QUICK_START.md
# 3. Cheat sheet de comandos
CMAKE_CHEAT_SHEET.md
# 4. Configurar tu entorno
03_02_01_toolchains/TOOLCHAIN_PHILOSOPHY.md
π€οΈ RUTAS DE APRENDIZAJE¶
π± RUTA 1: PRINCIPIANTE (Nunca usΓ© CMake)¶
Objetivo: Poder compilar proyectos existentes
Secuencia (4-6 horas):
- QUICK_START.md (1 hora)
- π― Tu primer build exitoso
- Entender quΓ© hace cada paso
-
Resolver problemas bΓ‘sicos
-
BUILD_SYSTEMS_PHILOSOPHY.md - CapΓtulos 1-2 (1 hora)
- π Lee: La naturaleza de la transformaciΓ³n
- π Lee: ΒΏPor quΓ© CMake?
-
π― Objetivo: Entender QUΓ es un build
-
CMAKE_CHEAT_SHEET.md (30 min)
- π Bookmarkea este archivo
-
π― Objetivo: Comandos esenciales a mano
-
Scripts de Build (30 min)
- π Lee: 03_02_03_build_scripts/README.md
-
π― Objetivo: Usar scripts sin pensar en CMake
-
Troubleshooting BΓ‘sico (1 hora)
- π Lee: 03_02_05_troubleshooting/build_issues.md
- π― Objetivo: Resolver errores comunes
β Al Completar: Puedes compilar AudioLab en Debug/Release, resolver errores bΓ‘sicos.
πΏ RUTA 2: INTERMEDIO (SΓ© usar CMake bΓ‘sico)¶
Objetivo: Configurar builds complejos, cross-platform
Secuencia (8-10 horas):
- BUILD_SYSTEMS_PHILOSOPHY.md - Completo (3 horas)
- π Todos los capΓtulos
-
π― Objetivo: Modelo mental completo del pipeline
-
CMAKE_ARCHITECTURE_DEEP_DIVE.md (2 horas)
- π Internals de CMake
-
π― Objetivo: Entender cΓ³mo funciona CMake
-
TOOLCHAIN_PHILOSOPHY.md (2 horas)
- π Cross-compilation
- π Toolchains especΓficos
-
π― Objetivo: Compilar para otras plataformas
-
MΓ³dulos CMake (1 hora)
- π Explora: 03_02_00_build_system/*.cmake
-
π― Objetivo: Reutilizar mΓ³dulos en tus proyectos
-
DEPENDENCY_PHILOSOPHY.md (2 horas)
- π FetchContent, find_package, vcpkg
- π― Objetivo: Gestionar dependencias
β Al Completar: Puedes configurar builds complejos, cross-compile, gestionar dependencias.
π² RUTA 3: AVANZADO (Quiero optimizar builds)¶
Objetivo: Builds rΓ‘pidos, optimizados, CI/CD
Secuencia (10-15 horas):
- Optimization Modules (3 horas)
- π advanced_optimization.cmake - LTO, PGO
- π simd_detection.cmake - Vectorization
- π pch_setup.cmake - Precompiled headers
-
π― Objetivo: Builds 2-5x mΓ‘s rΓ‘pidos
-
Compiler Deep Dive (2 horas)
- π compiler_flags.cmake
- π warning_flags.cmake
-
π― Objetivo: Fine-tuning de compilaciΓ³n
-
Sanitizers & Debugging (2 horas)
- π sanitizers.cmake
-
π― Objetivo: Detectar bugs en runtime
-
Advanced Troubleshooting (3 horas)
- π BUILD_TROUBLESHOOTING_PHILOSOPHY.md - Completo
- π linker_errors.md
-
π― Objetivo: Diagnosticar problemas complejos
-
CI/CD Integration (prΓ‘ctica)
- π― Objetivo: Automatizar builds en GitHub Actions
β Al Completar: Puedes diseΓ±ar build systems complejos, optimizar, troubleshoot anything.
π¨ RUTA DE EMERGENCIA: "Β‘El Build FallΓ³!"¶
Si estΓ‘s bloqueado:
- STOP - No intentes compilar repetidamente sin entender
- Identifica la fase donde falla:
- Lee el playbook correspondiente:
- Configuration β build_issues.md - SecciΓ³n 1
- Compilation β BUILD_TROUBLESHOOTING_PHILOSOPHY.md - PHASE 3
- Linking β linker_errors.md
- Si no resuelves: Pide ayuda en
#build-helpSlack
π ESTRUCTURA DE DOCUMENTACIΓN¶
03_02_build_infrastructure/
β
βββ π README.md (este archivo) β
βββ π QUICK_START.md β (tutorial paso a paso)
βββ π CMAKE_CHEAT_SHEET.md β (quick reference)
βββ π BUILD_SYSTEMS_PHILOSOPHY.md (fundamentos conceptuales)
β
βββ π 03_02_00_build_system/
β βββ CMAKE_ARCHITECTURE_DEEP_DIVE.md (internals de CMake)
β βββ advanced_optimization.cmake (LTO, PGO)
β βββ compiler_flags.cmake (flags por compilador)
β βββ lto_config.cmake (Link Time Optimization)
β βββ pch_setup.cmake (Precompiled Headers)
β βββ sanitizers.cmake (ASan, UBSan, TSan)
β βββ simd_detection.cmake (SSE, AVX)
β βββ warning_flags.cmake (warning levels)
β
βββ π 03_02_00_cmake_foundation/
β βββ AudioLabConfig.cmake (project config)
β βββ AudioLabTargets.cmake (export targets)
β βββ AudioLabUtilities.cmake (helper functions)
β
βββ π 03_02_01_toolchains/
β βββ TOOLCHAIN_PHILOSOPHY.md (cross-compilation guide)
β βββ windows_msvc.cmake (Windows MSVC)
β βββ linux_gcc.cmake (Linux GCC)
β βββ linux_clang.cmake (Linux Clang)
β βββ macos_universal.cmake (macOS Universal)
β βββ cross_mingw.cmake (Linux β Windows)
β
βββ π 03_02_02_build_presets/
β βββ README.md (cΓ³mo usar presets)
β βββ CMakePresets.json (presets examples) β
β
βββ π 03_02_02_dependencies/
β βββ DEPENDENCY_PHILOSOPHY.md (gestiΓ³n de dependencias)
β βββ FetchContent.cmake (fetch external libs)
β βββ FindModules/
β βββ FindIPP.cmake (Intel Performance Primitives)
β βββ FindJUCE.cmake (JUCE framework)
β
βββ π 03_02_03_build_scripts/
β βββ README.md (guΓa de scripts)
β βββ build.sh (Unix/macOS build script) β
β βββ build.ps1 (Windows build script) β
β βββ clean.sh (cleanup script)
β βββ clean.ps1 (Windows cleanup)
β
βββ π 03_02_05_troubleshooting/
βββ BUILD_TROUBLESHOOTING_PHILOSOPHY.md (troubleshooting completo)
βββ build_issues.md (problemas comunes)
βββ linker_errors.md (errores de linkeo)
β = Documentos esenciales, leer primero
π¨ SCRIPTS DE BUILD¶
Scripts Principales¶
# Unix/macOS
./03_02_03_build_scripts/build.sh [opciones]
# Windows
.\03_02_03_build_scripts\build.ps1 [opciones]
Opciones Comunes¶
# Configuraciones
--config Debug # Debug build (default)
--config Release # Release build (optimizado)
--config RelWithDebInfo # Release con debug info
# Operaciones
--clean # Limpiar antes de compilar
--verbose # Output detallado
# Performance
--parallel 8 # 8 jobs paralelos (default: auto)
# Presets
--preset developer # Usar CMake preset especΓfico
--preset ci-linux # Para CI/CD
Ejemplos PrΓ‘cticos¶
# Build rΓ‘pido de debug
./build.sh
# Release optimizado con clean
./build.sh --config Release --clean
# Build paralelo mΓ‘ximo
./build.sh --parallel 16
# Usar preset especΓfico
./build.sh --preset developer
# Build verboso para debugging
./build.sh --verbose
Scripts de Limpieza¶
# Limpiar build directory
./03_02_03_build_scripts/clean.sh
# Limpiar TODO (builds + caches)
./03_02_03_build_scripts/clean.sh --all
Ver: 03_02_03_build_scripts/README.md
π§ CONFIGURACIΓN RΓPIDA¶
Primer Build (5 minutos)¶
# 1. Verificar requisitos
cmake --version # MΓnimo 3.20
g++ --version # O clang++, msvc
# 2. Clonar
git clone https://github.com/audiolab/audio-lab.git
cd audio-lab
# 3. Build
./2\ -\ FOUNDATION/03_INFRA/03_02_build_infrastructure/03_02_03_build_scripts/build.sh
# 4. Β‘Γxito!
# Binarios en: build/Debug/bin/
ConfiguraciΓ³n Avanzada¶
# Usar toolchain especΓfico
cmake -S . -B build \
-DCMAKE_TOOLCHAIN_FILE=03_02_01_toolchains/linux_clang.cmake
# Habilitar optimizaciones
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_LTO=ON \
-DENABLE_SIMD=ON
# Usar preset
cmake --preset developer
cmake --build --preset developer
Ver: CMAKE_CHEAT_SHEET.md
π¨ TROUBLESHOOTING¶
DiagnΓ³stico RΓ‘pido¶
ΒΏDΓ³nde fallΓ³ el build?
βββββββββββββββββββββββββββββββββββββββ
β "CMake Error: Could not find..." β β Configuration Error
β β Ver: build_issues.md #1
βββββββββββββββββββββββββββββββββββββββ€
β "error: 'vector' is not defined" β β Compilation Error
β β Ver: BUILD_TROUBLESHOOTING #3
βββββββββββββββββββββββββββββββββββββββ€
β "undefined reference to `foo'" β β Linker Error
β β Ver: linker_errors.md
βββββββββββββββββββββββββββββββββββββββ€
β "Code signing failed" β β Post-build Error
β β Ver: BUILD_TROUBLESHOOTING #5
βββββββββββββββββββββββββββββββββββββββ
Errores Comunes (Top 5)¶
-
CMake no encuentra dependencia
-
Compilador no encontrado
-
Undefined reference (linker error)
-
Permission denied (Unix)
-
Out of memory durante link
Ver documentaciΓ³n completa: BUILD_TROUBLESHOOTING_PHILOSOPHY.md
π CASOS DE USO¶
Caso 1: Developer Local Build¶
# Debug build para desarrollo diario
./build.sh --config Debug
# Con sanitizers para detectar bugs
cmake -S . -B build-debug \
-DCMAKE_BUILD_TYPE=Debug \
-DENABLE_ASAN=ON \
-DENABLE_UBSAN=ON
Caso 2: Release Build para DistribuciΓ³n¶
# Release optimizado
./build.sh --config Release --clean
# Con todas las optimizaciones
cmake -S . -B build-release \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_LTO=ON \
-DENABLE_SIMD=ON \
-DENABLE_STRIP=ON
Caso 3: Cross-Compilation¶
# Linux β Windows (MinGW)
cmake -S . -B build-windows \
-DCMAKE_TOOLCHAIN_FILE=03_02_01_toolchains/cross_mingw.cmake
# macOS Universal (Intel + Apple Silicon)
cmake -S . -B build-universal \
-DCMAKE_TOOLCHAIN_FILE=03_02_01_toolchains/macos_universal.cmake
Caso 4: CI/CD Build¶
# Build no-interactivo para CI
./build.sh --preset ci-linux --parallel 4
# O directamente CMake
cmake --preset ci-linux
cmake --build --preset ci-linux --target all test
π RECURSOS ADICIONALES¶
AudioLab Interno¶
- Version Control: ../03_01_version_control/
- Dependencies: ../03_03_dependency_management/
- Testing: ../03_04_testing_infrastructure/
Externos Recomendados¶
- CMake Official Docs
- CMake Tutorial
- Effective CMake (CppCon talk)
- Professional CMake (book)
Herramientas¶
- CMake - Build system generator
- Ninja - Fast build tool (recomendado)
- ccache - Compiler cache (acelera rebuilds)
- sccache - Distributed compiler cache
π FILOSOFΓA DE AUDIOLAB BUILD¶
Principios¶
- Reproducibilidad - Mismo cΓ³digo β mismo resultado
- Cross-platform - Write once, build anywhere
- Performance - Fast builds, fast binaries
- Debuggability - Errores claros, fΓ‘cil de troubleshoot
- Maintainability - Build system simple y comprensible
Build Philosophy¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β "El build system es infraestructura invisible que β
β permite a developers enfocarse en crear, no compilar." β
β β
β Un buen build system: β
β β’ Funciona en primer intento β
β β’ Falla rΓ‘pido con mensajes claros β
β β’ Se optimiza solo β
β β’ No requiere configuraciΓ³n manual β
β β
β - AudioLab Build Team β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π€ CONTRIBUCIONES¶
Mejorar Build System¶
Si encuentras: - β Build que falla en tu plataforma - π‘ OptimizaciΓ³n que falta - π DocumentaciΓ³n unclear - π Bug en scripts
Por favor: 1. Crea issue con detalles 2. O haz PR con fix 3. Documenta en troubleshooting si es nuevo error
Maintainer¶
Build Infrastructure Team
Slack: #build-help
Email: build-team@audiolab.com
π MΓTRICAS DE ΓXITO¶
SabrΓ‘s que dominas el build system cuando:
- Puedes compilar AudioLab en cualquier plataforma
- Entiendes cada paso del pipeline de build
- Puedes diagnosticar errores de compilation/linking
- Configuras optimizaciones (LTO, SIMD, PCH)
- Cross-compilas para otras plataformas
- Troubleshooteas build issues de otros developers
- DiseΓ±as CMake configs para nuevos proyectos
Γltima actualizaciΓ³n: 2025-10-09 VersiΓ³n: 1.0.0
Β‘Bienvenido al sistema de build de AudioLab! π
"De cΓ³digo fuente a plugins de audio en minutos, no horas."