Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8037

SDK • Re: embedded website html makefsdata.py

$
0
0
The suggestion for cmake modifications by hippy was interesting, but I think too dependent on sdk structure.
I would say it's independent of Pico SDK save for the fact it uses the 'makefsdata.py' it provides. It could easily use something else. Otherwise it's a standard '.cmake' file invoked by 'CMakeLists.txt', but yes, it does use 'pico_add_library' to add the library. There is probably some other way to do that.

Here's a version which allows the Python program which creates 'fsdata.inc' to be specified within 'CMakeLists.txt'. It currently uses the Pico SDK provided program -

CMakeLists.txt

Code:

set(PROJECT build-fsdata-dot-inc)cmake_minimum_required(VERSION 3.12)include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)project(${PROJECT} C CXX ASM)pico_sdk_init()add_executable(${PROJECT} main.c)include(create_fsdata_inc.cmake)pico_add_library(create_fsdata_inc)set_fsdata_inc_content(create_fsdata_inc INTERFACE   # First is the python script to run       ${PICO_SDK_PATH}/src/rp2_common/pico_lwip/tools/makefsdata.py   # List of files to include       ${CMAKE_CURRENT_SOURCE_DIR}/index.html       ${CMAKE_CURRENT_SOURCE_DIR}/favicon.ico   # Last is output file       ${CMAKE_CURRENT_SOURCE_DIR}/fsdata.inc)target_link_libraries(${PROJECT} create_fsdata_inc)target_link_libraries(${PROJECT} pico_stdlib)pico_add_extra_outputs(${PROJECT})pico_enable_stdio_usb(${PROJECT} 1)pico_enable_stdio_uart(${PROJECT} 0)
create_fsdata_inc.cmake

Code:

function(set_fsdata_inc_content TARGET_LIB TARGET_TYPE)    find_package (Python3 REQUIRED COMPONENTS Interpreter)    set(CREATE_FSDATA_INC_TARGET "${TARGET_LIB}_create_fsdata_inc_content")    set(INPUT_NAMES ${ARGN})    list(POP_FRONT INPUT_NAMES PYTHON_SCRIPT)    list(POP_BACK  INPUT_NAMES OUTPUT_NAME)    message("***************")    message("Python Script = ${PYTHON_SCRIPT}")    message("Input files   = ${INPUT_NAMES}")    message("Output file   = ${OUTPUT_NAME}")    message("***************")    add_custom_target(${CREATE_FSDATA_INC_TARGET} DEPENDS ${OUTPUT_NAME})    add_custom_command(        OUTPUT  ${OUTPUT_NAME}        DEPENDS ${INPUT_NAMES}        COMMAND ${Python3_EXECUTABLE} ${PYTHON_SCRIPT}                -i ${INPUT_NAMES}                -o ${OUTPUT_NAME}        VERBATIM)    add_dependencies(${TARGET_LIB} ${CREATE_FSDATA_INC_TARGET})endfunction()
Nothing in that depends on the Pico SDK.

Statistics: Posted by hippy — Sun Mar 16, 2025 5:02 pm



Viewing all articles
Browse latest Browse all 8037

Trending Articles