From a24f57285fe53d359b21bbe253c38288c9d26031 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 23 Apr 2026 18:23:08 +0300 Subject: [PATCH] pref: fix build failed with msvc 2022 (fixes #14784) --- vlib/v/pref/pref_test.v | 29 +++++++++++++++++++++++++++++ vlib/v/pref/should_compile.v | 4 ++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/vlib/v/pref/pref_test.v b/vlib/v/pref/pref_test.v index 18acab9b0..50adee0f2 100644 --- a/vlib/v/pref/pref_test.v +++ b/vlib/v/pref/pref_test.v @@ -119,6 +119,35 @@ fn new_wasm_preferences() pref.Preferences { } } +fn new_c_preferences() pref.Preferences { + return pref.Preferences{ + backend: .c + os: .linux + arch: .amd64 + } +} + +fn test_c_backend_filters_backend_specific_files() { + prefs := new_c_preferences() + dir := os.join_path(os.vtmp_dir(), 'c_backend_filters') + filtered := prefs.should_compile_filtered_files(dir, [ + 'mod.c.v', + 'mod.js.v', + 'mod.v', + 'mod.wasm.v', + ]) + assert filtered == [ + os.join_path(dir, 'mod.c.v'), + os.join_path(dir, 'mod.v'), + ] +} + +fn test_c_backend_skips_modules_with_only_non_c_variants() { + prefs := new_c_preferences() + filtered := prefs.should_compile_filtered_files('sus', ['sus.js.v', 'sus.wasm.v']) + assert filtered.len == 0 +} + fn test_wasm_backend_filters_backend_specific_files() { prefs := new_wasm_preferences() dir := os.join_path(os.vtmp_dir(), 'wasm_backend_filters') diff --git a/vlib/v/pref/should_compile.v b/vlib/v/pref/should_compile.v index 530b2875d..767fd8bf2 100644 --- a/vlib/v/pref/should_compile.v +++ b/vlib/v/pref/should_compile.v @@ -246,8 +246,8 @@ fn (prefs &Preferences) bsd_specific_file_kind(file string) string { // TODO: Rework this using is_target_of() pub fn (prefs &Preferences) should_compile_c(file string) bool { - if file.ends_with('.js.v') { - // Probably something like `a.js.v`. + if file.ends_with('.js.v') || file.ends_with('.wasm.v') { + // Probably something like `a.js.v` or `a.wasm.v`. return false } if prefs.is_bare && file.ends_with('.freestanding.v') { -- 2.39.5