From 7b1ade237b0e96e7d33ec7749113b540c6ea5ad9 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 19 Jun 2022 16:19:56 +0300 Subject: [PATCH] tools: fix the first run of `v translate hw.c` --- cmd/tools/translate.v | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/tools/translate.v b/cmd/tools/translate.v index 177571659b..91f8a42370 100644 --- a/cmd/tools/translate.v +++ b/cmd/tools/translate.v @@ -11,33 +11,35 @@ fn main() { c2v_bin := os.join_path(c2v_dir, 'c2v') // Git clone c2v if !os.exists(c2v_dir) { - println('C2V is not installed. Downloading C2V...') - println(vmodules) + println('C2V is not installed. Cloning C2V to $c2v_dir ...') os.chdir(vmodules)? res := os.execute('git clone --depth 1 git@github.com:/vlang/c2v_alpha.git') if res.exit_code != 0 { eprintln('Failed to download C2V. Perhaps it is not released yet? Is it June 20 yet?') - return + exit(1) } } // Compile c2v if !os.exists(c2v_bin) { os.chdir(c2v_dir)? + println('Compiling c2v ...') res2 := os.execute('v -d trace_verbose -g -o c2v -experimental -w .') if res2.exit_code != 0 { eprintln('Failed to compile C2V. This should never happen, please report it via GitHub.') - return + exit(2) } } if os.args.len < 3 { eprintln('Wrong number of args. Use `v translate file.c`.') - return + exit(3) } passed_args := util.args_quote_paths(os.args[2..]) // println(passed_args) + os.chdir(os.wd_at_startup)? res := os.execute('$c2v_bin $passed_args') if res.exit_code != 0 { eprintln('C2V failed to translate this file. This should never happen, please report it via GitHub.') + exit(4) } println('Success!') // println(res.output)