Skip to content

Commit e72f52d

Browse files
authored
feat(CI): Windows MSVC and GCC build (lvgl#6015)
1 parent d0436fb commit e72f52d

20 files changed

+269
-92
lines changed

.github/workflows/ccpp.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,37 @@ jobs:
2727
- name: Building ${{ matrix.build_option }}
2828
run: python tests/main.py --build-option=${{ matrix.build_option }} build
2929

30+
build-windows-GCC:
31+
runs-on: windows-2022
32+
name: Build Windows GCC
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: ammaraskar/gcc-problem-matcher@master
36+
- name: Install prerequisites
37+
run: scripts\install-prerequisites.bat
38+
- name: Build
39+
run: python tests/main.py build
40+
env:
41+
CC: gcc
42+
43+
build-windows-MSVC:
44+
runs-on: windows-2022
45+
name: Build Windows MSVC
46+
steps:
47+
- uses: actions/checkout@v4
48+
- name: Install prerequisites
49+
run: scripts\install-prerequisites.bat
50+
- uses: ilammy/msvc-dev-cmd@v1
51+
with:
52+
arch: x64
53+
- uses: ruby/setup-ruby@v1
54+
with:
55+
ruby-version: 'mswin'
56+
- name: Build
57+
run: python tests/main.py build
58+
env:
59+
CC: cl
60+
3061
test-native:
3162
runs-on: ubuntu-latest
3263
name: amd64 Executable Tests

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ cmake_minimum_required(VERSION 3.12.4)
33
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
44

55
if(NOT ESP_PLATFORM)
6-
project(lvgl LANGUAGES C CXX ASM HOMEPAGE_URL https://github.com/lvgl/lvgl)
6+
if(NOT (CMAKE_C_COMPILER_ID STREQUAL "MSVC"))
7+
project(lvgl LANGUAGES C CXX ASM HOMEPAGE_URL https://github.com/lvgl/lvgl)
8+
else()
9+
project(lvgl LANGUAGES C CXX HOMEPAGE_URL https://github.com/lvgl/lvgl)
10+
endif()
711
endif()
812

913
set(LVGL_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})

env_support/cmake/custom.cmake

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ file(GLOB_RECURSE THORVG_SOURCES ${LVGL_ROOT_DIR}/src/libs/thorvg/*.cpp ${LVGL_R
2525
add_library(lvgl ${SOURCES})
2626
add_library(lvgl::lvgl ALIAS lvgl)
2727

28-
target_compile_definitions(
29-
lvgl PUBLIC $<$<BOOL:${LV_LVGL_H_INCLUDE_SIMPLE}>:LV_LVGL_H_INCLUDE_SIMPLE>
30-
$<$<BOOL:${LV_CONF_INCLUDE_SIMPLE}>:LV_CONF_INCLUDE_SIMPLE>
31-
$<$<COMPILE_LANGUAGE:ASM>:__ASSEMBLY__>)
28+
if(NOT (CMAKE_C_COMPILER_ID STREQUAL "MSVC"))
29+
target_compile_definitions(
30+
lvgl PUBLIC $<$<BOOL:${LV_LVGL_H_INCLUDE_SIMPLE}>:LV_LVGL_H_INCLUDE_SIMPLE>
31+
$<$<BOOL:${LV_CONF_INCLUDE_SIMPLE}>:LV_CONF_INCLUDE_SIMPLE>
32+
$<$<COMPILE_LANGUAGE:ASM>:__ASSEMBLY__>)
33+
else()
34+
target_compile_definitions(
35+
lvgl PUBLIC $<$<BOOL:${LV_LVGL_H_INCLUDE_SIMPLE}>:LV_LVGL_H_INCLUDE_SIMPLE>
36+
$<$<BOOL:${LV_CONF_INCLUDE_SIMPLE}>:LV_CONF_INCLUDE_SIMPLE>)
37+
endif()
3238

3339
# Add definition of LV_CONF_PATH only if needed
3440
if(LV_CONF_PATH)
@@ -51,7 +57,9 @@ if(NOT LV_CONF_BUILD_DISABLE_THORVG_INTERNAL)
5157
target_link_libraries(lvgl_thorvg PUBLIC lvgl)
5258
endif()
5359

54-
set_source_files_properties(${LVGL_ROOT_DIR}/src/others/vg_lite_tvg/vg_lite_tvg.cpp PROPERTIES COMPILE_FLAGS -Wunused-parameter)
60+
if(NOT (CMAKE_C_COMPILER_ID STREQUAL "MSVC"))
61+
set_source_files_properties(${LVGL_ROOT_DIR}/src/others/vg_lite_tvg/vg_lite_tvg.cpp PROPERTIES COMPILE_FLAGS -Wunused-parameter)
62+
endif()
5563

5664
# Build LVGL example library
5765
if(NOT LV_CONF_BUILD_DISABLE_EXAMPLES)

scripts/install-prerequisites.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
vcpkg install vcpkg-tool-ninja libpng freetype
2+
if %errorlevel% neq 0 exit /b %errorlevel%
3+
pip install pypng lz4
4+
if %errorlevel% neq 0 exit /b %errorlevel%

src/draw/vg_lite/lv_draw_vg_lite_vector.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "lv_vg_lite_pending.h"
1717
#include "lv_vg_lite_utils.h"
1818
#include "lv_vg_lite_grad.h"
19+
#include <float.h>
1920

2021
/*********************
2122
* DEFINES
@@ -290,10 +291,10 @@ static void lv_path_to_vg(lv_vg_lite_path_t * dest, const lv_vector_path_t * src
290291
lv_vg_lite_path_set_quality(dest, lv_quality_to_vg(src->quality));
291292

292293
/* init bounds */
293-
float min_x = __FLT_MAX__;
294-
float min_y = __FLT_MAX__;
295-
float max_x = __FLT_MIN__;
296-
float max_y = __FLT_MIN__;
294+
float min_x = FLT_MAX;
295+
float min_y = FLT_MAX;
296+
float max_x = FLT_MIN;
297+
float max_y = FLT_MIN;
297298

298299
#define CMP_BOUNDS(point) \
299300
do { \

src/draw/vg_lite/lv_vg_lite_path.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ bool lv_vg_lite_path_update_bonding_box(lv_vg_lite_path_t * path)
218218
lv_vg_lite_path_bounds_t bounds;
219219

220220
/* init bounds */
221-
bounds.min_x = __FLT_MAX__;
222-
bounds.min_y = __FLT_MAX__;
223-
bounds.max_x = __FLT_MIN__;
224-
bounds.max_y = __FLT_MIN__;
221+
bounds.min_x = FLT_MAX;
222+
bounds.min_y = FLT_MAX;
223+
bounds.max_x = FLT_MIN;
224+
bounds.max_y = FLT_MIN;
225225

226226
/* calc bounds */
227227
lv_vg_lite_path_for_each_data(lv_vg_lite_path_get_path(path), path_bounds_iter_cb, &bounds);

src/drivers/windows/lv_windows_context.c

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
#include "lv_windows_context.h"
1111
#if LV_USE_WINDOWS
1212

13+
#ifdef __GNUC__
14+
#pragma GCC diagnostic ignored "-Wcast-function-type"
15+
#endif
16+
1317
#include "lv_windows_display.h"
18+
#include "lv_windows_input_private.h"
1419

1520
/*********************
1621
* DEFINES
@@ -37,27 +42,6 @@ static LRESULT CALLBACK lv_windows_window_message_callback(
3742
WPARAM wParam,
3843
LPARAM lParam);
3944

40-
bool lv_windows_pointer_device_window_message_handler(
41-
HWND hWnd,
42-
UINT uMsg,
43-
WPARAM wParam,
44-
LPARAM lParam,
45-
LRESULT * plResult);
46-
47-
bool lv_windows_keypad_device_window_message_handler(
48-
HWND hWnd,
49-
UINT uMsg,
50-
WPARAM wParam,
51-
LPARAM lParam,
52-
LRESULT * plResult);
53-
54-
bool lv_windows_encoder_device_window_message_handler(
55-
HWND hWnd,
56-
UINT uMsg,
57-
WPARAM wParam,
58-
LPARAM lParam,
59-
LRESULT * plResult);
60-
6145
/**********************
6246
* STATIC VARIABLES
6347
**********************/
@@ -154,6 +138,7 @@ static void lv_windows_delay_callback(uint32_t ms)
154138
static void lv_windows_check_display_existence_timer_callback(
155139
lv_timer_t * timer)
156140
{
141+
LV_UNUSED(timer);
157142
if(!lv_display_get_next(NULL)) {
158143
// Don't use lv_deinit() due to it will cause exception when parallel
159144
// rendering is enabled.
@@ -186,7 +171,7 @@ static HDC lv_windows_create_frame_buffer(
186171
typedef struct _BITMAPINFO_16BPP {
187172
BITMAPINFOHEADER bmiHeader;
188173
DWORD bmiColorMask[3];
189-
} BITMAPINFO_16BPP, * PBITMAPINFO_16BPP;
174+
} BITMAPINFO_16BPP;
190175

191176
BITMAPINFO_16BPP bitmap_info = { 0 };
192177
#else
@@ -275,7 +260,7 @@ static void lv_windows_display_timer_callback(lv_timer_t * timer)
275260
context->display_device_object,
276261
context->display_framebuffer_base,
277262
NULL,
278-
context->display_framebuffer_size,
263+
(uint32_t)context->display_framebuffer_size,
279264
LV_DISPLAY_RENDER_MODE_DIRECT);
280265
}
281266
}
@@ -290,6 +275,8 @@ static void lv_windows_display_driver_flush_callback(
290275
const lv_area_t * area,
291276
uint8_t * px_map)
292277
{
278+
LV_UNUSED(area);
279+
293280
HWND window_handle = lv_windows_get_display_window_handle(display);
294281
if(!window_handle) {
295282
lv_display_flush_ready(display);

src/drivers/windows/lv_windows_input.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@
1010
#include "lv_windows_input.h"
1111
#if LV_USE_WINDOWS
1212

13+
#ifdef __GNUC__
14+
#pragma GCC diagnostic ignored "-Wcast-function-type"
15+
#endif
16+
1317
#include "lv_windows_context.h"
1418
#include "lv_windows_display.h"
19+
#include "lv_windows_input_private.h"
20+
#include "../../misc/lv_text_private.h"
1521

1622
#include <windowsx.h>
1723

@@ -557,6 +563,8 @@ bool lv_windows_keypad_device_window_message_handler(
557563
LPARAM lParam,
558564
LRESULT * plResult)
559565
{
566+
LV_UNUSED(lParam);
567+
560568
switch(uMsg) {
561569
case WM_KEYDOWN:
562570
case WM_KEYUP: {
@@ -791,6 +799,8 @@ bool lv_windows_encoder_device_window_message_handler(
791799
LPARAM lParam,
792800
LRESULT * plResult)
793801
{
802+
LV_UNUSED(lParam);
803+
794804
switch(uMsg) {
795805
case WM_MBUTTONDOWN:
796806
case WM_MBUTTONUP: {
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* @file lv_windows_input_private.h
3+
*
4+
*/
5+
6+
#ifndef LV_WINDOWS_INPUT_PRIVATE_H
7+
#define LV_WINDOWS_INPUT_PRIVATE_H
8+
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
13+
/*********************
14+
* INCLUDES
15+
*********************/
16+
17+
#if LV_USE_WINDOWS
18+
19+
#include <stdbool.h>
20+
#include <windows.h>
21+
22+
/*********************
23+
* DEFINES
24+
*********************/
25+
26+
/**********************
27+
* TYPEDEFS
28+
**********************/
29+
30+
/**********************
31+
* GLOBAL PROTOTYPES
32+
**********************/
33+
34+
bool lv_windows_pointer_device_window_message_handler(
35+
HWND hWnd,
36+
UINT uMsg,
37+
WPARAM wParam,
38+
LPARAM lParam,
39+
LRESULT * plResult);
40+
41+
bool lv_windows_keypad_device_window_message_handler(
42+
HWND hWnd,
43+
UINT uMsg,
44+
WPARAM wParam,
45+
LPARAM lParam,
46+
LRESULT * plResult);
47+
48+
bool lv_windows_encoder_device_window_message_handler(
49+
HWND hWnd,
50+
UINT uMsg,
51+
WPARAM wParam,
52+
LPARAM lParam,
53+
LRESULT * plResult);
54+
55+
/**********************
56+
* MACROS
57+
**********************/
58+
59+
#endif // LV_USE_WINDOWS
60+
61+
#ifdef __cplusplus
62+
} /*extern "C"*/
63+
#endif
64+
65+
#endif /*LV_WINDOWS_INPUT_PRIVATE_H*/

src/libs/fsdrv/lv_fs_stdio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* TYPEDEFS
2828
**********************/
2929
typedef struct {
30-
#ifdef WIN32
30+
#ifdef _WIN32
3131
HANDLE dir_p;
3232
char next_fn[MAX_PATH_LEN];
3333
#else

src/libs/fsdrv/lv_fs_win32.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ static void * fs_dir_open(lv_fs_drv_t * drv, const char * path)
413413
static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn, uint32_t fn_len)
414414
{
415415
LV_UNUSED(drv);
416+
LV_UNUSED(fn_len);
416417
dir_handle_t * handle = (dir_handle_t *)dir_p;
417418
lv_strcpy(fn, handle->next_fn);
418419
lv_fs_res_t current_error = handle->next_error;

src/libs/tjpgd/lv_tjpgd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static lv_result_t decoder_get_area(lv_image_decoder_t * decoder, lv_image_decod
223223
if(decoded_area->y1 == LV_COORD_MIN) {
224224
decoded_area->y1 = 0;
225225
decoded_area->y2 = my - 1;
226-
decoded_area->x1 = -mx;
226+
decoded_area->x1 = -((int32_t)mx);
227227
decoded_area->x2 = -1;
228228
jd->scale = 0;
229229
jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0; /* Initialize DC values */

src/lvgl_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extern "C" {
1919
#include "libs/freetype/lv_freetype_private.h"
2020
#include "misc/cache/lv_cache_entry_private.h"
2121
#include "misc/cache/lv_cache_private.h"
22+
#include "drivers/windows/lv_windows_input_private.h"
2223

2324
/*********************
2425
* DEFINES

src/others/vg_lite_tvg/vg_lite.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@
3232
extern "C" {
3333
#endif
3434

35+
/**
36+
* causes MSVC error C1189.
37+
* Not needed because "The __inline keyword is equivalent to inline."
38+
* See: https://learn.microsoft.com/en-us/cpp/cpp/inline-functions-cpp?view=msvc-170
39+
*/
40+
/*
3541
#if defined(_MSC_VER)
3642
#define inline __inline
3743
#endif
44+
*/
3845

3946
#include <stddef.h>
4047
#include <stdint.h>

src/others/vg_lite_tvg/vg_lite_tvg.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,11 @@ extern "C" {
463463
vg_lite_uint32_t stride = VG_LITE_ALIGN((buffer->width * mul / div), align);
464464

465465
buffer->stride = stride;
466+
#ifndef _WIN32
466467
buffer->memory = aligned_alloc(LV_VG_LITE_THORVG_BUF_ADDR_ALIGN, stride * buffer->height);
468+
#else
469+
buffer->memory = _aligned_malloc(stride * buffer->height, LV_VG_LITE_THORVG_BUF_ADDR_ALIGN);
470+
#endif
467471
LV_ASSERT(buffer->memory);
468472
buffer->address = (vg_lite_uint32_t)(uintptr_t)buffer->memory;
469473
buffer->handle = buffer->memory;
@@ -473,7 +477,11 @@ extern "C" {
473477
vg_lite_error_t vg_lite_free(vg_lite_buffer_t * buffer)
474478
{
475479
LV_ASSERT(buffer->memory);
480+
#ifndef _WIN32
476481
free(buffer->memory);
482+
#else
483+
_aligned_free(buffer->memory);
484+
#endif
477485
memset(buffer, 0, sizeof(vg_lite_buffer_t));
478486
return VG_LITE_SUCCESS;
479487
}
@@ -2190,8 +2198,8 @@ static Result shape_append_path(std::unique_ptr<Shape> & shape, vg_lite_path_t *
21902198
float x_max = path->bounding_box[2];
21912199
float y_max = path->bounding_box[3];
21922200

2193-
if(math_equal(x_min, __FLT_MIN__) && math_equal(y_min, __FLT_MIN__)
2194-
&& math_equal(x_max, __FLT_MAX__) && math_equal(y_max, __FLT_MAX__)) {
2201+
if(math_equal(x_min, FLT_MIN) && math_equal(y_min, FLT_MIN)
2202+
&& math_equal(x_max, FLT_MAX) && math_equal(y_max, FLT_MAX)) {
21952203
return Result::Success;
21962204
}
21972205

0 commit comments

Comments
 (0)