mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
tools: print an error message, when make
is needed, but is missing on unix
This commit is contained in:
parent
8394b358d8
commit
f5c4864db8
1 changed files with 25 additions and 4 deletions
|
@ -13,6 +13,9 @@ struct App {
|
||||||
is_prod bool
|
is_prod bool
|
||||||
vexe string
|
vexe string
|
||||||
vroot string
|
vroot string
|
||||||
|
//
|
||||||
|
skip_v_self bool // do not run `v self`, effectively enforcing the running of `make` or `make.bat`
|
||||||
|
skip_current bool // skip the current hash check, enabling easier testing on the same commit, without using docker etc
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_app() App {
|
fn new_app() App {
|
||||||
|
@ -21,6 +24,8 @@ fn new_app() App {
|
||||||
is_prod: '-prod' in os.args
|
is_prod: '-prod' in os.args
|
||||||
vexe: vexe
|
vexe: vexe
|
||||||
vroot: vroot
|
vroot: vroot
|
||||||
|
skip_v_self: '-skip_v_self' in os.args
|
||||||
|
skip_current: '-skip_current' in os.args
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +39,7 @@ fn main() {
|
||||||
current_hash := version.githash(true)
|
current_hash := version.githash(true)
|
||||||
// println(v_hash)
|
// println(v_hash)
|
||||||
// println(current_hash)
|
// println(current_hash)
|
||||||
if v_hash == current_hash {
|
if v_hash == current_hash && !app.skip_current {
|
||||||
println('V is already updated.')
|
println('V is already updated.')
|
||||||
app.show_current_v_version()
|
app.show_current_v_version()
|
||||||
return
|
return
|
||||||
|
@ -77,6 +82,9 @@ fn (app App) recompile_v() bool {
|
||||||
// Note: app.vexe is more reliable than just v (which may be a symlink)
|
// Note: app.vexe is more reliable than just v (which may be a symlink)
|
||||||
opts := if app.is_prod { '-prod' } else { '' }
|
opts := if app.is_prod { '-prod' } else { '' }
|
||||||
vself := '${os.quoted_path(app.vexe)} ${opts} self'
|
vself := '${os.quoted_path(app.vexe)} ${opts} self'
|
||||||
|
if app.skip_v_self {
|
||||||
|
return app.make(vself)
|
||||||
|
}
|
||||||
app.vprintln('> recompiling v itself with `${vself}` ...')
|
app.vprintln('> recompiling v itself with `${vself}` ...')
|
||||||
self_result := os.execute(vself)
|
self_result := os.execute(vself)
|
||||||
if self_result.exit_code == 0 {
|
if self_result.exit_code == 0 {
|
||||||
|
@ -170,9 +178,22 @@ fn (app App) get_git() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_make_cmd_name() string {
|
fn get_make_cmd_name() string {
|
||||||
|
mut cmd := 'make'
|
||||||
$if windows {
|
$if windows {
|
||||||
return 'make.bat'
|
cmd = 'make.bat'
|
||||||
} $else {
|
|
||||||
return 'make'
|
|
||||||
}
|
}
|
||||||
|
if cmd == 'make' {
|
||||||
|
make_sure_cmd_is_available(cmd)
|
||||||
|
cc := os.getenv_opt('CC') or { 'cc' }
|
||||||
|
make_sure_cmd_is_available(cc)
|
||||||
|
}
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
fn make_sure_cmd_is_available(cmd string) {
|
||||||
|
found_path := os.find_abs_path_of_executable(cmd) or {
|
||||||
|
eprintln('Could not find `${cmd}` in PATH. Please install `${cmd}`, since `v up` needs it.')
|
||||||
|
exit(1)
|
||||||
|
}
|
||||||
|
println('Found `${cmd}` as `${found_path}`.')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue