feat: update cJSON and add JSON minification for MTR_LINE_STATION
This commit is contained in:
@@ -1,4 +1,14 @@
|
||||
dependencies:
|
||||
espressif/cjson:
|
||||
component_hash: 9372811fb197926f522c467627cf4a8e72b681e0366e17879631da801103aef3
|
||||
dependencies:
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=5.0'
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
version: 1.7.19
|
||||
espressif/esp_lcd_touch:
|
||||
component_hash: 3f85a7d95af876f1a6ecca8eb90a81614890d0f03a038390804e5a77e2caf862
|
||||
dependencies:
|
||||
@@ -49,10 +59,11 @@ dependencies:
|
||||
type: service
|
||||
version: 9.4.0
|
||||
direct_dependencies:
|
||||
- espressif/cjson
|
||||
- espressif/esp_lcd_touch_gt911
|
||||
- espressif/esp_lvgl_port
|
||||
- idf
|
||||
- lvgl/lvgl
|
||||
manifest_hash: fef450d0c399587685f90aba8ae661965ef507d04a5fcf17633db86d5d0fbcff
|
||||
target: esp32
|
||||
manifest_hash: 2010806782b4d2486b02b853afa44a545717d3d0593eb60f9aa6e5c696270f8f
|
||||
target: esp32s3
|
||||
version: 2.0.0
|
||||
|
||||
@@ -1,6 +1,39 @@
|
||||
set(requires esp-tls spi_flash nvs_flash esp_event esp_netif esp_http_client esp_wifi)
|
||||
set(requires esp-tls spi_flash nvs_flash esp_event esp_netif esp_http_client esp_wifi esp_psram)
|
||||
file(GLOB SRCS "main.cpp" "*.cpp" "*.c" "**/*.cpp" "**/*.c")
|
||||
|
||||
# Path to the source JSON in this component
|
||||
set(ASSETS_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/../assets)
|
||||
set(ASSETS_BINARY_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/assets)
|
||||
set(MTR_JSON_SRC ${ASSETS_SRC_DIR}/MTR_LINE_STATION.json)
|
||||
set(MTR_JSON_HEADER ${ASSETS_BINARY_OUTPUT_DIR}/MTR_LINE_STATION.h)
|
||||
set(CUSTOM_CMAKE_MODULES_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake)
|
||||
|
||||
## Generate a minified header at configure time using Python
|
||||
find_package(Python3 COMPONENTS Interpreter)
|
||||
file(MAKE_DIRECTORY ${ASSETS_BINARY_OUTPUT_DIR})
|
||||
if (Python3_Interpreter_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${Python3_EXECUTABLE} -c "import json,sys,io; sys.stdout.write(json.dumps(json.load(open(sys.argv[1], 'r', encoding='utf-8')),separators=(',',':')))"
|
||||
"${MTR_JSON_SRC}"
|
||||
RESULT_VARIABLE _mtr_json_minify_result
|
||||
OUTPUT_VARIABLE MTR_JSON_MINIFIED
|
||||
ERROR_VARIABLE _mtr_json_minify_error
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if (_mtr_json_minify_result)
|
||||
message(WARNING "Python minify failed (code=${_mtr_json_minify_result}): ${_mtr_json_minify_error}\nEmbedding original ${MTR_JSON_SRC} instead.")
|
||||
file(READ ${MTR_JSON_SRC} MTR_JSON_MINIFIED)
|
||||
elseif (NOT MTR_JSON_MINIFIED)
|
||||
message(WARNING "Python minified output empty; embedding original ${MTR_JSON_SRC} instead.")
|
||||
file(READ ${MTR_JSON_SRC} MTR_JSON_MINIFIED)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Python3 not found; embedding original JSON without minification.")
|
||||
file(READ ${MTR_JSON_SRC} MTR_JSON_MINIFIED)
|
||||
endif()
|
||||
|
||||
file(WRITE ${MTR_JSON_HEADER} "#pragma once\nstatic const char MTR_LINE_STATION_JSON[] = R\"json(${MTR_JSON_MINIFIED})json\";\n")
|
||||
|
||||
idf_component_register(SRCS ${SRCS}
|
||||
PRIV_REQUIRES ${requires}
|
||||
INCLUDE_DIRS "." "display" "touch" "network" "ui" "io" "common")
|
||||
INCLUDE_DIRS "." "${CMAKE_CURRENT_BINARY_DIR}" "display" "touch" "network" "ui" "io" "common" "external")
|
||||
|
||||
20
main/cmake/write_json_header.cmake
Normal file
20
main/cmake/write_json_header.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
if(NOT DEFINED INPUT)
|
||||
message(FATAL_ERROR "write_json_header.cmake: INPUT not defined")
|
||||
endif()
|
||||
if(NOT DEFINED OUTPUT)
|
||||
message(FATAL_ERROR "write_json_header.cmake: OUTPUT not defined")
|
||||
endif()
|
||||
|
||||
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${Python3_EXECUTABLE} -c "import json,sys;print(json.dumps(json.load(open(sys.argv[1])),separators=(', ',':')) )" ${INPUT}
|
||||
OUTPUT_VARIABLE MINIFIED_JSON
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if(NOT MINIFIED_JSON)
|
||||
message(FATAL_ERROR "write_json_header.cmake: failed to minify ${INPUT}")
|
||||
endif()
|
||||
|
||||
file(WRITE ${OUTPUT} "#pragma once\nstatic const char MTR_LINE_STATION_JSON[] = R\"json(${MINIFIED_JSON})json\";\n")
|
||||
@@ -17,3 +17,4 @@ dependencies:
|
||||
lvgl/lvgl: ^9.4.0
|
||||
espressif/esp_lcd_touch_gt911: ^1.2.0~1
|
||||
espressif/esp_lvgl_port: ^2.7.0
|
||||
espressif/cjson: ^1.7.19
|
||||
|
||||
Reference in New Issue
Block a user