ompiler: MSVC related fixes and `v test v` for windows testing

* MSVC related fixes and v test v for windows testing

* If second stage crashes on windows goto error

* use os.exec instead of system so that the error can be printed

* use -debug for osx vid

* Fix some whitespace to trigger a rebuild
pull/1656/head
Emily Hudson 2019-08-18 15:25:33 +01:00 committed by Alexander Medvednikov
parent 0066afe7fc
commit d373b331fa
7 changed files with 109 additions and 92 deletions

View File

@ -52,5 +52,5 @@ script:
- |
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
git clone https://github.com/vlang/vid
cd vid && ../v .
cd vid && ../v -debug -o vid .
fi

View File

@ -427,9 +427,14 @@ void init_consts();')
}
// vlib can't have `init_consts()`
cgen.genln('void init_consts() {
#ifdef _WIN32\n _setmode(_fileno(stdout), _O_U8TEXT);
#ifdef _WIN32
#ifndef _BOOTSTRAP_NO_UNICODE_STREAM
_setmode(_fileno(stdout), _O_U8TEXT);
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), ENABLE_PROCESSED_OUTPUT | 0x0004);
// ENABLE_VIRTUAL_TERMINAL_PROCESSING\n#endif\n g_str_buf=malloc(1000);
// ENABLE_VIRTUAL_TERMINAL_PROCESSING
#endif
#endif
g_str_buf=malloc(1000);
$consts_init_body
}')
// _STR function can't be defined in vlib
@ -720,8 +725,7 @@ fn (c mut V) cc_windows_cross() {
winroot_url := 'https://github.com/vlang/v/releases/download/v0.1.10/winroot.zip'
println('"$winroot" not found. Download it from $winroot_url and save in $ModPath')
exit(1)
}
}
mut obj_name := c.out_name
obj_name = obj_name.replace('.exe', '')
obj_name = obj_name.replace('.o.o', '.o')
@ -745,7 +749,7 @@ fn (c mut V) cc_windows_cross() {
if os.system(link_cmd) != 0 {
println('Cross compilation for Windows failed. Make sure you have lld linker installed.')
exit(1)
}
}
// os.rm(obj_name)
}
println('Done!')
@ -1448,11 +1452,20 @@ fn update_v() {
fn test_v() {
vexe := os.args[0]
// Emily: pass args from the invocation to the test
// e.g. `v -g -os msvc test v` -> `$vexe -g -os msvc $file`
mut joined_args := os.args.right(1).join(' ')
joined_args = joined_args.left(joined_args.last_index('test'))
println('$joined_args')
test_files := os.walk_ext('.', '_test.v')
for file in test_files {
print(file + ' ')
if os.system('$vexe $file') != 0 {
println('failed')
r := os.exec('$vexe $joined_args -debug $file') or {
panic('failed on $file')
}
if r.exit_code != 0 {
println('failed `$file` (\n$r.output\n)')
exit(1)
} else {
println('OK')
@ -1462,8 +1475,11 @@ fn test_v() {
examples := os.walk_ext('examples', '.v')
for file in examples {
print(file + ' ')
if os.system('$vexe $file') != 0 {
println('failed')
r := os.exec('$vexe $joined_args -debug $file') or {
panic('failed on $file')
}
if r.exit_code != 0 {
println('failed `$file` (\n$r.output\n)')
exit(1)
} else {
println('OK')

View File

@ -345,6 +345,8 @@ pub fn (v mut V) cc_msvc() {
if !v.pref.is_prod {
a << '/DEBUG:FULL'
} else {
a << '/DEBUG:NONE'
}
args := a.join(' ')

View File

@ -20,19 +20,25 @@ echo fetch v_win.c
curl -O https://raw.githubusercontent.com/vlang/vc/master/v_win.c
echo build v_win.c with msvc
cl.exe /w /volatile:ms /D_UNICODE /DUNICODE /Fo.v_win.c.obj /O2 /MD v_win.c user32.lib kernel32.lib advapi32.lib shell32.lib /link /NOLOGO /OUT:v2.exe /INCREMENTAL:NO
cl.exe /w /volatile:ms /D_UNICODE /DUNICODE /D_BOOTSTRAP_NO_UNICODE_STREAM /Fo.v_win.c.obj /O2 /MD v_win.c user32.lib kernel32.lib advapi32.lib shell32.lib /link /DEBUG:NONE /NOLOGO /OUT:v2.exe /INCREMENTAL:NO
if %ERRORLEVEL% GEQ 1 (
goto :compileerror
)
echo rebuild from source
v2.exe -o v.exe compiler
v2.exe -os msvc -o v.exe compiler
if %ERRORLEVEL% GEQ 1 (
goto :compileerror
)
del .v_win.c.obj
del v_win.c
del v2.exe
echo Success
exit
:nomsvc

View File

@ -36,27 +36,20 @@ if %ERRORLEVEL% NEQ 0 goto :fail
setlocal EnableDelayedExpansion
echo testing v
for /r . %%x in (*_test.v) do (
v -o test.exe -debug %%x
if !ERRORLEVEL! NEQ 0 goto :fail
)
v test v
if %ERRORLEVEL% NEQ 0 goto :fail
echo testing v.msvc
for /r . %%x in (*_test.v) do (
v.msvc.exe -o test.exe -debug %%x
if !ERRORLEVEL! NEQ 0 goto :fail
)
v.msvc.exe test v
if %ERRORLEVEL% NEQ 0 goto :fail
echo testing v -os msvc
for /r . %%x in (*_test.v) do (
v -os msvc -o test.exe -debug %%x
if !ERRORLEVEL! NEQ 0 goto :fail
)
v -os msvc test v
if %ERRORLEVEL% NEQ 0 goto :fail
echo testing v.msvc -os msvc
for /r . %%x in (*_test.v) do (
v.msvc.exe -os msvc -o test.exe -debug %%x
if !ERRORLEVEL! NEQ 0 goto :fail
)
v.msvc.exe -os msvc test v
if %ERRORLEVEL% NEQ 0 goto :fail
goto :done

Binary file not shown.

Binary file not shown.