mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
tools: use v retry
in more places, that do network operations that can fail temporarily (#22836)
This commit is contained in:
parent
34be083e25
commit
4e82b62142
4 changed files with 12 additions and 11 deletions
|
@ -19,7 +19,7 @@ fn main() {
|
||||||
os.mkdir_all(vmodules)!
|
os.mkdir_all(vmodules)!
|
||||||
println('C2V is not installed. Cloning C2V to ${c2v_dir} ...')
|
println('C2V is not installed. Cloning C2V to ${c2v_dir} ...')
|
||||||
os.chdir(vmodules)!
|
os.chdir(vmodules)!
|
||||||
res := os.execute('git clone --filter=blob:none https://github.com/vlang/c2v')
|
res := os.execute('${os.quoted_path(vexe)} retry -- git clone --filter=blob:none https://github.com/vlang/c2v')
|
||||||
if res.exit_code != 0 {
|
if res.exit_code != 0 {
|
||||||
eprintln('Failed to download C2V.')
|
eprintln('Failed to download C2V.')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
@ -49,6 +49,8 @@ mut:
|
||||||
args []string
|
args []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const vexe = os.real_path(os.getenv_opt('VEXE') or { @VEXE })
|
||||||
|
|
||||||
const vls_folder = os.join_path(os.home_dir(), '.vls')
|
const vls_folder = os.join_path(os.home_dir(), '.vls')
|
||||||
|
|
||||||
const vls_bin_folder = os.join_path(vls_folder, 'bin')
|
const vls_bin_folder = os.join_path(vls_folder, 'bin')
|
||||||
|
@ -255,13 +257,13 @@ fn (upd VlsUpdater) compile_from_source() ! {
|
||||||
|
|
||||||
if !os.exists(vls_src_folder) {
|
if !os.exists(vls_src_folder) {
|
||||||
upd.log('Cloning VLS repo...')
|
upd.log('Cloning VLS repo...')
|
||||||
clone_result := os.execute('${git} clone --filter=blob:none https://github.com/vlang/vls ${vls_src_folder}')
|
clone_result := os.execute('${os.quoted_path(vexe)} retry -- ${git} clone --filter=blob:none https://github.com/vlang/vls ${vls_src_folder}')
|
||||||
if clone_result.exit_code != 0 {
|
if clone_result.exit_code != 0 {
|
||||||
return error('Failed to build VLS from source. Reason: ${clone_result.output}')
|
return error('Failed to build VLS from source. Reason: ${clone_result.output}')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
upd.log('Updating VLS repo...')
|
upd.log('Updating VLS repo...')
|
||||||
pull_result := os.execute('${git} -C ${vls_src_folder} pull')
|
pull_result := os.execute('${os.quoted_path(vexe)} retry -- ${git} -C ${vls_src_folder} pull')
|
||||||
if !upd.is_force && pull_result.output.trim_space() == 'Already up to date.' {
|
if !upd.is_force && pull_result.output.trim_space() == 'Already up to date.' {
|
||||||
upd.log("VLS was already updated to it's latest version.")
|
upd.log("VLS was already updated to it's latest version.")
|
||||||
return
|
return
|
||||||
|
@ -282,7 +284,8 @@ fn (upd VlsUpdater) compile_from_source() ! {
|
||||||
return error('Cannot compile VLS from source: no appropriate C compiler found.')
|
return error('Cannot compile VLS from source: no appropriate C compiler found.')
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_result := os.execute('v run ${os.join_path(vls_src_folder, 'build.vsh')} ${possible_compilers[selected_compiler_idx]}')
|
compile_result := os.execute('${os.quoted_path(vexe)} run ${os.join_path(vls_src_folder,
|
||||||
|
'build.vsh')} ${possible_compilers[selected_compiler_idx]}')
|
||||||
if compile_result.exit_code != 0 {
|
if compile_result.exit_code != 0 {
|
||||||
return error('Cannot compile VLS from source: ${compile_result.output}')
|
return error('Cannot compile VLS from source: ${compile_result.output}')
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,13 @@ const freetype_folder = os.join_path('thirdparty', 'freetype')
|
||||||
fn main() {
|
fn main() {
|
||||||
$if windows {
|
$if windows {
|
||||||
println('Setup freetype...')
|
println('Setup freetype...')
|
||||||
vroot := os.dir(os.real_path(os.getenv_opt('VEXE') or { @VEXE }))
|
vexe := os.real_path(os.getenv_opt('VEXE') or { @VEXE })
|
||||||
|
vroot := os.dir(vexe)
|
||||||
os.chdir(vroot)!
|
os.chdir(vroot)!
|
||||||
if os.is_dir(freetype_folder) {
|
if os.is_dir(freetype_folder) {
|
||||||
println('Thirdparty "freetype" is already installed.')
|
println('Thirdparty "freetype" is already installed.')
|
||||||
} else {
|
} else {
|
||||||
s := os.execute('git clone --filter=blob:none ${freetype_repo_url} ${freetype_folder}')
|
s := os.execute('${os.quoted_path(vexe)} retry -- git clone --filter=blob:none ${freetype_repo_url} ${freetype_folder}')
|
||||||
if s.exit_code != 0 {
|
if s.exit_code != 0 {
|
||||||
panic(s.output)
|
panic(s.output)
|
||||||
}
|
}
|
||||||
|
|
|
@ -521,9 +521,9 @@ pub fn check_module_is_installed(modulename string, is_verbose bool, need_update
|
||||||
eprintln('check_module_is_installed: mod_v_file: ${mod_v_file}')
|
eprintln('check_module_is_installed: mod_v_file: ${mod_v_file}')
|
||||||
eprintln('check_module_is_installed: murl: ${murl}')
|
eprintln('check_module_is_installed: murl: ${murl}')
|
||||||
}
|
}
|
||||||
|
vexe := pref.vexe_path()
|
||||||
if os.exists(mod_v_file) {
|
if os.exists(mod_v_file) {
|
||||||
if need_update {
|
if need_update {
|
||||||
vexe := pref.vexe_path()
|
|
||||||
update_cmd := "${os.quoted_path(vexe)} update '${modulename}'"
|
update_cmd := "${os.quoted_path(vexe)} update '${modulename}'"
|
||||||
if is_verbose {
|
if is_verbose {
|
||||||
eprintln('check_module_is_installed: updating with ${update_cmd} ...')
|
eprintln('check_module_is_installed: updating with ${update_cmd} ...')
|
||||||
|
@ -548,10 +548,7 @@ and the existing module `${modulename}` may still work.')
|
||||||
if is_verbose {
|
if is_verbose {
|
||||||
eprintln('check_module_is_installed: cloning from ${murl} ...')
|
eprintln('check_module_is_installed: cloning from ${murl} ...')
|
||||||
}
|
}
|
||||||
cloning_res := os.execute('git clone ${os.quoted_path(murl)} ${os.quoted_path(mpath)}')
|
cloning_res := os.execute('${os.quoted_path(vexe)} retry -- git clone ${os.quoted_path(murl)} ${os.quoted_path(mpath)}')
|
||||||
if cloning_res.exit_code < 0 {
|
|
||||||
return error_with_code('git is not installed, error: ${cloning_res.output}', cloning_res.exit_code)
|
|
||||||
}
|
|
||||||
if cloning_res.exit_code != 0 {
|
if cloning_res.exit_code != 0 {
|
||||||
return error_with_code('cloning failed, details: ${cloning_res.output}', cloning_res.exit_code)
|
return error_with_code('cloning failed, details: ${cloning_res.output}', cloning_res.exit_code)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue