From daa659e1fd101f6c97c800a77291661f21841626 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 5 Dec 2020 15:35:39 +0200 Subject: [PATCH] builder: allow for `-os windows -cc msvc -o x.c` on any platform --- vlib/v/builder/c.v | 2 +- vlib/v/builder/msvc.v | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/vlib/v/builder/c.v b/vlib/v/builder/c.v index e80ab4070a..3368ad6949 100644 --- a/vlib/v/builder/c.v +++ b/vlib/v/builder/c.v @@ -46,7 +46,7 @@ pub fn (mut b Builder) build_c(v_files []string, out_file string) { } pub fn (mut b Builder) compile_c() { - if os.user_os() != 'windows' && b.pref.ccompiler == 'msvc' { + if os.user_os() != 'windows' && b.pref.ccompiler == 'msvc' && !b.pref.out_name.ends_with('.c') { verror('Cannot build with msvc on $os.user_os()') } // cgen.genln('// Generated by V') diff --git a/vlib/v/builder/msvc.v b/vlib/v/builder/msvc.v index 3c00a11bd2..e41ad03519 100644 --- a/vlib/v/builder/msvc.v +++ b/vlib/v/builder/msvc.v @@ -181,7 +181,12 @@ fn find_msvc() ?MsvcResult { valid: true } } $else { - return error('msvc not found') + // This hack allows to at least see the generated .c file with `-os windows -cc msvc -o x.c` + // Please do not remove it, unless you also check that the above continues to work. + return MsvcResult{ + full_cl_exe_path: '/usr/bin/true' + valid: true + } } }