Below are my 2 latest scripts and both compress files only after embed_file or target_add_binary. I need to invert this order! Both examples are shorter than real, embedding only one file to improve reading.
Code: Select all
idf_component_register(SRCS "http.cpp"
INCLUDE_DIRS "."
REQUIRES esp_http_server
EMBED_FILES web/zip/index.html.gz)
message(STATUS "### Compressing WEB files over custom cmake")
set (WEB_DIR ${COMPONENT_DIR}/web)
add_custom_target(
process_http_files
ALL
COMMAND ${CMAKE_COMMAND} -E echo "---- Compressing [FW_HTTP]"
COMMAND ${CMAKE_COMMAND} -E remove_directory ${WEB_DIR}/zip
COMMAND ${CMAKE_COMMAND} -E make_directory ${WEB_DIR}/zip
COMMAND gzip -krf -9 ${WEB_DIR}/
COMMAND find ${WEB_DIR} -maxdepth 1 -name "*.gz" -exec mv -t ${WEB_DIR}/zip {} +
COMMAND ${CMAKE_COMMAND} -E echo "---- Compressed [FW_HTTP] successfully"
)
add_dependencies(${COMPONENT_LIB} process_http_files)
Code: Select all
idf_component_register(
SRCS "http.cpp"
INCLUDE_DIRS "."
REQUIRES esp_http_server
)
externalproject_add(execute_zip
PREFIX ${COMPONENT_DIR}
SOURCE_DIR ${COMPONENT_DIR}
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND ${CMAKE_COMMAND} -E env bash ${COMPONENT_DIR}/zip_all.sh
INSTALL_COMMAND ""
)
add_dependencies(${COMPONENT_LIB} execute_zip)
target_add_binary_data(${COMPONENT_LIB} "${COMPONENT_DIR}/web/zip/index.html.gz" BINARY DEPENDS execute_zip)