From 7cb266c086474515b7ec741e9dfac8bb01a39052 Mon Sep 17 00:00:00 2001 From: Michael Simon Date: Sat, 20 Apr 2024 20:49:56 +0200 Subject: [PATCH] feat(ci): Add CI test for UEFI build (#5964) Co-authored-by: Gabor Kiss-Vamosi --- .github/workflows/makefile_uefi.yml | 23 +++ .../others/imgfont/lv_example_imgfont_1.c | 1 - examples/widgets/list/lv_example_list_2.c | 6 +- src/drivers/nuttx/lv_nuttx_libuv.c | 2 +- src/libs/gif/gifdec.h | 2 +- src/libs/lodepng/lodepng.h | 3 +- src/libs/lodepng/lv_lodepng.c | 2 +- src/libs/qrcode/qrcodegen.c | 7 +- src/libs/qrcode/qrcodegen.h | 5 + src/libs/tjpgd/tjpgd.c | 2 + src/libs/tjpgd/tjpgd.h | 5 + src/others/snapshot/lv_snapshot.h | 7 +- tests/makefile_uefi/.gitignore | 1 + tests/makefile_uefi/Makefile | 38 +++++ tests/makefile_uefi/efi.h | 160 ++++++++++++++++++ tests/makefile_uefi/test.c | 35 ++++ 16 files changed, 284 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/makefile_uefi.yml create mode 100644 tests/makefile_uefi/.gitignore create mode 100644 tests/makefile_uefi/Makefile create mode 100644 tests/makefile_uefi/efi.h create mode 100644 tests/makefile_uefi/test.c diff --git a/.github/workflows/makefile_uefi.yml b/.github/workflows/makefile_uefi.yml new file mode 100644 index 000000000..8699f5541 --- /dev/null +++ b/.github/workflows/makefile_uefi.yml @@ -0,0 +1,23 @@ +name: Check Makefile for UEFI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} + runs-on: ubuntu-latest + name: Build using Makefile for UEFI + steps: + - uses: actions/checkout@v4 + - uses: ammaraskar/gcc-problem-matcher@master + - name: Install prerequisites + run: scripts/install-prerequisites.sh + - name: Install clang + run: sudo apt-get install clang lld + - name: Build + working-directory: tests/makefile_uefi + run: make -j diff --git a/examples/others/imgfont/lv_example_imgfont_1.c b/examples/others/imgfont/lv_example_imgfont_1.c index 8e0aa6d8d..dd103c905 100644 --- a/examples/others/imgfont/lv_example_imgfont_1.c +++ b/examples/others/imgfont/lv_example_imgfont_1.c @@ -1,5 +1,4 @@ #include "../../lv_examples.h" -#include #if LV_BUILD_EXAMPLES #if LV_USE_IMGFONT diff --git a/examples/widgets/list/lv_example_list_2.c b/examples/widgets/list/lv_example_list_2.c index 96b8548dc..c50201312 100644 --- a/examples/widgets/list/lv_example_list_2.c +++ b/examples/widgets/list/lv_example_list_2.c @@ -1,5 +1,3 @@ -#include - #include "../../lv_examples.h" #if LV_USE_LIST && LV_BUILD_EXAMPLES @@ -102,8 +100,8 @@ static void event_handler_swap(lv_event_t * e) uint32_t cnt = lv_obj_get_child_count(list1); for(int i = 0; i < 100; i++) if(cnt > 1) { - lv_obj_t * obj = lv_obj_get_child(list1, rand() % cnt); - lv_obj_move_to_index(obj, rand() % cnt); + lv_obj_t * obj = lv_obj_get_child(list1, lv_rand(0, cnt)); + lv_obj_move_to_index(obj, lv_rand(0, cnt)); if(currentButton != NULL) { lv_obj_scroll_to_view(currentButton, LV_ANIM_ON); } diff --git a/src/drivers/nuttx/lv_nuttx_libuv.c b/src/drivers/nuttx/lv_nuttx_libuv.c index 7d56bf54f..0235e5ec0 100644 --- a/src/drivers/nuttx/lv_nuttx_libuv.c +++ b/src/drivers/nuttx/lv_nuttx_libuv.c @@ -6,12 +6,12 @@ * INCLUDES *********************/ #include "lv_nuttx_libuv.h" -#include #include "../../../lvgl.h" #include "../../lvgl_private.h" #if LV_USE_NUTTX +#include #if LV_USE_NUTTX_LIBUV #include diff --git a/src/libs/gif/gifdec.h b/src/libs/gif/gifdec.h index 3fd60bf3b..21ff210ab 100644 --- a/src/libs/gif/gifdec.h +++ b/src/libs/gif/gifdec.h @@ -5,10 +5,10 @@ extern "C" { #endif -#include #include "../../misc/lv_fs.h" #if LV_USE_GIF +#include typedef struct _gd_Palette { int size; diff --git a/src/libs/lodepng/lodepng.h b/src/libs/lodepng/lodepng.h index de9eec5ff..2670e1c32 100644 --- a/src/libs/lodepng/lodepng.h +++ b/src/libs/lodepng/lodepng.h @@ -30,10 +30,9 @@ freely, subject to the following restrictions: extern "C" { #endif -#include /*for size_t*/ - #include "../../../lvgl.h" #if LV_USE_LODEPNG +#include LV_STDDEF_INCLUDE /*for size_t*/ LV_ATTRIBUTE_EXTERN_DATA extern const char * LODEPNG_VERSION_STRING; /* diff --git a/src/libs/lodepng/lv_lodepng.c b/src/libs/lodepng/lv_lodepng.c index 5310b6989..b2ed520b5 100644 --- a/src/libs/lodepng/lv_lodepng.c +++ b/src/libs/lodepng/lv_lodepng.c @@ -121,7 +121,7 @@ static lv_result_t decoder_info(lv_image_decoder_t * decoder, const void * src, const uint32_t * size = ((uint32_t *)img_dsc->data) + 4; const uint8_t magic[] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a}; if(data_size < sizeof(magic)) return LV_RESULT_INVALID; - if(memcmp(magic, img_dsc->data, sizeof(magic))) return LV_RESULT_INVALID; + if(lv_memcmp(magic, img_dsc->data, sizeof(magic))) return LV_RESULT_INVALID; header->cf = LV_COLOR_FORMAT_ARGB8888; diff --git a/src/libs/qrcode/qrcodegen.c b/src/libs/qrcode/qrcodegen.c index 8f71f4724..f501a248f 100644 --- a/src/libs/qrcode/qrcodegen.c +++ b/src/libs/qrcode/qrcodegen.c @@ -21,11 +21,13 @@ * Software. */ +#include "qrcodegen.h" +#include "../../misc/lv_assert.h" + +#if LV_USE_QRCODE #include #include #include -#include "qrcodegen.h" -#include "../../misc/lv_assert.h" #ifndef QRCODEGEN_TEST #define testable static // Keep functions private @@ -1111,3 +1113,4 @@ int qrcodegen_version2size(int version) return ((version - 1) * 4 + 21); } +#endif diff --git a/src/libs/qrcode/qrcodegen.h b/src/libs/qrcode/qrcodegen.h index 986bada58..950948684 100644 --- a/src/libs/qrcode/qrcodegen.h +++ b/src/libs/qrcode/qrcodegen.h @@ -23,6 +23,9 @@ #pragma once +#include "../../../lvgl.h" +#ifdef LV_USE_QRCODE + #include #include #include @@ -317,3 +320,5 @@ int qrcodegen_getMinFitVersion(enum qrcodegen_Ecc ecl, size_t dataLen); #ifdef __cplusplus } #endif + +#endif diff --git a/src/libs/tjpgd/tjpgd.c b/src/libs/tjpgd/tjpgd.c index 22dfd5632..f53810d73 100644 --- a/src/libs/tjpgd/tjpgd.c +++ b/src/libs/tjpgd/tjpgd.c @@ -26,6 +26,7 @@ #include "tjpgd.h" +#if LV_USE_TJPGD #if JD_FASTDECODE == 2 #define HUFF_BIT 10 /* Bit length to apply fast huffman decode */ @@ -1135,3 +1136,4 @@ JRESULT jd_decomp( return rc; } +#endif diff --git a/src/libs/tjpgd/tjpgd.h b/src/libs/tjpgd/tjpgd.h index f1b578820..887038a2b 100644 --- a/src/libs/tjpgd/tjpgd.h +++ b/src/libs/tjpgd/tjpgd.h @@ -8,7 +8,11 @@ extern "C" { #endif +#include "../../lv_conf_internal.h" #include "tjpgdcnf.h" + +#if LV_USE_TJPGD + #include #include @@ -95,6 +99,7 @@ JRESULT jd_mcu_output(JDEC * jd, int (*outfunc)(JDEC *, void *, JRECT *), unsign JRESULT jd_restart(JDEC * jd, uint16_t rstn); +#endif #ifdef __cplusplus } diff --git a/src/others/snapshot/lv_snapshot.h b/src/others/snapshot/lv_snapshot.h index f8cd0cae2..3a685cf11 100644 --- a/src/others/snapshot/lv_snapshot.h +++ b/src/others/snapshot/lv_snapshot.h @@ -13,16 +13,17 @@ extern "C" { /********************* * INCLUDES *********************/ +#include "../../core/lv_obj.h" + +#if LV_USE_SNAPSHOT + #include #include -#include "../../core/lv_obj.h" - /********************* * DEFINES *********************/ -#if LV_USE_SNAPSHOT /********************** * TYPEDEFS **********************/ diff --git a/tests/makefile_uefi/.gitignore b/tests/makefile_uefi/.gitignore new file mode 100644 index 000000000..3c0eb7ac0 --- /dev/null +++ b/tests/makefile_uefi/.gitignore @@ -0,0 +1 @@ +test_file diff --git a/tests/makefile_uefi/Makefile b/tests/makefile_uefi/Makefile new file mode 100644 index 000000000..2a3d2e2e3 --- /dev/null +++ b/tests/makefile_uefi/Makefile @@ -0,0 +1,38 @@ +LVGL_PATH := $(CURDIR)/../.. +ARCH = x86_64 +CC = clang +$(info LVGL_PATH is set to: $(LVGL_PATH)) +include ../../lvgl.mk + +CSRCS += test.c +CFLAGS = -Werror -I$(LVGL_PATH)/.. -I$(CURDIR) \ + -target $(ARCH)-unknown-windows -ffreestanding -fshort-wchar -mno-red-zone -fno-stack-protector -fno-stack-check -mno-red-zone \ + -DLV_CONF_SKIP=1 \ + -DLV_BUILD_TEST=1 \ + -DLV_BUILD_EXAMPLES=0 \ + -DLV_COLOR_DEPTH=32 \ + -DLV_USE_STDLIB_MALLOC=LV_STDLIB_BUILTIN \ + -DLV_USE_STDLIB_STRING=LV_STDLIB_BUILTIN \ + -DLV_USE_STDLIB_SPRINTF=LV_STDLIB_BUILTIN \ + -DLV_STDINT_INCLUDE=\"efi.h\" \ + -DLV_STDINT_INCLUDE=\"efi.h\" \ + -DLV_STDDEF_INCLUDE=\"efi.h\" \ + -DLV_STDBOOL_INCLUDE=\"efi.h\" \ + -DLV_INTTYPES_INCLUDE=\"efi.h\" \ + -DLV_LIMITS_INCLUDE=\"efi.h\" \ + -DLV_STDARG_INCLUDE=\"efi.h\" + +LDFLAGS = -target $(ARCH)-unknown-windows -nostdlib -Wl,-entry:efi_main -Wl,-subsystem:efi_application -fuse-ld=lld-link + +COBJS := $(patsubst $(LVGL_PATH)%,objs/%, $(CSRCS:.c=.o)) + +test_file: $(COBJS) + $(CC) -o $@ $^ $(LDFLAGS) + +objs/%.o: $(LVGL_PATH)%.c + mkdir -p $(dir $@) + $(CC) $(CFLAGS) -o $@ -c $^ + +clean: + rm -r $(CURDIR)/objs + rm test_file diff --git a/tests/makefile_uefi/efi.h b/tests/makefile_uefi/efi.h new file mode 100644 index 000000000..9c0516d8a --- /dev/null +++ b/tests/makefile_uefi/efi.h @@ -0,0 +1,160 @@ +#ifndef __LVGL_TESTS_MAKEFILE_UEFI_EFI_H__ +#define __LVGL_TESTS_MAKEFILE_UEFI_EFI_H__ + +#ifndef __clang__ + #error This file is only for use with the clang compiler +#endif + +/************************************* + * TYPES +*************************************/ +#if defined(__x86_64__) + typedef unsigned long long UINT64; + typedef long long INT64; + typedef unsigned int UINT32; + typedef int INT32; + typedef unsigned short UINT16; + typedef unsigned short CHAR16; + typedef short INT16; + typedef unsigned char BOOLEAN; + typedef unsigned char UINT8; + typedef char CHAR8; + typedef signed char INT8; + typedef UINT64 UINTN; + typedef INT64 INTN; + typedef INT64 INTMAX; +#elif defined(__i386__) + typedef unsigned long long UINT64; + typedef long long INT64; + typedef unsigned int UINT32; + typedef int INT32; + typedef unsigned short UINT16; + typedef unsigned short CHAR16; + typedef short INT16; + typedef unsigned char BOOLEAN; + typedef unsigned char UINT8; + typedef char CHAR8; + typedef signed char INT8; + typedef UINT32 UINTN; + typedef INT32 INTN; + typedef INT64 INTMAX; +#elif defined(__aarch64__) + typedef unsigned long long UINT64; + typedef long long INT64; + typedef unsigned int UINT32; + typedef int INT32; + typedef unsigned short UINT16; + typedef unsigned short CHAR16; + typedef short INT16; + typedef unsigned char BOOLEAN; + typedef unsigned char UINT8; + typedef char CHAR8; + typedef signed char INT8; + typedef UINT64 UINTN; + typedef INT64 INTN; + typedef INT64 INTMAX; +#else + #error Architecture is not supported +#endif + +typedef UINT8 uint8_t; +typedef UINT16 uint16_t; +typedef UINT32 uint32_t; +typedef UINT64 uint64_t; +typedef INT8 int8_t; +typedef INT16 int16_t; +typedef INT32 int32_t; +typedef INT64 int64_t; +typedef void VOID; + +typedef uint32_t uint_fast32_t; +typedef UINTN uintptr_t; +typedef UINTN size_t; +typedef INTN intptr_t; +typedef INTMAX intmax_t; +typedef INTN ptrdiff_t; + +typedef UINT8 bool; + +/************************************* + * DEFINES +*************************************/ +#define false 0 +#define true 1 +#define NULL ((void*)0) + +#define PRId8 "d" +#define PRId16 "d" +#define PRId32 "d" +#define PRId64 "d" + +#define PRIu8 "u" +#define PRIu16 "u" +#define PRIu32 "u" +#define PRIu64 "u" + +#define PRIx8 "x" +#define PRIx16 "x" +#define PRIx32 "x" +#define PRIx64 "x" + +#define PRIX8 "X" +#define PRIX16 "X" +#define PRIX32 "X" +#define PRIX64 "X" + +#define offsetof(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field)) + +/************************************* + * LIMITS +*************************************/ +#define INT8_MAX (0x7F) +#define UINT8_MAX (0xFF) +#define INT16_MAX (0x7FFF) +#define UINT16_MAX (0xFFFF) +#define INT32_MAX (0x7FFFFFFF) +#define UINT32_MAX (0xFFFFFFFF) +#define INT64_MAX (0x7FFFFFFFFFFFFFFFULL) +#define UINT64_MAX (0xFFFFFFFFFFFFFFFFULL) +#define INT_MAX (0x7FFFFFFFFFFFFFFFULL) +#define UINT_MAX (0xFFFFFFFFFFFFFFFFULL) + +/// +/// Minimum values for the signed UEFI Data Types +/// +#define INT8_MIN (( -127) - 1) +#define INT16_MIN (( -32767) - 1) +#define INT32_MIN (( -2147483647) - 1) +#define INT64_MIN (( -9223372036854775807LL) - 1) + +#define SIZE_MAX (0xFFFFFFFF) +#define LONG_MAX (0x7FFFFFFF) +#define CHAR_BIT 8 + +/************************************* + * VA_ARG +*************************************/ +typedef __builtin_va_list va_list; +#define va_start(Marker, Parameter) __builtin_va_start (Marker, Parameter) +#define va_arg(Marker, TYPE) ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE))) +#define va_end(Marker) __builtin_va_end (Marker) +#define va_copy(Dest, Start) __builtin_va_copy (Dest, Start) + +/************************************* + * VERIFICATION +*************************************/ +_Static_assert(sizeof(bool) == 1, "Size check for 'bool' failed."); +_Static_assert(sizeof(int8_t) == 1, "Size check for 'int8_t' failed."); +_Static_assert(sizeof(uint8_t) == 1, "Size check for 'uint8_t' failed."); +_Static_assert(sizeof(int16_t) == 2, "Size check for 'int16_t' failed."); +_Static_assert(sizeof(uint16_t) == 2, "Size check for 'uint16_t' failed."); +_Static_assert(sizeof(int32_t) == 4, "Size check for 'int32_t' failed."); +_Static_assert(sizeof(uint32_t) == 4, "Size check for 'uint32_t' failed."); +_Static_assert(sizeof(uint_fast32_t) == 4, "Size check for 'uint_fast32_t' failed."); +_Static_assert(sizeof(int64_t) == 8, "Size check for 'int64_t' failed."); +_Static_assert(sizeof(uint64_t) == 8, "Size check for 'uint64_t' failed."); +_Static_assert(sizeof(intptr_t) == sizeof(void *), "Size check for 'intptr_t' failed."); +_Static_assert(sizeof(ptrdiff_t) == sizeof(void *), "Size check for 'ptrdiff_t' failed."); +_Static_assert(sizeof(uintptr_t) == sizeof(void *), "Size check for 'uintptr_t' failed."); + +#endif diff --git a/tests/makefile_uefi/test.c b/tests/makefile_uefi/test.c new file mode 100644 index 000000000..f40b0e7a3 --- /dev/null +++ b/tests/makefile_uefi/test.c @@ -0,0 +1,35 @@ +#if LV_BUILD_TEST +#include "../../lvgl.h" + +int efi_main(void * image_handle, void * system_table) +{ + lv_init(); + return 0; +} + +// memcpy is required as symbol for the clang compiler +void * memcpy(void * s, const void * ct, size_t n) +{ + const uint8_t * ct_8 = (const uint8_t *) ct; + uint8_t * s_8 = (uint8_t *) s; + + while(n-- > 0) { + *s_8++ = *ct_8++; + } + + return s; +} + +// memset is required as symbol for the clang compiler +void * memset(void * s, int c, size_t n) +{ + uint8_t * s_8 = (uint8_t *)s; + + while(n-- > 0) { + *s_8++ = (uint8_t)c; + } + + return s; +} + +#endif