From ffc73bf6435d961d2f4bf628b9edf3f7cd3b18dd Mon Sep 17 00:00:00 2001 From: yuyi Date: Mon, 5 Dec 2022 14:48:45 +0800 Subject: [PATCH] builder: fix v builder error (#16590) --- vlib/v/builder/cc.v | 14 ++++++++++++++ vlib/v/builder/cc_windows.v | 11 ----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 839004ff6c..b9ccee2298 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -981,3 +981,17 @@ fn error_context_lines(text string, keyword string, before int, after int) []str idx_e := if idx_s + after < lines.len { idx_s + after } else { lines.len } return lines[idx_s..idx_e] } + +pub fn (mut v Builder) quote_compiler_name(name string) string { + $if windows { + // some compiler frontends on windows, like emcc, are a .bat file on windows. + // Quoting the .bat file name here leads to problems with them, when they internally call python scripts for some reason. + // Just emcc without quotes here does work, but: + // |"emcc" -v| produces: python.exe: can't open file 'D:\programs\v\emcc.py': [Errno 2] No such file or directory + if name.contains('/') || name.contains('\\') { + return os.quoted_path(name) + } + return name + } + return os.quoted_path(name) +} diff --git a/vlib/v/builder/cc_windows.v b/vlib/v/builder/cc_windows.v index 5d37d5bb82..08c65bd5e8 100644 --- a/vlib/v/builder/cc_windows.v +++ b/vlib/v/builder/cc_windows.v @@ -6,17 +6,6 @@ module builder import os import v.pref -pub fn (mut v Builder) quote_compiler_name(name string) string { - // some compiler frontends on windows, like emcc, are a .bat file on windows. - // Quoting the .bat file name here leads to problems with them, when they internally call python scripts for some reason. - // Just emcc without quotes here does work, but: - // |"emcc" -v| produces: python.exe: can't open file 'D:\programs\v\emcc.py': [Errno 2] No such file or directory - if name.contains('/') || name.contains('\\') { - return os.quoted_path(name) - } - return name -} - pub fn (mut v Builder) find_win_cc() ! { $if !windows { return