feat(build): make it work with MSVC build (#4704)

Signed-off-by: YanXiaowei <yanxiaowei@xiaomi.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
Co-authored-by: bjsylvia <bjsylvia@163.com>
Co-authored-by: YanXiaowei <yanxiaowei@xiaomi.com>
Co-authored-by: Niklas Fiekas <niklas.fiekas@backscattering.de>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: lhdjply <1029652979@qq.com>
This commit is contained in:
1000len-4959
2023-11-06 14:34:50 +01:00
committed by Gabor Kiss-Vamosi
parent 96ce505651
commit 361663ee5f
38 changed files with 70 additions and 49 deletions

View File

@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.12.4) cmake_minimum_required(VERSION 3.12.4)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(NOT ESP_PLATFORM) if(NOT ESP_PLATFORM)
project(lvgl HOMEPAGE_URL https://github.com/lvgl/lvgl) project(lvgl HOMEPAGE_URL https://github.com/lvgl/lvgl)
endif() endif()
@@ -15,3 +17,11 @@ elseif(MICROPY_DIR)
else() else()
include(${CMAKE_CURRENT_LIST_DIR}/env_support/cmake/custom.cmake) include(${CMAKE_CURRENT_LIST_DIR}/env_support/cmake/custom.cmake)
endif() endif()
if (MSVC)
if (BUILD_SHARED_LIBS)
target_compile_definitions(lvgl PUBLIC LV_ATTRIBUTE_EXTERN_DATA=__declspec\(dllimport\))
else()
target_compile_definitions(lvgl PUBLIC LV_ATTRIBUTE_EXTERN_DATA=__declspec\(dllexport\))
endif()
endif()

View File

@@ -11,11 +11,10 @@
#ifdef _MSC_VER #ifdef _MSC_VER
#include <io.h> #include <io.h>
#else #elif __linux__
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "lv_demos.h" #include "lv_demos.h"
/********************* /*********************

View File

@@ -317,6 +317,9 @@
*should also appear on LVGL binding API such as Micropython.*/ *should also appear on LVGL binding API such as Micropython.*/
#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ #define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/
/*Prefix all global extern data with this*/
#define LV_ATTRIBUTE_EXTERN_DATA
/* Use `float` as `lv_value_precise_t` */ /* Use `float` as `lv_value_precise_t` */
#define LV_USE_FLOAT 0 #define LV_USE_FLOAT 0

View File

@@ -196,7 +196,7 @@ enum {
/** /**
* Make the base object's class publicly available. * Make the base object's class publicly available.
*/ */
extern const lv_obj_class_t lv_obj_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_obj_class;
/** /**
* Special, rarely used attributes. * Special, rarely used attributes.

View File

@@ -877,6 +877,15 @@
#endif #endif
#endif #endif
/*Prefix all global extern data with this*/
#ifndef LV_ATTRIBUTE_EXTERN_DATA
#ifdef CONFIG_LV_ATTRIBUTE_EXTERN_DATA
#define LV_ATTRIBUTE_EXTERN_DATA CONFIG_LV_ATTRIBUTE_EXTERN_DATA
#else
#define LV_ATTRIBUTE_EXTERN_DATA
#endif
#endif
/* Use `float` as `lv_value_precise_t` */ /* Use `float` as `lv_value_precise_t` */
#ifndef LV_USE_FLOAT #ifndef LV_USE_FLOAT
#ifdef CONFIG_LV_USE_FLOAT #ifdef CONFIG_LV_USE_FLOAT

View File

@@ -30,7 +30,7 @@ extern "C" {
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
extern const lv_obj_class_t lv_animimg_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_animimg_class;
/*Data of image*/ /*Data of image*/
typedef struct { typedef struct {

View File

@@ -59,7 +59,7 @@ typedef struct {
int16_t knob_offset; /*knob offset from the main arc*/ int16_t knob_offset; /*knob offset from the main arc*/
} lv_arc_t; } lv_arc_t;
extern const lv_obj_class_t lv_arc_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_arc_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -61,7 +61,7 @@ typedef struct {
lv_bar_mode_t mode : 2; /**< Type of bar*/ lv_bar_mode_t mode : 2; /**< Type of bar*/
} lv_bar_t; } lv_bar_t;
extern const lv_obj_class_t lv_bar_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_bar_class;
/********************** /**********************

View File

@@ -30,7 +30,7 @@ typedef struct {
lv_obj_t obj; lv_obj_t obj;
} lv_button_t; } lv_button_t;
extern const lv_obj_class_t lv_button_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_button_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -69,7 +69,7 @@ typedef struct {
uint32_t one_check : 1; /*Single button toggled at once*/ uint32_t one_check : 1; /*Single button toggled at once*/
} lv_buttonmatrix_t; } lv_buttonmatrix_t;
extern const lv_obj_class_t lv_buttonmatrix_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_buttonmatrix_class;
/********************** /**********************

View File

@@ -47,7 +47,7 @@ typedef struct {
char nums [7 * 6][4]; char nums [7 * 6][4];
} lv_calendar_t; } lv_calendar_t;
extern const lv_obj_class_t lv_calendar_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_calendar_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -23,7 +23,7 @@ extern "C" {
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
extern const lv_obj_class_t lv_calendar_header_arrow_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_calendar_header_arrow_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -23,7 +23,7 @@ extern "C" {
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
extern const lv_obj_class_t lv_calendar_header_dropdown_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_calendar_header_dropdown_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -27,7 +27,7 @@ extern "C" {
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
extern const lv_obj_class_t lv_canvas_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_canvas_class;
/*Data of canvas*/ /*Data of canvas*/
typedef struct { typedef struct {

View File

@@ -120,7 +120,7 @@ typedef struct {
lv_chart_update_mode_t update_mode : 1; lv_chart_update_mode_t update_mode : 1;
} lv_chart_t; } lv_chart_t;
extern const lv_obj_class_t lv_chart_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_chart_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -32,7 +32,7 @@ typedef struct {
uint32_t static_txt : 1; uint32_t static_txt : 1;
} lv_checkbox_t; } lv_checkbox_t;
extern const lv_obj_class_t lv_checkbox_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_checkbox_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -53,7 +53,7 @@ typedef struct {
uint8_t obj_size_mode: 2; /*Image size mode when image size and object size is different.*/ uint8_t obj_size_mode: 2; /*Image size mode when image size and object size is different.*/
} lv_image_t; } lv_image_t;
extern const lv_obj_class_t lv_image_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_image_class;
/** /**
* Image size mode, when image size and object size is different * Image size mode, when image size and object size is different

View File

@@ -46,7 +46,7 @@ typedef struct {
lv_imgbtn_src_info_t src_right[_LV_IMGBTN_STATE_NUM]; /*Store right side images to each state*/ lv_imgbtn_src_info_t src_right[_LV_IMGBTN_STATE_NUM]; /*Store right side images to each state*/
} lv_imgbtn_t; } lv_imgbtn_t;
extern const lv_obj_class_t lv_imgbtn_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_imgbtn_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -65,7 +65,7 @@ typedef struct {
uint8_t popovers : 1; /*Show button titles in popovers on press*/ uint8_t popovers : 1; /*Show button titles in popovers on press*/
} lv_keyboard_t; } lv_keyboard_t;
extern const lv_obj_class_t lv_keyboard_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_keyboard_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -89,7 +89,7 @@ typedef struct {
uint8_t invalid_size_cache : 1; /*1: Recalculate size and update cache*/ uint8_t invalid_size_cache : 1; /*1: Recalculate size and update cache*/
} lv_label_t; } lv_label_t;
extern const lv_obj_class_t lv_label_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_label_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -41,7 +41,7 @@ typedef struct {
uint8_t bright; /**< Current brightness of the LED (0..255)*/ uint8_t bright; /**< Current brightness of the LED (0..255)*/
} lv_led_t; } lv_led_t;
extern const lv_obj_class_t lv_led_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_led_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -32,7 +32,7 @@ typedef struct {
uint32_t y_inv : 1; /**< 1: y == 0 will be on the bottom*/ uint32_t y_inv : 1; /**< 1: y == 0 will be on the bottom*/
} lv_line_t; } lv_line_t;
extern const lv_obj_class_t lv_line_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_line_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -25,9 +25,9 @@ extern "C" {
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
extern const lv_obj_class_t lv_list_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_list_class;
extern const lv_obj_class_t lv_list_text_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_list_text_class;
extern const lv_obj_class_t lv_list_button_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_list_button_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
**********************/ **********************/

View File

@@ -93,15 +93,15 @@ typedef struct {
bool static_title; bool static_title;
} lv_menu_page_t; } lv_menu_page_t;
extern const lv_obj_class_t lv_menu_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_menu_class;
extern const lv_obj_class_t lv_menu_page_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_menu_page_class;
extern const lv_obj_class_t lv_menu_cont_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_menu_cont_class;
extern const lv_obj_class_t lv_menu_section_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_menu_section_class;
extern const lv_obj_class_t lv_menu_separator_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_menu_separator_class;
extern const lv_obj_class_t lv_menu_sidebar_cont_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_menu_sidebar_cont_class;
extern const lv_obj_class_t lv_menu_main_cont_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_menu_main_cont_class;
extern const lv_obj_class_t lv_menu_sidebar_header_cont_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_menu_sidebar_header_cont_class;
extern const lv_obj_class_t lv_menu_main_header_cont_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_menu_main_header_cont_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
**********************/ **********************/

View File

@@ -43,9 +43,9 @@ typedef struct {
lv_obj_t * buttons; lv_obj_t * buttons;
} lv_msgbox_t; } lv_msgbox_t;
extern const lv_obj_class_t lv_msgbox_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_msgbox_class;
extern const lv_obj_class_t lv_msgbox_content_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_msgbox_content_class;
extern const lv_obj_class_t lv_msgbox_backdrop_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_msgbox_backdrop_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -39,7 +39,7 @@ typedef struct {
/*New data for this type*/ /*New data for this type*/
} lv_templ_t; } lv_templ_t;
extern const lv_obj_class_t lv_templ_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_templ_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -55,7 +55,7 @@ typedef struct {
uint32_t moved : 1; uint32_t moved : 1;
} lv_roller_t; } lv_roller_t;
extern const lv_obj_class_t lv_roller_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_roller_class;
/********************** /**********************

View File

@@ -90,7 +90,7 @@ typedef struct {
int32_t rotation; int32_t rotation;
} lv_scale_t; } lv_scale_t;
extern const lv_obj_class_t lv_scale_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_scale_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -53,7 +53,7 @@ typedef struct {
uint8_t left_knob_focus : 1; /*1: with encoder now the right knob can be adjusted*/ uint8_t left_knob_focus : 1; /*1: with encoder now the right knob can be adjusted*/
} lv_slider_t; } lv_slider_t;
extern const lv_obj_class_t lv_slider_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_slider_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -73,7 +73,7 @@ typedef struct {
uint32_t refresh : 1; /* the spangroup need refresh cache_w and cache_h */ uint32_t refresh : 1; /* the spangroup need refresh cache_w and cache_h */
} lv_spangroup_t; } lv_spangroup_t;
extern const lv_obj_class_t lv_spangroup_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_spangroup_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -45,7 +45,7 @@ typedef struct {
uint32_t digit_step_dir : 2; /* the direction the digit will step on encoder button press when editing*/ uint32_t digit_step_dir : 2; /* the direction the digit will step on encoder button press when editing*/
} lv_spinbox_t; } lv_spinbox_t;
extern const lv_obj_class_t lv_spinbox_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_spinbox_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -29,7 +29,7 @@ extern "C" {
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
extern const lv_obj_class_t lv_spinner_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_spinner_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -35,7 +35,7 @@ typedef struct {
int32_t anim_state; int32_t anim_state;
} lv_switch_t; } lv_switch_t;
extern const lv_obj_class_t lv_switch_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_switch_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -61,7 +61,7 @@ typedef struct {
uint32_t row_act; uint32_t row_act;
} lv_table_t; } lv_table_t;
extern const lv_obj_class_t lv_table_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_table_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -33,7 +33,7 @@ typedef struct {
lv_dir_t tab_pos; lv_dir_t tab_pos;
} lv_tabview_t; } lv_tabview_t;
extern const lv_obj_class_t lv_tabview_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_tabview_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -63,7 +63,7 @@ typedef struct {
uint8_t one_line : 1; /*One line mode (ignore line breaks)*/ uint8_t one_line : 1; /*One line mode (ignore line breaks)*/
} lv_textarea_t; } lv_textarea_t;
extern const lv_obj_class_t lv_textarea_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_textarea_class;
enum { enum {
LV_PART_TEXTAREA_PLACEHOLDER = LV_PART_CUSTOM_FIRST, LV_PART_TEXTAREA_PLACEHOLDER = LV_PART_CUSTOM_FIRST,

View File

@@ -34,8 +34,8 @@ typedef struct {
lv_dir_t dir; lv_dir_t dir;
} lv_tileview_tile_t; } lv_tileview_tile_t;
extern const lv_obj_class_t lv_tileview_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_tileview_class;
extern const lv_obj_class_t lv_tileview_tile_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_tileview_tile_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES

View File

@@ -26,7 +26,7 @@ typedef struct {
lv_obj_t obj; lv_obj_t obj;
} lv_win_t; } lv_win_t;
extern const lv_obj_class_t lv_win_class; LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_win_class;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES