acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

CMakeLists.txt (10482B)

      1 if(ESP_PLATFORM)
      2 
      3 ###################################
      4 # Tests do not build for ESP-IDF. #
      5 ###################################
      6 
      7 else()
      8 
      9 cmake_minimum_required(VERSION 3.13)
     10 project(lvgl_tests LANGUAGES C)
     11 
     12 include(CTest)
     13 
     14 set(LVGL_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
     15 
     16 set(LVGL_TEST_COMMON_EXAMPLE_OPTIONS
     17     -DLV_BUILD_EXAMPLES=1
     18     -DLV_USE_DEMO_WIDGETS=1
     19     -DLV_USE_DEMO_STRESS=1
     20 )
     21 
     22 set(LVGL_TEST_OPTIONS_MINIMAL_MONOCHROME
     23     -DLV_COLOR_DEPTH=1
     24     -DLV_MEM_SIZE=65535
     25     -DLV_DPI_DEF=40
     26     -DLV_DRAW_COMPLEX=0
     27     -DLV_USE_METER=0
     28     -DLV_USE_LOG=1
     29     -DLV_USE_ASSERT_NULL=0
     30     -DLV_USE_ASSERT_MALLOC=0
     31     -DLV_USE_ASSERT_MEM_INTEGRITY=0
     32     -DLV_USE_ASSERT_OBJ=0
     33     -DLV_USE_ASSERT_STYLE=0
     34     -DLV_USE_USER_DATA=0
     35     -DLV_FONT_UNSCII_8=1
     36     -DLV_USE_BIDI=0
     37     -DLV_USE_ARABIC_PERSIAN_CHARS=0
     38     -DLV_BUILD_EXAMPLES=1
     39     -DLV_FONT_DEFAULT=&lv_font_montserrat_14
     40     -DLV_USE_PNG=1
     41     -DLV_USE_BMP=1
     42     -DLV_USE_GIF=1
     43     -DLV_USE_QRCODE=1
     44 )
     45 
     46 set(LVGL_TEST_OPTIONS_NORMAL_8BIT
     47     -DLV_COLOR_DEPTH=8
     48     -DLV_MEM_SIZE=65535
     49     -DLV_DPI_DEF=40
     50     -DLV_DRAW_COMPLEX=1
     51     -DLV_USE_LOG=1
     52     -DLV_USE_ASSERT_NULL=0
     53     -DLV_USE_ASSERT_MALLOC=0
     54     -DLV_USE_ASSERT_MEM_INTEGRITY=0
     55     -DLV_USE_ASSERT_OBJ=0
     56     -DLV_USE_ASSERT_STYLE=0
     57     -DLV_USE_USER_DATA=1
     58     -DLV_FONT_UNSCII_8=1
     59     -DLV_USE_FONT_SUBPX=1
     60     -DLV_USE_BIDI=0
     61     -DLV_USE_ARABIC_PERSIAN_CHARS=0
     62     ${LVGL_TEST_COMMON_EXAMPLE_OPTIONS}
     63     -DLV_FONT_DEFAULT=&lv_font_montserrat_14
     64     -DLV_USE_PNG=1
     65     -DLV_USE_BMP=1
     66     -DLV_USE_SJPG=1
     67     -DLV_USE_GIF=1
     68     -DLV_USE_QRCODE=1
     69 )
     70 
     71 set(LVGL_TEST_OPTIONS_16BIT
     72     -DLV_COLOR_DEPTH=16
     73     -DLV_COLOR_16_SWAP=0
     74     -DLV_MEM_SIZE=65536
     75     -DLV_DPI_DEF=40
     76     -DLV_DRAW_COMPLEX=1
     77     -DLV_DITHER_GRADIENT=1
     78     -DLV_USE_LOG=1
     79     -DLV_USE_ASSERT_NULL=0
     80     -DLV_USE_ASSERT_MALLOC=0
     81     -DLV_USE_ASSERT_MEM_INTEGRITY=0
     82     -DLV_USE_ASSERT_OBJ=0
     83     -DLV_USE_ASSERT_STYLE=0
     84     -DLV_USE_USER_DATA=1
     85     -DLV_FONT_UNSCII_8=1
     86     -DLV_USE_FONT_SUBPX=1
     87     -DLV_USE_BIDI=0
     88     -DLV_USE_ARABIC_PERSIAN_CHARS=0
     89     ${LVGL_TEST_COMMON_EXAMPLE_OPTIONS}
     90     -DLV_FONT_DEFAULT=&lv_font_montserrat_14
     91     -DLV_USE_PNG=1
     92     -DLV_USE_BMP=1
     93     -DLV_USE_SJPG=1
     94     -DLV_USE_GIF=1
     95     -DLV_USE_QRCODE=1
     96 )
     97 
     98 set(LVGL_TEST_OPTIONS_16BIT_SWAP
     99     -DLV_COLOR_DEPTH=16
    100     -DLV_COLOR_16_SWAP=1
    101     -DLV_MEM_SIZE=65536
    102     -DLV_DPI_DEF=40
    103     -DLV_DRAW_COMPLEX=1
    104     -DLV_DITHER_GRADIENT=1
    105     -DLV_DITHER_ERROR_DIFFUSION=1
    106     -DLV_GRAD_CACHE_DEF_SIZE=8*1024
    107     -DLV_USE_LOG=1
    108     -DLV_USE_ASSERT_NULL=0
    109     -DLV_USE_ASSERT_MALLOC=0
    110     -DLV_USE_ASSERT_MEM_INTEGRITY=0
    111     -DLV_USE_ASSERT_OBJ=0
    112     -DLV_USE_ASSERT_STYLE=0
    113     -DLV_USE_USER_DATA=1
    114     -DLV_FONT_UNSCII_8=1
    115     -DLV_USE_FONT_SUBPX=1
    116     -DLV_USE_BIDI=0
    117     -DLV_USE_ARABIC_PERSIAN_CHARS=0
    118     ${LVGL_TEST_COMMON_EXAMPLE_OPTIONS}
    119     -DLV_FONT_DEFAULT=&lv_font_montserrat_14
    120     -DLV_USE_PNG=1
    121     -DLV_USE_BMP=1
    122     -DLV_USE_SJPG=1
    123     -DLV_USE_GIF=1
    124     -DLV_USE_QRCODE=1
    125 )
    126 
    127 set(LVGL_TEST_OPTIONS_FULL_32BIT
    128     -DLV_COLOR_DEPTH=32
    129     -DLV_MEM_SIZE=8388608
    130     -DLV_DPI_DEF=160
    131     -DLV_DRAW_COMPLEX=1
    132     -DLV_SHADOW_CACHE_SIZE=1
    133     -DLV_IMG_CACHE_DEF_SIZE=32
    134     -DLV_USE_LOG=1
    135     -DLV_LOG_LEVEL=LV_LOG_LEVEL_TRACE
    136     -DLV_LOG_PRINTF=1
    137     -DLV_USE_FONT_SUBPX=1
    138     -DLV_FONT_SUBPX_BGR=1
    139     -DLV_USE_PERF_MONITOR=1
    140     -DLV_USE_ASSERT_NULL=1
    141     -DLV_USE_ASSERT_MALLOC=1
    142     -DLV_USE_ASSERT_MEM_INTEGRITY=1
    143     -DLV_USE_ASSERT_OBJ=1
    144     -DLV_USE_ASSERT_STYLE=1
    145     -DLV_USE_USER_DATA=1
    146     -DLV_USE_LARGE_COORD=1
    147     -DLV_FONT_MONTSERRAT_8=1
    148     -DLV_FONT_MONTSERRAT_10=1
    149     -DLV_FONT_MONTSERRAT_12=1
    150     -DLV_FONT_MONTSERRAT_14=1
    151     -DLV_FONT_MONTSERRAT_16=1
    152     -DLV_FONT_MONTSERRAT_18=1
    153     -DLV_FONT_MONTSERRAT_20=1
    154     -DLV_FONT_MONTSERRAT_22=1
    155     -DLV_FONT_MONTSERRAT_24=1
    156     -DLV_FONT_MONTSERRAT_26=1
    157     -DLV_FONT_MONTSERRAT_28=1
    158     -DLV_FONT_MONTSERRAT_30=1
    159     -DLV_FONT_MONTSERRAT_32=1
    160     -DLV_FONT_MONTSERRAT_34=1
    161     -DLV_FONT_MONTSERRAT_36=1
    162     -DLV_FONT_MONTSERRAT_38=1
    163     -DLV_FONT_MONTSERRAT_40=1
    164     -DLV_FONT_MONTSERRAT_42=1
    165     -DLV_FONT_MONTSERRAT_44=1
    166     -DLV_FONT_MONTSERRAT_46=1
    167     -DLV_FONT_MONTSERRAT_48=1
    168     -DLV_FONT_MONTSERRAT_12_SUBPX=1
    169     -DLV_FONT_MONTSERRAT_28_COMPRESSED=1
    170     -DLV_FONT_DEJAVU_16_PERSIAN_HEBREW=1
    171     -DLV_FONT_SIMSUN_16_CJK=1
    172     -DLV_FONT_UNSCII_8=1
    173     -DLV_FONT_UNSCII_16=1
    174     -DLV_FONT_FMT_TXT_LARGE=1
    175     -DLV_USE_FONT_COMPRESSED=1
    176     -DLV_USE_BIDI=1
    177     -DLV_USE_ARABIC_PERSIAN_CHARS=1
    178     -DLV_USE_PERF_MONITOR=1
    179     -DLV_USE_MEM_MONITOR=1
    180     -DLV_LABEL_TEXT_SELECTION=1
    181     ${LVGL_TEST_COMMON_EXAMPLE_OPTIONS}
    182     -DLV_FONT_DEFAULT=&lv_font_montserrat_24
    183     -DLV_USE_FS_STDIO=1
    184     -DLV_FS_STDIO_LETTER='A'
    185     -DLV_USE_FS_POSIX=1
    186     -DLV_FS_POSIX_LETTER='B'
    187     -DLV_USE_PNG=1
    188     -DLV_USE_BMP=1
    189     -DLV_USE_SJPG=1
    190     -DLV_USE_GIF=1
    191     -DLV_USE_QRCODE=1
    192     -DLV_USE_FRAGMENT=1
    193     -DLV_USE_IMGFONT=1
    194     -DLV_USE_MSG=1
    195 )
    196 
    197 set(LVGL_TEST_OPTIONS_TEST_COMMON
    198     --coverage
    199     -DLV_COLOR_DEPTH=32
    200     -DLV_MEM_SIZE=2097152
    201     -DLV_SHADOW_CACHE_SIZE=10240
    202     -DLV_IMG_CACHE_DEF_SIZE=32
    203     -DLV_DITHER_GRADIENT=1
    204     -DLV_DITHER_ERROR_DIFFUSION=1
    205     -DLV_GRAD_CACHE_DEF_SIZE=8*1024
    206     -DLV_USE_LOG=1
    207     -DLV_LOG_PRINTF=1
    208     -DLV_USE_FONT_SUBPX=1
    209     -DLV_FONT_SUBPX_BGR=1
    210     -DLV_USE_ASSERT_NULL=0
    211     -DLV_USE_ASSERT_MALLOC=0
    212     -DLV_USE_ASSERT_MEM_INTEGRITY=0
    213     -DLV_USE_ASSERT_OBJ=0
    214     -DLV_USE_ASSERT_STYLE=0
    215     -DLV_USE_USER_DATA=1
    216     -DLV_USE_LARGE_COORD=1
    217     -DLV_FONT_MONTSERRAT_14=1
    218     -DLV_FONT_MONTSERRAT_16=1
    219     -DLV_FONT_MONTSERRAT_18=1
    220     -DLV_FONT_MONTSERRAT_24=1
    221     -DLV_FONT_MONTSERRAT_48=1
    222     -DLV_FONT_MONTSERRAT_12_SUBPX=1
    223     -DLV_FONT_MONTSERRAT_28_COMPRESSED=1
    224     -DLV_FONT_DEJAVU_16_PERSIAN_HEBREW=1
    225     -DLV_FONT_SIMSUN_16_CJK=1
    226     -DLV_FONT_UNSCII_8=1
    227     -DLV_FONT_UNSCII_16=1
    228     -DLV_FONT_FMT_TXT_LARGE=1
    229     -DLV_USE_FONT_COMPRESSED=1
    230     -DLV_USE_BIDI=1
    231     -DLV_USE_ARABIC_PERSIAN_CHARS=1
    232     -DLV_LABEL_TEXT_SELECTION=1
    233     -DLV_USE_FS_STDIO=1
    234     -DLV_FS_STDIO_LETTER='A'
    235     -DLV_FS_STDIO_CACHE_SIZE=100
    236     -DLV_USE_FS_POSIX=1
    237     -DLV_FS_POSIX_LETTER='B'
    238     -DLV_FS_POSIX_CACHE_SIZE=0
    239     ${LVGL_TEST_COMMON_EXAMPLE_OPTIONS}
    240     -DLV_FONT_DEFAULT=&lv_font_montserrat_14
    241     -Wno-unused-but-set-variable # unused variables are common in the dual-heap arrangement
    242     -Wno-unused-variable
    243 )
    244 
    245 set(LVGL_TEST_OPTIONS_TEST_SYSHEAP
    246     ${LVGL_TEST_OPTIONS_TEST_COMMON}
    247     -DLVGL_CI_USING_SYS_HEAP
    248     -DLV_MEM_CUSTOM=1
    249     -fsanitize=address
    250 )
    251 
    252 set(LVGL_TEST_OPTIONS_TEST_DEFHEAP
    253     ${LVGL_TEST_OPTIONS_TEST_COMMON}
    254     -DLVGL_CI_USING_DEF_HEAP
    255     -DLV_MEM_SIZE=2097152
    256     -fsanitize=address
    257 )
    258 
    259 if (OPTIONS_MINIMAL_MONOCHROME)
    260     set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_MINIMAL_MONOCHROME})
    261 elseif (OPTIONS_NORMAL_8BIT)
    262     set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_NORMAL_8BIT})
    263 elseif (OPTIONS_16BIT)
    264     set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_16BIT})
    265 elseif (OPTIONS_16BIT_SWAP)
    266     set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_16BIT_SWAP})
    267 elseif (OPTIONS_FULL_32BIT)
    268     set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_FULL_32BIT})
    269 elseif (OPTIONS_TEST_SYSHEAP)
    270     set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_TEST_SYSHEAP})
    271     set (TEST_LIBS --coverage -fsanitize=address)
    272 elseif (OPTIONS_TEST_DEFHEAP)
    273     set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_TEST_DEFHEAP})
    274     set (TEST_LIBS --coverage -fsanitize=address)
    275 else()
    276     message(FATAL_ERROR "Must provide a known options value (check main.py?).")
    277 endif()
    278 
    279 # Options lvgl and examples are compiled with.
    280 set(COMPILE_OPTIONS
    281     -DLV_CONF_PATH=${LVGL_TEST_DIR}/src/lv_test_conf.h
    282     -DLV_BUILD_TEST
    283     -pedantic-errors
    284     -Wall
    285     -Wclobbered
    286     -Wdeprecated
    287     -Wdouble-promotion
    288     -Wempty-body
    289     -Werror
    290     -Wextra
    291     -Wformat-security
    292     -Wmaybe-uninitialized
    293     -Wmissing-prototypes
    294     -Wpointer-arith
    295     -Wmultichar
    296     -Wno-discarded-qualifiers
    297     -Wpedantic
    298     -Wreturn-type
    299     -Wshadow
    300     -Wshift-negative-value
    301     -Wsizeof-pointer-memaccess
    302     -Wstack-usage=5000
    303     -Wtype-limits
    304     -Wundef
    305     -Wuninitialized
    306     -Wunreachable-code
    307     ${BUILD_OPTIONS}
    308 )
    309 
    310 # Options test cases are compiled with.
    311 set(LVGL_TESTFILE_COMPILE_OPTIONS
    312     ${COMPILE_OPTIONS}
    313     -Wno-missing-prototypes
    314 )
    315 
    316 get_filename_component(LVGL_DIR ${LVGL_TEST_DIR} DIRECTORY)
    317 
    318 # Include lvgl project file.
    319 include(${LVGL_DIR}/CMakeLists.txt)
    320 target_compile_options(lvgl PUBLIC ${COMPILE_OPTIONS})
    321 target_compile_options(lvgl_examples PUBLIC ${COMPILE_OPTIONS})
    322 
    323 
    324 set(TEST_INCLUDE_DIRS
    325     $<BUILD_INTERFACE:${LVGL_TEST_DIR}/src>
    326     $<BUILD_INTERFACE:${LVGL_TEST_DIR}/unity>
    327     $<BUILD_INTERFACE:${LVGL_TEST_DIR}>
    328 )
    329 
    330 add_library(test_common
    331     STATIC
    332         src/lv_test_indev.c
    333         src/lv_test_init.c
    334         src/test_fonts/font_1.c
    335         src/test_fonts/font_2.c
    336         src/test_fonts/font_3.c
    337         unity/unity_support.c
    338         unity/unity.c
    339 )
    340 target_include_directories(test_common PUBLIC ${TEST_INCLUDE_DIRS})
    341 target_compile_options(test_common PUBLIC ${LVGL_TESTFILE_COMPILE_OPTIONS})
    342 
    343 # Some examples `#include "lvgl/lvgl.h"` - which is a path which is not
    344 # in this source repository. If this repo is in a directory names 'lvgl'
    345 # then we can add our parent directory to the include path.
    346 # TODO: This is not good practice and should be fixed.
    347 get_filename_component(LVGL_PARENT_DIR ${LVGL_DIR} DIRECTORY)
    348 target_include_directories(lvgl_examples PUBLIC $<BUILD_INTERFACE:${LVGL_PARENT_DIR}>)
    349 
    350 # Generate one test executable for each source file pair.
    351 # The sources in src/test_runners is auto-generated, the
    352 # sources in src/test_cases is the actual test case.
    353 file( GLOB TEST_CASE_FILES src/test_cases/*.c )
    354 foreach( test_case_fname ${TEST_CASE_FILES} )
    355     # If test file is foo/bar/baz.c then test_name is "baz".
    356     get_filename_component(test_name ${test_case_fname} NAME_WLE)
    357     if (${test_name} STREQUAL "_test_template")
    358         continue()
    359     endif()
    360     # Create path to auto-generated source file.
    361     set(test_runner_fname src/test_runners/${test_name}_Runner.c)
    362     add_executable( ${test_name}
    363         ${test_case_fname}
    364         ${test_runner_fname}
    365     )
    366     target_link_libraries(${test_name} test_common lvgl_examples lvgl_demos lvgl png ${TEST_LIBS})
    367     target_include_directories(${test_name} PUBLIC ${TEST_INCLUDE_DIRS})
    368     target_compile_options(${test_name} PUBLIC ${LVGL_TESTFILE_COMPILE_OPTIONS})
    369 
    370     add_test(
    371         NAME ${test_name}
    372         WORKING_DIRECTORY ${LVGL_TEST_DIR}
    373         COMMAND ${test_name})
    374 endforeach( test_case_fname ${TEST_CASE_FILES} )
    375 
    376 endif()