From 2524207d1cbd039ed7c5f5e0e2337f0b283749dc Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 23 Jun 2022 03:31:05 +0300 Subject: [PATCH] tools: support c2v.exe in `v translate`, use os.quoted_path, cleanup errors. --- cmd/tools/translate.v | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/tools/translate.v b/cmd/tools/translate.v index 2c87d69997..652ed2e484 100644 --- a/cmd/tools/translate.v +++ b/cmd/tools/translate.v @@ -5,10 +5,15 @@ module main import os import v.util +const vexe = os.getenv('VEXE') + fn main() { vmodules := os.vmodules_dir() c2v_dir := os.join_path(vmodules, 'c2v') - c2v_bin := os.join_path(c2v_dir, 'c2v') + mut c2v_bin := os.join_path(c2v_dir, 'c2v') + $if windows { + c2v_bin += '.exe' + } // Git clone c2v if !os.exists(c2v_dir) { println('C2V is not installed. Cloning C2V to $c2v_dir ...') @@ -23,15 +28,15 @@ fn main() { if !os.exists(c2v_bin) { os.chdir(c2v_dir)? println('Compiling c2v ...') - res2 := os.execute('v -keepc -g -experimental -o c2v .') + res2 := os.execute('${os.quoted_path(vexe)} -o ${os.quoted_path(c2v_bin)} -keepc -g -experimental .') if res2.exit_code != 0 { eprintln(res2.output) - eprintln('Failed to compile C2V. This should never happen, please report it via GitHub.') + eprintln('Failed to compile C2V. This should not happen. Please report it via GitHub.') exit(2) } } if os.args.len < 3 { - eprintln('Wrong number of args. Use `v translate file.c`.') + eprintln('Wrong number of arguments. Use `v translate file.c` .') exit(3) } passed_args := util.args_quote_paths(os.args[2..])