# MimiClaw - CMake build configuration
# This file is processed by ESP-IDF's CMake build system

# ─── Core modules (always compiled) ────────────────────────────────────────
set(core_srcs
    "mimi.c"
    "bus/message_bus.c"
    "wifi/wifi_manager.c"
    "llm/llm_proxy.c"
    "llm/llm_provider.c"
    "agent/agent_loop.c"
    "agent/context_builder.c"
    "memory/memory_store.c"
    "memory/session_mgr.c"
    "cli/serial_cli.c"
    "proxy/http_proxy.c"
    "cron/cron_service.c"
    "heartbeat/heartbeat.c"
    "tools/tool_registry.c"
    "tools/tool_cron.c"
    "tools/tool_get_time.c"
    "tools/tool_set_timezone.c"
    "tools/tool_files.c"
    "skills/skill_loader.c"
)

# ─── Channel modules ───────────────────────────────────────────────────────
if(CONFIG_MIMI_CHAN_TELEGRAM)
    list(APPEND core_srcs "channels/telegram/telegram_bot.c")
endif()

if(CONFIG_MIMI_CHAN_FEISHU)
    list(APPEND core_srcs "channels/feishu/feishu_bot.c")
endif()

# ─── Optional modules ───────────────────────────────────────────────────────
if(CONFIG_MIMI_WS_SERVER)
    list(APPEND core_srcs "gateway/ws_server.c")
endif()

if(CONFIG_MIMI_WIFI_ONBOARD)
    list(APPEND core_srcs "onboard/wifi_onboard.c")
endif()

if(CONFIG_MIMI_OTA)
    list(APPEND core_srcs "ota/ota_manager.c")
endif()

# ─── Tool modules ──────────────────────────────────────────────────────────
if(CONFIG_MIMI_TOOL_WEB_SEARCH)
    list(APPEND core_srcs "tools/tool_web_search.c")
endif()

if(CONFIG_MIMI_TOOL_GPIO)
    list(APPEND core_srcs "tools/tool_gpio.c")
    list(APPEND core_srcs "tools/gpio_policy.c")
endif()

# ─── Register component ───────────────────────────────────────────────────
idf_component_register(
    SRCS ${core_srcs}
    INCLUDE_DIRS "."
    REQUIRES
        nvs_flash esp_wifi esp_netif esp_http_client esp_http_server
        esp_https_ota esp_event cjson spiffs console vfs app_update esp-tls
        esp_timer esp_websocket_client esp_driver_gpio
)
