- _corebuild.musl_platform_tag(): на musl (Alpine/HA OS) bdist_wheel выпускает py3-none-musllinux_X_Y_<arch> вместо linux_<arch> — иначе pip ставит glibc-сборку и dlopen падает на ld-linux-x86-64.so.2 - shared-библиотека линкуется со -static-libstdc++ -static-libgcc (gcc): NEEDED только libm/libc (проверено readelf), меньше зависимостей у HA OS - Gitea Actions: job build-musllinux (container python:3.12-alpine) собирает и публикует musl-wheel; build-glibc — как раньше; общий scripts/publish-gitea-pypi.sh с пропуском уже загруженных файлов - тесты musl_platform_tag; RELEASE_HA §1.1-1.4 (выбор wheel, переустановка на HA OS, ручная сборка musllinux без container:); README troubleshooting
152 lines
5.3 KiB
CMake
152 lines
5.3 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
|
|
if(ESP_PLATFORM)
|
|
# ---------------------------------------------------------------------------
|
|
# Сборка как компонента ESP-IDF (корень репозитория = компонент; имя
|
|
# компонента = имя каталога, из которого он подключён).
|
|
# ВАЖНО: cmake_minimum_required должен остаться до этой ветки, project()
|
|
# для IDF-сборки не вызывается.
|
|
# ---------------------------------------------------------------------------
|
|
idf_component_register(
|
|
SRCS
|
|
"src/ayla/crypto.cpp"
|
|
"src/ayla/envelope.cpp"
|
|
"src/ayla/httpc.cpp"
|
|
"src/ayla/httpd.cpp"
|
|
"src/ayla/log.cpp"
|
|
"src/ayla/session.cpp"
|
|
"src/aircon/c_api.cpp"
|
|
"src/aircon/session.cpp"
|
|
"src/aircon/tables.cpp"
|
|
"src/ayla/platform/esp-idf/platform.cpp"
|
|
INCLUDE_DIRS
|
|
"include"
|
|
PRIV_INCLUDE_DIRS
|
|
"."
|
|
"src"
|
|
PRIV_REQUIRES
|
|
lwip
|
|
esp_timer
|
|
esp_hw_support
|
|
pthread
|
|
mbedtls
|
|
)
|
|
target_compile_options(${COMPONENT_LIB} PRIVATE
|
|
-Wall -Wextra -Werror
|
|
-fno-exceptions -fno-rtti
|
|
)
|
|
target_compile_features(${COMPONENT_LIB} PUBLIC cxx_std_20)
|
|
else()
|
|
# ---------------------------------------------------------------------------
|
|
# Обычная (POSIX) сборка: статическая библиотека + тесты.
|
|
# ---------------------------------------------------------------------------
|
|
project(fgl-aircon VERSION 0.1.0 LANGUAGES CXX)
|
|
|
|
option(FGL_BUILD_TESTS "Build tests" ON)
|
|
option(FGL_BUILD_EXAMPLES "Build examples (fglctl)" ON)
|
|
option(FGL_BUILD_SHARED "Build shared library (pyfglair/cffi)" ON)
|
|
option(FGL_BUNDLED_MBEDTLS "Fetch and build Mbed TLS instead of system" OFF)
|
|
|
|
# ---- mbedtls ----
|
|
if(NOT FGL_BUNDLED_MBEDTLS)
|
|
find_path(MBEDTLS_INCLUDE_DIR mbedtls/aes.h
|
|
HINTS /usr/include/mbedtls3 /usr/include
|
|
)
|
|
find_library(MBEDTLS_CRYPTO_LIB
|
|
NAMES mbedcrypto-3 mbedcrypto
|
|
)
|
|
if(NOT MBEDTLS_INCLUDE_DIR OR NOT MBEDTLS_CRYPTO_LIB)
|
|
message(STATUS "System Mbed TLS not found - falling back to bundled")
|
|
set(FGL_BUNDLED_MBEDTLS ON)
|
|
endif()
|
|
endif()
|
|
if(FGL_BUNDLED_MBEDTLS)
|
|
include(FetchContent)
|
|
FetchContent_Declare(mbedtls
|
|
GIT_REPOSITORY https://github.com/Mbed-TLS/mbedtls.git
|
|
GIT_TAG v3.6.2
|
|
GIT_SHALLOW TRUE
|
|
)
|
|
set(ENABLE_PROGRAMS OFF CACHE BOOL "" FORCE)
|
|
set(ENABLE_TESTING OFF CACHE BOOL "" FORCE)
|
|
set(USE_SHARED_MBEDTLS_LIBRARY OFF CACHE BOOL "" FORCE)
|
|
set(USE_STATIC_MBEDTLS_LIBRARY ON CACHE BOOL "" FORCE)
|
|
FetchContent_MakeAvailable(mbedtls)
|
|
set(FGL_MBEDTLS_TARGET mbedcrypto)
|
|
set(FGL_MBEDTLS_INCLUDE_DIR "")
|
|
# Статический mbedcrypto нужен и для shared-библиотеки (pyfglair).
|
|
set_target_properties(mbedcrypto PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
else()
|
|
set(FGL_MBEDTLS_TARGET "${MBEDTLS_CRYPTO_LIB}")
|
|
set(FGL_MBEDTLS_INCLUDE_DIR "${MBEDTLS_INCLUDE_DIR}")
|
|
endif()
|
|
|
|
set(FGL_SOURCES
|
|
src/ayla/crypto.cpp
|
|
src/ayla/envelope.cpp
|
|
src/ayla/httpc.cpp
|
|
src/ayla/httpd.cpp
|
|
src/ayla/log.cpp
|
|
src/ayla/session.cpp
|
|
src/aircon/c_api.cpp
|
|
src/aircon/session.cpp
|
|
src/aircon/tables.cpp
|
|
src/ayla/platform/posix/platform.cpp
|
|
)
|
|
|
|
function(fgl_configure_target tgt)
|
|
target_include_directories(${tgt}
|
|
PUBLIC
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
|
"${FGL_MBEDTLS_INCLUDE_DIR}"
|
|
PRIVATE
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/src"
|
|
)
|
|
target_link_libraries(${tgt} PUBLIC ${FGL_MBEDTLS_TARGET})
|
|
target_compile_features(${tgt} PUBLIC cxx_std_20)
|
|
target_compile_options(${tgt} PRIVATE
|
|
-Wall -Wextra -Werror
|
|
-fno-exceptions -fno-rtti
|
|
)
|
|
endfunction()
|
|
|
|
add_library(fgl-aircon STATIC ${FGL_SOURCES})
|
|
fgl_configure_target(fgl-aircon)
|
|
|
|
# Shared-библиотека для cffi/pyfglair (Home Assistant). Имя то же
|
|
# (libfgl-aircon.so), чтобы dlopen по имени был предсказуем.
|
|
if(FGL_BUILD_SHARED)
|
|
add_library(fgl-aircon-shared SHARED ${FGL_SOURCES})
|
|
fgl_configure_target(fgl-aircon-shared)
|
|
set_target_properties(fgl-aircon-shared PROPERTIES
|
|
OUTPUT_NAME fgl-aircon
|
|
POSITION_INDEPENDENT_CODE ON
|
|
VERSION ${PROJECT_VERSION}
|
|
SOVERSION ${PROJECT_VERSION_MAJOR}
|
|
)
|
|
# Минимум внешних зависимостей у wheel: C++-рантайм встраиваем, остаются
|
|
# libc/libm (на musl — musl). Иначе Alpine/HA OS может не иметь
|
|
# libstdc++.so.6/libgcc_s.so.1 нужной сборки.
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
target_link_options(fgl-aircon-shared PRIVATE
|
|
-static-libstdc++ -static-libgcc
|
|
)
|
|
endif()
|
|
endif()
|
|
|
|
if(FGL_BUILD_TESTS)
|
|
enable_testing()
|
|
add_subdirectory(tests)
|
|
endif()
|
|
|
|
if(FGL_BUILD_EXAMPLES)
|
|
add_executable(fglctl examples/cli/fglctl.cpp)
|
|
target_compile_features(fglctl PRIVATE cxx_std_20)
|
|
target_link_libraries(fglctl PRIVATE fgl-aircon)
|
|
target_include_directories(fglctl PRIVATE "${CMAKE_SOURCE_DIR}/src")
|
|
target_compile_options(fglctl PRIVATE -Wall -Wextra -Werror
|
|
-fno-exceptions -fno-rtti)
|
|
endif()
|
|
endif()
|