feat: add C++ support with ImGui/ImPlot framework and vendor submodules

Añade soporte C++ al registry: vendor submodules (glfw, imgui, implot, tracy),
sistema de build con CMake y toolchains cross-platform, runner C++ en fn CLI,
parser de tests Google Test, y funciones bash para build Linux/Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-06 23:46:36 +02:00
parent 0c759c1b66
commit 4b2bb6998a
36 changed files with 1065 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
---
name: build_cpp_linux
kind: function
lang: bash
domain: infra
version: "1.0.0"
purity: impure
signature: "build_cpp_linux(target?: string) -> void"
description: "Compila las funciones y apps C++ del registry para Linux nativo usando cmake"
tags: [cpp, build, cmake, linux, imgui]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
tested: false
tests: []
test_file_path: ""
file_path: "bash/functions/infra/build_cpp_linux.sh"
params:
- name: target
desc: "Nombre del target cmake a compilar (opcional, sin argumento compila todo)"
output: "Compila los binarios en cpp/build/linux/"
---
# build_cpp_linux
Configura y compila el proyecto C++ (ImGui/ImPlot) para Linux nativo.
Usa cmake con compilacion paralela (`-j$(nproc)`). Si no se ha configurado antes, ejecuta `cmake -B` automaticamente.
```bash
fn run build_cpp_linux # Compilar todo
fn run build_cpp_linux chart_demo # Compilar solo chart_demo
```
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -euo pipefail
REGISTRY_ROOT="${FN_REGISTRY_ROOT:-$(cd "$(dirname "$0")/../../.." && pwd)}"
CPP_ROOT="$REGISTRY_ROOT/cpp"
BUILD_DIR="$CPP_ROOT/build/linux"
TARGET="${1:-}"
# Configure if needed
if [ ! -f "$BUILD_DIR/CMakeCache.txt" ]; then
echo "[build_cpp_linux] Configuring cmake..."
cmake -B "$BUILD_DIR" -S "$CPP_ROOT"
fi
# Build
if [ -n "$TARGET" ]; then
echo "[build_cpp_linux] Building target: $TARGET"
cmake --build "$BUILD_DIR" --target "$TARGET" -- -j"$(nproc)"
else
echo "[build_cpp_linux] Building all targets..."
cmake --build "$BUILD_DIR" -- -j"$(nproc)"
fi
echo "[build_cpp_linux] Done. Binaries in $BUILD_DIR"
+38
View File
@@ -0,0 +1,38 @@
---
name: build_cpp_windows
kind: function
lang: bash
domain: infra
version: "1.0.0"
purity: impure
signature: "build_cpp_windows(target?: string) -> void"
description: "Cross-compila las funciones y apps C++ del registry para Windows usando mingw-w64"
tags: [cpp, build, cmake, windows, cross-compile, mingw, imgui]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
tested: false
tests: []
test_file_path: ""
file_path: "bash/functions/infra/build_cpp_windows.sh"
params:
- name: target
desc: "Nombre del target cmake a compilar (opcional, sin argumento compila todo)"
output: "Produce binarios .exe de Windows en cpp/build/windows/"
---
# build_cpp_windows
Cross-compila el proyecto C++ para Windows desde Linux usando el toolchain mingw-w64.
Los .exe resultantes incluyen runtime linkado estaticamente (self-contained).
```bash
fn run build_cpp_windows # Compilar todo
fn run build_cpp_windows chart_demo # Compilar solo chart_demo
```
Requiere `mingw-w64`: `sudo apt install mingw-w64`
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail
REGISTRY_ROOT="${FN_REGISTRY_ROOT:-$(cd "$(dirname "$0")/../../.." && pwd)}"
CPP_ROOT="$REGISTRY_ROOT/cpp"
BUILD_DIR="$CPP_ROOT/build/windows"
TOOLCHAIN="$CPP_ROOT/toolchains/mingw-w64.cmake"
TARGET="${1:-}"
# Check mingw is available
if ! command -v x86_64-w64-mingw32-g++ &>/dev/null; then
echo "[build_cpp_windows] Error: mingw-w64 not found. Install with: sudo apt install mingw-w64"
exit 1
fi
# Configure if needed
if [ ! -f "$BUILD_DIR/CMakeCache.txt" ]; then
echo "[build_cpp_windows] Configuring cmake with mingw-w64 toolchain..."
cmake -B "$BUILD_DIR" -S "$CPP_ROOT" -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN"
fi
# Build
if [ -n "$TARGET" ]; then
echo "[build_cpp_windows] Cross-compiling target: $TARGET"
cmake --build "$BUILD_DIR" --target "$TARGET" -- -j"$(nproc)"
else
echo "[build_cpp_windows] Cross-compiling all targets..."
cmake --build "$BUILD_DIR" -- -j"$(nproc)"
fi
echo "[build_cpp_windows] Done. Windows binaries in $BUILD_DIR"
if [ -n "$TARGET" ]; then
file "$BUILD_DIR"/**/"$TARGET".exe 2>/dev/null || file "$BUILD_DIR/$TARGET".exe 2>/dev/null || true
fi
+37
View File
@@ -0,0 +1,37 @@
---
name: install_cpp_deps
kind: function
lang: bash
domain: infra
version: "1.0.0"
purity: impure
signature: "install_cpp_deps() -> void"
description: "Verifica e instala las dependencias de sistema necesarias para compilar C++ con ImGui (cmake, g++, glfw, mesa)"
tags: [cpp, dependencies, setup, cmake, imgui]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
tested: false
tests: []
test_file_path: ""
file_path: "bash/functions/infra/install_cpp_deps.sh"
params: []
output: "Instala paquetes faltantes via apt o confirma que todo esta instalado"
---
# install_cpp_deps
Verifica las dependencias necesarias para el build C++:
- `cmake` — sistema de build
- `g++` / `build-essential` — compilador
- `libglfw3-dev` — windowing (GLFW)
- `libgl1-mesa-dev` — OpenGL headers
Tambien reporta si `mingw-w64` esta disponible para cross-compile a Windows.
```bash
fn run install_cpp_deps
```
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail
echo "[install_cpp_deps] Checking C++ build dependencies..."
MISSING=()
if ! command -v cmake &>/dev/null; then
MISSING+=(cmake)
else
echo " cmake: $(cmake --version | head -1)"
fi
if ! command -v g++ &>/dev/null; then
MISSING+=(g++ build-essential)
else
echo " g++: $(g++ --version | head -1)"
fi
if ! dpkg -s libglfw3-dev &>/dev/null 2>&1; then
MISSING+=(libglfw3-dev)
else
echo " libglfw3-dev: installed"
fi
if ! dpkg -s libgl1-mesa-dev &>/dev/null 2>&1; then
MISSING+=(libgl1-mesa-dev)
else
echo " libgl1-mesa-dev: installed"
fi
# Optional: mingw for cross-compile
if command -v x86_64-w64-mingw32-g++ &>/dev/null; then
echo " mingw-w64: $(x86_64-w64-mingw32-g++ --version | head -1)"
else
echo " mingw-w64: not installed (optional, for Windows cross-compile)"
fi
if [ ${#MISSING[@]} -eq 0 ]; then
echo "[install_cpp_deps] All dependencies satisfied."
exit 0
fi
echo ""
echo "[install_cpp_deps] Missing packages: ${MISSING[*]}"
echo "[install_cpp_deps] Installing..."
sudo apt-get update -qq
sudo apt-get install -y -qq "${MISSING[@]}"
echo "[install_cpp_deps] Done."