build: Add support building with msvc#59
Conversation
…riable] [build] /mnt/c/work/lvgl/lv_binding_js/deps/txiki/deps/libwebsockets/lib/system/async-dns/async-dns.c:801:27: error: variable ‘c’ set but not used [-Werror=unused-but-set-variable] [build] 801 | lws_adns_cache_t *c; [build] | ^ [build] cc1: all warnings being treated as errors
MSVC do not support for zero length array: Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
There was a problem hiding this comment.
5 issues found across 45 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/render/native/components/roller/roller_wrap.cpp">
<violation number="1" location="src/render/native/components/roller/roller_wrap.cpp:16">
P1: `argc >= 1` is too weak: `argv[1]` and `argv[2]` are accessed in the same condition, causing out-of-bounds reads when fewer than 3 arguments are passed.</violation>
</file>
<file name="src/render/native/components/line/line_wrap.cpp">
<violation number="1" location="src/render/native/components/line/line_wrap.cpp:17">
P2: Out-of-bounds argv access: checks `argc >= 1` but reads `argv[1]`, should be `argc >= 2`</violation>
</file>
<file name="src/render/native/components/calendar/calendar_wrap.cpp">
<violation number="1" location="src/render/native/components/calendar/calendar_wrap.cpp:16">
P2: Out-of-bounds read: `argc >= 1` insufficiently guards `argv[1]` access (should be `argc >= 2`)</violation>
</file>
<file name="src/render/native/components/dropdownlist/dropdownlist_wrap.cpp">
<violation number="1" location="src/render/native/components/dropdownlist/dropdownlist_wrap.cpp:16">
P1: Out-of-bounds argv access: condition checks `argc >= 1` but then reads `argv[1]` which requires at least 2 arguments. If `setItems` is called with only one argument, `JS_IsNumber(argv[1])` causes an out-of-bounds read and `JS_ToInt32(ctx, &item_len, argv[1])` reads garbage. The guard should be `argc >= 2`.</violation>
</file>
<file name="src/engine/hal/simulator/simulator.cpp">
<violation number="1" location="src/engine/hal/simulator/simulator.cpp:3">
P1: Wrapping `LV_IMG_DECLARE(mouse_cursor_icon)` in `extern "C"` creates a C-linkage reference, but `mouse_cursor_icon.c` is compiled with the C++ compiler in this build, so the definition will not match and linking can fail.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| static JSValue NativeCompSetOptions(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { | ||
| if (argc >= 1 && JS_IsArray(ctx, argv[0]) && JS_IsNumber(argv[1]) && JS_IsBool(argv[2])) { | ||
| if (argc >= 1 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1]) && JS_IsBool(argv[2])) { |
There was a problem hiding this comment.
P1: argc >= 1 is too weak: argv[1] and argv[2] are accessed in the same condition, causing out-of-bounds reads when fewer than 3 arguments are passed.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/render/native/components/roller/roller_wrap.cpp, line 16:
<comment>`argc >= 1` is too weak: `argv[1]` and `argv[2]` are accessed in the same condition, causing out-of-bounds reads when fewer than 3 arguments are passed.</comment>
<file context>
@@ -13,7 +13,7 @@ WRAPPED_SCROLL_INTO_VIEW(Roller, "Roller")
static JSValue NativeCompSetOptions(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) {
- if (argc >= 1 && JS_IsArray(ctx, argv[0]) && JS_IsNumber(argv[1]) && JS_IsBool(argv[2])) {
+ if (argc >= 1 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1]) && JS_IsBool(argv[2])) {
COMP_REF* ref = (COMP_REF*)JS_GetOpaque(this_val, RollerClassID);
std::vector<std::string> items;
</file context>
| if (argc >= 1 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1]) && JS_IsBool(argv[2])) { | |
| if (argc >= 3 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1]) && JS_IsBool(argv[2])) { |
|
|
||
| static JSValue NativeCompSetItems(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { | ||
| if (argc >= 1 && JS_IsArray(ctx, argv[0]) && JS_IsNumber(argv[1])) { | ||
| if (argc >= 1 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1])) { |
There was a problem hiding this comment.
P1: Out-of-bounds argv access: condition checks argc >= 1 but then reads argv[1] which requires at least 2 arguments. If setItems is called with only one argument, JS_IsNumber(argv[1]) causes an out-of-bounds read and JS_ToInt32(ctx, &item_len, argv[1]) reads garbage. The guard should be argc >= 2.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/render/native/components/dropdownlist/dropdownlist_wrap.cpp, line 16:
<comment>Out-of-bounds argv access: condition checks `argc >= 1` but then reads `argv[1]` which requires at least 2 arguments. If `setItems` is called with only one argument, `JS_IsNumber(argv[1])` causes an out-of-bounds read and `JS_ToInt32(ctx, &item_len, argv[1])` reads garbage. The guard should be `argc >= 2`.</comment>
<file context>
@@ -13,7 +13,7 @@ WRAPPED_SCROLL_INTO_VIEW(Dropdownlist, "Dropdownlist")
static JSValue NativeCompSetItems(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) {
- if (argc >= 1 && JS_IsArray(ctx, argv[0]) && JS_IsNumber(argv[1])) {
+ if (argc >= 1 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1])) {
COMP_REF* ref = (COMP_REF*)JS_GetOpaque(this_val, DropdownlistClassID);
std::vector<std::string> items;
</file context>
| if (argc >= 1 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1])) { | |
| if (argc >= 2 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1])) { |
| extern "C" { | ||
|
|
||
| LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/ | ||
|
|
||
| } |
There was a problem hiding this comment.
P1: Wrapping LV_IMG_DECLARE(mouse_cursor_icon) in extern "C" creates a C-linkage reference, but mouse_cursor_icon.c is compiled with the C++ compiler in this build, so the definition will not match and linking can fail.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/engine/hal/simulator/simulator.cpp, line 3:
<comment>Wrapping `LV_IMG_DECLARE(mouse_cursor_icon)` in `extern "C"` creates a C-linkage reference, but `mouse_cursor_icon.c` is compiled with the C++ compiler in this build, so the definition will not match and linking can fail.</comment>
<file context>
@@ -1,5 +1,11 @@
#include "./simulator.hpp"
+extern "C" {
+
+LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/
</file context>
| extern "C" { | |
| LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/ | |
| } | |
| LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/ |
There was a problem hiding this comment.
You were wrong about mouse_cursor_icon.c, the compiler for mouse_cursor_icon.c is default to c, that's why I use
extern "C"
|
|
||
| static JSValue NativeCompSetPoints(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { | ||
| if (argc >= 1 && JS_IsArray(ctx, argv[0]) && JS_IsNumber(argv[1])) { | ||
| if (argc >= 1 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1])) { |
There was a problem hiding this comment.
P2: Out-of-bounds argv access: checks argc >= 1 but reads argv[1], should be argc >= 2
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/render/native/components/line/line_wrap.cpp, line 17:
<comment>Out-of-bounds argv access: checks `argc >= 1` but reads `argv[1]`, should be `argc >= 2`</comment>
<file context>
@@ -14,7 +14,7 @@ WRAPPED_SCROLL_INTO_VIEW(Line, "Line")
static JSValue NativeCompSetPoints(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) {
- if (argc >= 1 && JS_IsArray(ctx, argv[0]) && JS_IsNumber(argv[1])) {
+ if (argc >= 1 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1])) {
COMP_REF* ref = (COMP_REF*)JS_GetOpaque(this_val, LineClassID);
</file context>
| if (argc >= 1 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1])) { | |
| if (argc >= 2 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1])) { |
|
|
||
| static JSValue NativeCompSetHightLights(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { | ||
| if (argc >= 1 && JS_IsArray(ctx, argv[0]) && JS_IsNumber(argv[1])) { | ||
| if (argc >= 1 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1])) { |
There was a problem hiding this comment.
P2: Out-of-bounds read: argc >= 1 insufficiently guards argv[1] access (should be argc >= 2)
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/render/native/components/calendar/calendar_wrap.cpp, line 16:
<comment>Out-of-bounds read: `argc >= 1` insufficiently guards `argv[1]` access (should be `argc >= 2`)</comment>
<file context>
@@ -13,7 +13,7 @@ WRAPPED_SCROLL_INTO_VIEW(Calendar, "Calendar")
static JSValue NativeCompSetHightLights(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) {
- if (argc >= 1 && JS_IsArray(ctx, argv[0]) && JS_IsNumber(argv[1])) {
+ if (argc >= 1 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1])) {
COMP_REF* ref = (COMP_REF*)JS_GetOpaque(this_val, CalendarClassID);
</file context>
| if (argc >= 1 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1])) { | |
| if (argc >= 2 && JS_IsArray(argv[0]) && JS_IsNumber(argv[1])) { |
There was a problem hiding this comment.
@cubic-dev-ai Please check the agrc check in whole code-base, I am not touching about argc changes, that's should belongs to separate MR, can you automatically create that MR for me?
There was a problem hiding this comment.
@lygstate Fix with cubic is available during trial and on the Pro plan. Upgrade your plan to use this feature. https://www.cubic.dev/settings?tab=subscription
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
vcpkg install:
Summary by cubic
Add MSVC build support for Windows (simulator +
vcpkg), updatetxikito v26.4.0, and fix a style init bug. Also improves QuickJS and Windows compatibility for smoother cross-platform builds.New Features
WIN32_LEAN_AND_MEAN; newBUILD_LVGL_SIMULATOR=ONflag with Makefile update; non‑MSVC simulator builds relax-Werrorfor unused-but-set variables.src/render/native/lv_bindings_js.h; align QuickJS API usage (e.g.,JS_IsArraywithout ctx, boolean literals, event handlers returnJS_UNDEFINED); renameArcto avoid a Windows name clash; remove zero-lengthComponentClassFuncsarrays.txikito v26.4.0 and apply compile fixes.Migration
vcpkg:.\vcpkg.exe install curl zlib libffi sdl2 libffi:x64-windows-static-DBUILD_LVGL_SIMULATOR=ON -DUSE_EXTERNAL_FFI=ON -DCMAKE_PREFIX_PATH=C:/work/vcpkg/packages/zlib_x64-windows;C:/work/vcpkg/packages/curl_x64-windows;C:/work/vcpkg/packages/libffi_x64-windows;C:/work/vcpkg/packages/sdl2_x64-windows -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>Written for commit 632869f. Summary will update on new commits. Review in cubic
Closes: #57