mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tools: fix v -prod cmd/tools/vdoctor.v
This commit is contained in:
parent
f885c7cea9
commit
0bde55f77e
@ -30,9 +30,7 @@ fn (mut a App) collect_info() {
|
|||||||
arch_details << 'little endian'
|
arch_details << 'little endian'
|
||||||
}
|
}
|
||||||
if os_kind == 'macos' {
|
if os_kind == 'macos' {
|
||||||
arch_details << a.cmd(
|
arch_details << a.cmd(command: 'sysctl -n machdep.cpu.brand_string')
|
||||||
command: 'sysctl -n machdep.cpu.brand_string'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
if os_kind == 'linux' {
|
if os_kind == 'linux' {
|
||||||
mut cpu_details := ''
|
mut cpu_details := ''
|
||||||
@ -55,13 +53,11 @@ fn (mut a App) collect_info() {
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
mut os_details := ''
|
mut os_details := ''
|
||||||
wsl_check := a.cmd(
|
wsl_check := a.cmd(command: 'cat /proc/sys/kernel/osrelease')
|
||||||
command: 'cat /proc/sys/kernel/osrelease'
|
|
||||||
)
|
|
||||||
if os_kind == 'linux' {
|
if os_kind == 'linux' {
|
||||||
os_details = a.get_linux_os_name()
|
os_details = a.get_linux_os_name()
|
||||||
if 'hypervisor' in a.cpu_info('flags') {
|
if a.cpu_info('flags').contains('hypervisor') {
|
||||||
if 'microsoft' in wsl_check {
|
if wsl_check.contains('microsoft') {
|
||||||
// WSL 2 is a Managed VM and Full Linux Kernel
|
// WSL 2 is a Managed VM and Full Linux Kernel
|
||||||
// See https://docs.microsoft.com/en-us/windows/wsl/compare-versions
|
// See https://docs.microsoft.com/en-us/windows/wsl/compare-versions
|
||||||
os_details += ' (WSL 2)'
|
os_details += ' (WSL 2)'
|
||||||
@ -71,7 +67,7 @@ fn (mut a App) collect_info() {
|
|||||||
}
|
}
|
||||||
// WSL 1 is NOT a Managed VM and Full Linux Kernel
|
// WSL 1 is NOT a Managed VM and Full Linux Kernel
|
||||||
// See https://docs.microsoft.com/en-us/windows/wsl/compare-versions
|
// See https://docs.microsoft.com/en-us/windows/wsl/compare-versions
|
||||||
if 'Microsoft' in wsl_check {
|
if wsl_check.contains('Microsoft') {
|
||||||
os_details += ' (WSL)'
|
os_details += ' (WSL)'
|
||||||
}
|
}
|
||||||
// From https://unix.stackexchange.com/a/14346
|
// From https://unix.stackexchange.com/a/14346
|
||||||
@ -81,15 +77,9 @@ fn (mut a App) collect_info() {
|
|||||||
}
|
}
|
||||||
} else if os_kind == 'macos' {
|
} else if os_kind == 'macos' {
|
||||||
mut details := []string{}
|
mut details := []string{}
|
||||||
details << a.cmd(
|
details << a.cmd(command: 'sw_vers -productName')
|
||||||
command: 'sw_vers -productName'
|
details << a.cmd(command: 'sw_vers -productVersion')
|
||||||
)
|
details << a.cmd(command: 'sw_vers -buildVersion')
|
||||||
details << a.cmd(
|
|
||||||
command: 'sw_vers -productVersion'
|
|
||||||
)
|
|
||||||
details << a.cmd(
|
|
||||||
command: 'sw_vers -buildVersion'
|
|
||||||
)
|
|
||||||
os_details = details.join(', ')
|
os_details = details.join(', ')
|
||||||
} else if os_kind == 'windows' {
|
} else if os_kind == 'windows' {
|
||||||
wmic_info := a.cmd(
|
wmic_info := a.cmd(
|
||||||
@ -105,9 +95,7 @@ fn (mut a App) collect_info() {
|
|||||||
}
|
}
|
||||||
a.line('OS', '$os_kind, $os_details')
|
a.line('OS', '$os_kind, $os_details')
|
||||||
a.line('Processor', arch_details.join(', '))
|
a.line('Processor', arch_details.join(', '))
|
||||||
a.line('CC version', a.cmd(
|
a.line('CC version', a.cmd(command: 'cc --version'))
|
||||||
command: 'cc --version'
|
|
||||||
))
|
|
||||||
a.println('')
|
a.println('')
|
||||||
getwd := os.getwd()
|
getwd := os.getwd()
|
||||||
vmodules := os.vmodules_dir()
|
vmodules := os.vmodules_dir()
|
||||||
@ -131,9 +119,7 @@ fn (mut a App) collect_info() {
|
|||||||
a.line('env VFLAGS', '"$vflags"')
|
a.line('env VFLAGS', '"$vflags"')
|
||||||
}
|
}
|
||||||
a.println('')
|
a.println('')
|
||||||
a.line('Git version', a.cmd(
|
a.line('Git version', a.cmd(command: 'git --version'))
|
||||||
command: 'git --version'
|
|
||||||
))
|
|
||||||
a.line('Git vroot status', a.git_info())
|
a.line('Git vroot status', a.git_info())
|
||||||
a.line('.git/config present', os.is_file('.git/config').str())
|
a.line('.git/config present', os.is_file('.git/config').str())
|
||||||
//
|
//
|
||||||
@ -168,7 +154,8 @@ fn (mut a App) line(label string, value string) {
|
|||||||
|
|
||||||
fn (app &App) parse(config string, sep string) map[string]string {
|
fn (app &App) parse(config string, sep string) map[string]string {
|
||||||
mut m := map[string]string{}
|
mut m := map[string]string{}
|
||||||
for line in config.split_into_lines() {
|
lines := config.split_into_lines()
|
||||||
|
for line in lines {
|
||||||
sline := line.trim_space()
|
sline := line.trim_space()
|
||||||
if sline.len == 0 || sline[0] == `#` {
|
if sline.len == 0 || sline[0] == `#` {
|
||||||
continue
|
continue
|
||||||
@ -200,24 +187,18 @@ fn (mut a App) get_linux_os_name() string {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
'lsb_release' {
|
'lsb_release' {
|
||||||
exists := a.cmd(
|
exists := a.cmd(command: 'type lsb_release')
|
||||||
command: 'type lsb_release'
|
|
||||||
)
|
|
||||||
if exists.starts_with('Error') {
|
if exists.starts_with('Error') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
os_details = a.cmd(
|
os_details = a.cmd(command: 'lsb_release -d -s')
|
||||||
command: 'lsb_release -d -s'
|
|
||||||
)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
'kernel' {
|
'kernel' {
|
||||||
if !os.is_file('/proc/version') {
|
if !os.is_file('/proc/version') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
os_details = a.cmd(
|
os_details = a.cmd(command: 'cat /proc/version')
|
||||||
command: 'cat /proc/version'
|
|
||||||
)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
'uname' {
|
'uname' {
|
||||||
@ -244,14 +225,10 @@ fn (mut a App) cpu_info(key string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn (mut a App) git_info() string {
|
fn (mut a App) git_info() string {
|
||||||
mut out := a.cmd(
|
mut out := a.cmd(command: 'git -C . describe --abbrev=8 --dirty --always --tags').trim_space()
|
||||||
command: 'git -C . describe --abbrev=8 --dirty --always --tags'
|
|
||||||
).trim_space()
|
|
||||||
os.execute('git -C . remote add V_REPO https://github.com/vlang/v') // ignore failure (i.e. remote exists)
|
os.execute('git -C . remote add V_REPO https://github.com/vlang/v') // ignore failure (i.e. remote exists)
|
||||||
os.execute('git -C . fetch V_REPO')
|
os.execute('git -C . fetch V_REPO')
|
||||||
commit_count := a.cmd(
|
commit_count := a.cmd(command: 'git rev-list @{0}...V_REPO/master --right-only --count').int()
|
||||||
command: 'git rev-list @{0}...V_REPO/master --right-only --count'
|
|
||||||
).int()
|
|
||||||
if commit_count > 0 {
|
if commit_count > 0 {
|
||||||
out += ' ($commit_count commit(s) behind V master)'
|
out += ' ($commit_count commit(s) behind V master)'
|
||||||
}
|
}
|
||||||
@ -263,12 +240,8 @@ fn (mut a App) report_tcc_version(tccfolder string) {
|
|||||||
a.line(tccfolder, 'N/A')
|
a.line(tccfolder, 'N/A')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tcc_branch_name := a.cmd(
|
tcc_branch_name := a.cmd(command: 'git -C $tccfolder rev-parse --abbrev-ref HEAD')
|
||||||
command: 'git -C $tccfolder rev-parse --abbrev-ref HEAD'
|
tcc_commit := a.cmd(command: 'git -C $tccfolder describe --abbrev=8 --dirty --always --tags')
|
||||||
)
|
|
||||||
tcc_commit := a.cmd(
|
|
||||||
command: 'git -C $tccfolder describe --abbrev=8 --dirty --always --tags'
|
|
||||||
)
|
|
||||||
a.line('$tccfolder status', '$tcc_branch_name $tcc_commit')
|
a.line('$tccfolder status', '$tcc_branch_name $tcc_commit')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user