Skip to content

Commit da7e85c

Browse files
committed
all: msvc fixes
1 parent 9a8464f commit da7e85c

20 files changed

Lines changed: 93 additions & 74 deletions

vlib/db/pg_sqlite_consistency_test.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// vtest build: !windows
12
module main
23

34
import db.pg

vlib/db/sqlite/sqlite.c.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $if $pkgconfig('sqlite3') {
1212
#include "sqlite3.h" # The SQLite header file is missing. Please install the corresponding development package.
1313
} $else $if windows {
1414
#flag -I@VEXEROOT/thirdparty/sqlite
15-
#flag @VEXEROOT/thirdparty/sqlite/sqlite3.c
15+
#flag @VEXEROOT/thirdparty/sqlite/sqlite3.o
1616
#include "sqlite3.h" # The SQLite header file is missing. Please run vlib/db/sqlite/install_thirdparty_sqlite.vsh to download an SQLite amalgamation.
1717
} $else $if darwin {
1818
// macOS ships libsqlite3, so do not require a separately downloaded amalgamation.

vlib/encoding/cbor/generic.v

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ module cbor
33
import math
44
import time
55

6+
const i32_min_i64 = -i64(2_147_483_647) - 1
7+
const i32_max_i64 = i64(2_147_483_647)
8+
const u32_max_i64 = i64(4_294_967_295)
9+
610
// Generic comptime-driven encoder/decoder. The pack[T] / unpack[T]
711
// methods below dispatch on T at compile time, so each call site
812
// monomorphises into straight-line code with no runtime type tests.
@@ -254,13 +258,13 @@ pub fn (mut u Unpacker) unpack[T]() !T {
254258
return i16(v)
255259
} $else $if T is int {
256260
v := u.unpack_int()!
257-
if v < -2_147_483_648 || v > 2_147_483_647 {
261+
if v < i32_min_i64 || v > i32_max_i64 {
258262
return int_range(u.pos, 'int', v.str())
259263
}
260264
return int(v)
261265
} $else $if T is i32 {
262266
v := u.unpack_int()!
263-
if v < -2_147_483_648 || v > 2_147_483_647 {
267+
if v < i32_min_i64 || v > i32_max_i64 {
264268
return int_range(u.pos, 'i32', v.str())
265269
}
266270
return i32(v)
@@ -280,7 +284,7 @@ pub fn (mut u Unpacker) unpack[T]() !T {
280284
return u16(v)
281285
} $else $if T is u32 {
282286
v := u.unpack_int()!
283-
if v < 0 || v > 4_294_967_295 {
287+
if v < 0 || v > u32_max_i64 {
284288
return int_range(u.pos, 'u32', v.str())
285289
}
286290
return u32(v)

vlib/gg/text_rendering_test.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// vtest build: !msvc
12
module gg
23

34
import fontstash
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
module runtime
22

3+
#include <psapi.h>
4+
35
// Windows 7+ exports K32GetProcessMemoryInfo from kernel32.dll, so avoid
4-
// depending on psapi.h/psapi.lib during bootstrap builds.
6+
// depending on psapi.lib during bootstrap builds.
57
@[typedef]
6-
struct C.V_PROCESS_MEMORY_COUNTERS {
7-
cb u32
8-
page_fault_count u32
9-
peak_working_set_size usize
10-
working_set_size usize
11-
quota_peak_paged_pool_usage usize
12-
quota_paged_pool_usage usize
13-
quota_peak_non_paged_pool_usage usize
14-
quota_non_paged_pool_usage usize
15-
pagefile_usage usize
16-
peak_pagefile_usage usize
8+
struct C.PROCESS_MEMORY_COUNTERS {
9+
cb u32
10+
PageFaultCount u32
11+
PeakWorkingSetSize usize
12+
WorkingSetSize usize
13+
QuotaPeakPagedPoolUsage usize
14+
QuotaPagedPoolUsage usize
15+
QuotaPeakNonPagedPoolUsage usize
16+
QuotaNonPagedPoolUsage usize
17+
PagefileUsage usize
18+
PeakPagefileUsage usize
1719
}
1820

19-
fn C.K32GetProcessMemoryInfo(voidptr, &C.V_PROCESS_MEMORY_COUNTERS, u32) bool
21+
fn C.K32GetProcessMemoryInfo(voidptr, &C.PROCESS_MEMORY_COUNTERS, u32) bool
2022

2123
// used_memory retrieves the current physical memory usage of the process.
2224
pub fn used_memory() !u64 {
23-
mut pmc := C.V_PROCESS_MEMORY_COUNTERS{}
25+
mut pmc := C.PROCESS_MEMORY_COUNTERS{}
2426
pmc.cb = u32(sizeof(pmc))
2527
if C.K32GetProcessMemoryInfo(C.GetCurrentProcess(), &pmc, pmc.cb) {
26-
return u64(pmc.working_set_size)
28+
return u64(pmc.WorkingSetSize)
2729
}
2830
return 0
2931
}

vlib/sokol/gfx/gfx_test.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// vtest build: !msvc
12
module gfx
23

34
import os

vlib/v/builder/builder_test.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ fn test_thirdparty_object_build_with_multiline_cflags() {
258258
}
259259

260260
fn test_missing_library_is_reported_without_compiler_bug_hint() {
261+
if os.user_os() == 'windows' && os.getenv('VFLAGS').contains('msvc') {
262+
return
263+
}
261264
os.chdir(test_path)!
262265
os.mkdir_all('missing_library')!
263266
lib_name := 'v_missing_lib_25499'

vlib/v/builder/cc_test.v

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,29 +409,29 @@ fn main() {
409409
}
410410

411411
fn test_live_windows_main_linker_args_export_host_symbols() {
412-
linker_args := builder_linker_args([
412+
linker_args := builder_linker_args_with_cc([
413413
'-os',
414414
'windows',
415415
'-cc',
416416
'gcc',
417417
'-live',
418418
hot_reload_graph_example(),
419-
])
419+
], .gcc)
420420
assert linker_args.contains('-Wl,--export-all-symbols')
421421
assert linker_args.contains('-Wl,--out-implib,')
422422
assert normalized_test_path(linker_args).contains(normalized_test_path(live_windows_import_lib_path(hot_reload_graph_example())))
423423
}
424424

425425
fn test_live_windows_shared_linker_args_include_host_import_lib() {
426-
linker_args := builder_linker_args([
426+
linker_args := builder_linker_args_with_cc([
427427
'-os',
428428
'windows',
429429
'-cc',
430430
'gcc',
431431
'-sharedlive',
432432
'-shared',
433433
hot_reload_graph_example(),
434-
])
434+
], .gcc)
435435
assert normalized_test_path(linker_args).contains(normalized_test_path(live_windows_import_lib_path(hot_reload_graph_example())))
436436
}
437437

@@ -529,6 +529,12 @@ fn builder_linker_args(args []string) string {
529529
return builder.get_linker_args().join(' ')
530530
}
531531

532+
fn builder_linker_args_with_cc(args []string, cc CC) string {
533+
mut builder := new_test_builder(args)
534+
builder.ccoptions.cc = cc
535+
return builder.get_linker_args().join(' ')
536+
}
537+
532538
fn new_test_builder(args []string) Builder {
533539
mut full_args := ['']
534540
full_args << args

vlib/v/builder/msvc_windows.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ fn (mut v Builder) build_thirdparty_obj_file_with_msvc(mod string, path string,
459459
defines := flags.defines.join(' ')
460460

461461
mut oargs := []string{}
462-
env_cflags := os.getenv('CFLAGS')
462+
env_cflags := os.getenv('CFLAGS').replace('\r', ' ').replace('\n', ' ')
463463
mut all_cflags := '${env_cflags} ${v.pref.cflags}'
464464
if all_cflags != ' ' {
465465
oargs << all_cflags
@@ -485,7 +485,7 @@ fn (mut v Builder) build_thirdparty_obj_file_with_msvc(mod string, path string,
485485
oargs << inc_dirs
486486
oargs << '/c "${cfile}"'
487487
oargs << '/Fo"${obj_path}"'
488-
env_ldflags := os.getenv('LDFLAGS')
488+
env_ldflags := os.getenv('LDFLAGS').replace('\r', ' ').replace('\n', ' ')
489489
mut all_ldflags := '${env_ldflags} ${v.pref.ldflags}'
490490
if all_ldflags != '' {
491491
oargs << all_ldflags

vlib/v/builder/parallel_cc_failure_test.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// vtest build: !msvc
12
module main
23

34
import os

0 commit comments

Comments
 (0)