mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tools: support c2v.exe in v translate
, use os.quoted_path, cleanup errors.
This commit is contained in:
parent
78c527b243
commit
2524207d1c
@ -5,10 +5,15 @@ module main
|
|||||||
import os
|
import os
|
||||||
import v.util
|
import v.util
|
||||||
|
|
||||||
|
const vexe = os.getenv('VEXE')
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
vmodules := os.vmodules_dir()
|
vmodules := os.vmodules_dir()
|
||||||
c2v_dir := os.join_path(vmodules, 'c2v')
|
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
|
// Git clone c2v
|
||||||
if !os.exists(c2v_dir) {
|
if !os.exists(c2v_dir) {
|
||||||
println('C2V is not installed. Cloning C2V to $c2v_dir ...')
|
println('C2V is not installed. Cloning C2V to $c2v_dir ...')
|
||||||
@ -23,15 +28,15 @@ fn main() {
|
|||||||
if !os.exists(c2v_bin) {
|
if !os.exists(c2v_bin) {
|
||||||
os.chdir(c2v_dir)?
|
os.chdir(c2v_dir)?
|
||||||
println('Compiling c2v ...')
|
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 {
|
if res2.exit_code != 0 {
|
||||||
eprintln(res2.output)
|
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)
|
exit(2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if os.args.len < 3 {
|
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)
|
exit(3)
|
||||||
}
|
}
|
||||||
passed_args := util.args_quote_paths(os.args[2..])
|
passed_args := util.args_quote_paths(os.args[2..])
|
||||||
|
Loading…
Reference in New Issue
Block a user