Generate the web UI headers from c/web/ via scripts/embed_file.py (minify + gzip) and serve them with Content-Encoding, replacing the checked-in web_*.h blobs. Move the LED driver/presets into lib/leds, and parse preset edits into a typed cmd_preset_t on core0 instead of passing raw JSON to core1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
100 lines
2.9 KiB
CMake
100 lines
2.9 KiB
CMake
cmake_minimum_required(VERSION 3.13)
|
|
|
|
set(PICO_BOARD pico2_w CACHE STRING "Board type")
|
|
|
|
include(pico_sdk_import.cmake)
|
|
|
|
project(led_hoop C CXX ASM)
|
|
|
|
pico_sdk_init()
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
file(GLOB_RECURSE SRC_SOURCES CONFIGURE_DEPENDS
|
|
"${CMAKE_CURRENT_LIST_DIR}/src/*.c"
|
|
"${CMAKE_CURRENT_LIST_DIR}/src/*.cpp"
|
|
)
|
|
file(GLOB_RECURSE LIB_SOURCES CONFIGURE_DEPENDS
|
|
"${CMAKE_CURRENT_LIST_DIR}/lib/*.c"
|
|
"${CMAKE_CURRENT_LIST_DIR}/lib/*.cpp"
|
|
"${CMAKE_CURRENT_LIST_DIR}/lib/**/*.c"
|
|
"${CMAKE_CURRENT_LIST_DIR}/lib/**/*.cpp"
|
|
)
|
|
|
|
# Embed web UI from normal files under web/ (headers generated into build/)
|
|
set(WEB_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
|
set(EMBED_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/scripts/embed_file.py")
|
|
set(WEB_ASSETS
|
|
"${WEB_GEN_DIR}/web_index_html.h"
|
|
"${WEB_GEN_DIR}/web_main_js.h"
|
|
"${WEB_GEN_DIR}/web_styles_css.h"
|
|
)
|
|
add_custom_command(
|
|
OUTPUT "${WEB_GEN_DIR}/web_index_html.h"
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${WEB_GEN_DIR}"
|
|
COMMAND python3 "${EMBED_SCRIPT}"
|
|
"${CMAKE_CURRENT_LIST_DIR}/web/index.html" web_index_html
|
|
"${WEB_GEN_DIR}/web_index_html.h"
|
|
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/web/index.html" "${EMBED_SCRIPT}"
|
|
VERBATIM
|
|
)
|
|
add_custom_command(
|
|
OUTPUT "${WEB_GEN_DIR}/web_main_js.h"
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${WEB_GEN_DIR}"
|
|
COMMAND python3 "${EMBED_SCRIPT}"
|
|
"${CMAKE_CURRENT_LIST_DIR}/web/static/main.js" web_main_js
|
|
"${WEB_GEN_DIR}/web_main_js.h"
|
|
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/web/static/main.js" "${EMBED_SCRIPT}"
|
|
VERBATIM
|
|
)
|
|
add_custom_command(
|
|
OUTPUT "${WEB_GEN_DIR}/web_styles_css.h"
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${WEB_GEN_DIR}"
|
|
COMMAND python3 "${EMBED_SCRIPT}"
|
|
"${CMAKE_CURRENT_LIST_DIR}/web/static/styles.css" web_styles_css
|
|
"${WEB_GEN_DIR}/web_styles_css.h"
|
|
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/web/static/styles.css" "${EMBED_SCRIPT}"
|
|
VERBATIM
|
|
)
|
|
add_custom_target(web_assets DEPENDS ${WEB_ASSETS})
|
|
|
|
add_executable(led_hoop
|
|
${SRC_SOURCES}
|
|
${LIB_SOURCES}
|
|
)
|
|
add_dependencies(led_hoop web_assets)
|
|
|
|
target_include_directories(led_hoop PRIVATE
|
|
${CMAKE_CURRENT_LIST_DIR}
|
|
${CMAKE_CURRENT_LIST_DIR}/src
|
|
${CMAKE_CURRENT_LIST_DIR}/lib
|
|
${CMAKE_CURRENT_LIST_DIR}/lib/httpserver
|
|
${WEB_GEN_DIR}
|
|
)
|
|
|
|
target_link_libraries(led_hoop
|
|
pico_stdlib
|
|
pico_multicore
|
|
hardware_pio
|
|
hardware_dma
|
|
hardware_clocks
|
|
hardware_flash
|
|
pico_cyw43_arch_lwip_threadsafe_background
|
|
pico_bootsel_via_double_reset
|
|
)
|
|
|
|
# Ensure picotool can force the running app into BOOTSEL (no button)
|
|
target_compile_definitions(led_hoop PRIVATE
|
|
PICO_ENABLE_USB_RESET_VIA_VENDOR_INTERFACE=1
|
|
PICO_ENABLE_USB_RESET_VIA_BAUD_RATE=1
|
|
)
|
|
|
|
pico_configure_ip4_address(led_hoop PRIVATE
|
|
CYW43_DEFAULT_IP_AP_ADDRESS 192.168.4.1
|
|
)
|
|
|
|
pico_enable_stdio_usb(led_hoop 1)
|
|
pico_enable_stdio_uart(led_hoop 0)
|
|
|
|
pico_add_extra_outputs(led_hoop)
|