comptime: fix #ifdef/#endif generation
parent
93d2ab200f
commit
b10fcc79ba
|
@ -9,7 +9,6 @@ const (
|
||||||
'vlib/arrays/arrays_test.v',
|
'vlib/arrays/arrays_test.v',
|
||||||
'vlib/cli/command_test.v',
|
'vlib/cli/command_test.v',
|
||||||
'vlib/cli/flag_test.v',
|
'vlib/cli/flag_test.v',
|
||||||
'vlib/clipboard/clipboard_test.v', // Linux only
|
|
||||||
'vlib/crypto/aes/aes_test.v',
|
'vlib/crypto/aes/aes_test.v',
|
||||||
'vlib/crypto/rand/rand_test.v',
|
'vlib/crypto/rand/rand_test.v',
|
||||||
'vlib/crypto/rc4/rc4_test.v',
|
'vlib/crypto/rc4/rc4_test.v',
|
||||||
|
@ -22,16 +21,12 @@ const (
|
||||||
'vlib/net/http/http_httpbin_test.v',
|
'vlib/net/http/http_httpbin_test.v',
|
||||||
'vlib/net/http/http_test.v',
|
'vlib/net/http/http_test.v',
|
||||||
'vlib/regex/regex_test.v',
|
'vlib/regex/regex_test.v',
|
||||||
'vlib/sqlite/sqlite_test.v', // Linux only
|
|
||||||
'vlib/strconv/ftoa/f32_f64_to_string_test.v',
|
'vlib/strconv/ftoa/f32_f64_to_string_test.v',
|
||||||
'vlib/v/tests/array_to_string_test.v',
|
'vlib/v/tests/array_to_string_test.v',
|
||||||
'vlib/v/tests/asm_test.v', // Linux only
|
|
||||||
'vlib/v/tests/backtrace_test.v', // TCC only
|
|
||||||
'vlib/v/tests/enum_bitfield_test.v',
|
'vlib/v/tests/enum_bitfield_test.v',
|
||||||
'vlib/v/tests/fixed_array_test.v',
|
'vlib/v/tests/fixed_array_test.v',
|
||||||
'vlib/v/tests/fn_test.v',
|
'vlib/v/tests/fn_test.v',
|
||||||
'vlib/v/tests/fn_variadic_test.v',
|
'vlib/v/tests/fn_variadic_test.v',
|
||||||
'vlib/v/tests/live_test.v', // Linux only
|
|
||||||
'vlib/v/tests/match_test.v',
|
'vlib/v/tests/match_test.v',
|
||||||
'vlib/v/tests/msvc_test.v',
|
'vlib/v/tests/msvc_test.v',
|
||||||
'vlib/v/tests/mut_test.v',
|
'vlib/v/tests/mut_test.v',
|
||||||
|
@ -47,6 +42,12 @@ const (
|
||||||
'vlib/v/tests/valgrind/valgrind_test.v', // ubuntu-musl only
|
'vlib/v/tests/valgrind/valgrind_test.v', // ubuntu-musl only
|
||||||
'vlib/v/tests/pointers_str_test.v',
|
'vlib/v/tests/pointers_str_test.v',
|
||||||
]
|
]
|
||||||
|
skip_on_non_linux = [
|
||||||
|
'vlib/clipboard/clipboard_test.v', // Linux only
|
||||||
|
'vlib/sqlite/sqlite_test.v', // Linux only
|
||||||
|
'vlib/v/tests/asm_test.v', // Linux only
|
||||||
|
'vlib/v/tests/live_test.v', // Linux only
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -57,12 +58,14 @@ fn main() {
|
||||||
args_string := args[1..].join(' ')
|
args_string := args[1..].join(' ')
|
||||||
cmd_prefix := args_string.all_before('test-fixed')
|
cmd_prefix := args_string.all_before('test-fixed')
|
||||||
title := 'testing all fixed tests'
|
title := 'testing all fixed tests'
|
||||||
|
|
||||||
all_test_files := os.walk_ext( os.join_path(vroot,'vlib'), '_test.v')
|
all_test_files := os.walk_ext( os.join_path(vroot,'vlib'), '_test.v')
|
||||||
testing.eheader(title)
|
testing.eheader(title)
|
||||||
mut tsession := testing.new_test_session(cmd_prefix)
|
mut tsession := testing.new_test_session(cmd_prefix)
|
||||||
tsession.files << all_test_files
|
tsession.files << all_test_files
|
||||||
tsession.skip_files << skip_test_files
|
tsession.skip_files << skip_test_files
|
||||||
|
$if !linux {
|
||||||
|
tsession.skip_files << skip_on_non_linux
|
||||||
|
}
|
||||||
tsession.test()
|
tsession.test()
|
||||||
eprintln(tsession.benchmark.total_message(title))
|
eprintln(tsession.benchmark.total_message(title))
|
||||||
if tsession.benchmark.nfail > 0 {
|
if tsession.benchmark.nfail > 0 {
|
||||||
|
|
|
@ -508,6 +508,7 @@ fn (g mut Gen) write_defer_stmts() {
|
||||||
if defer_stmt.ifdef.len > 0 {
|
if defer_stmt.ifdef.len > 0 {
|
||||||
g.writeln(defer_stmt.ifdef)
|
g.writeln(defer_stmt.ifdef)
|
||||||
g.stmts(defer_stmt.stmts)
|
g.stmts(defer_stmt.stmts)
|
||||||
|
g.writeln('')
|
||||||
g.writeln('#endif')
|
g.writeln('#endif')
|
||||||
} else {
|
} else {
|
||||||
g.stmts(defer_stmt.stmts)
|
g.stmts(defer_stmt.stmts)
|
||||||
|
@ -2755,6 +2756,7 @@ fn op_to_fn_name(name string) string {
|
||||||
|
|
||||||
fn comp_if_to_ifdef(name string) string {
|
fn comp_if_to_ifdef(name string) string {
|
||||||
match name {
|
match name {
|
||||||
|
// platforms/os-es:
|
||||||
'windows' {
|
'windows' {
|
||||||
return '_WIN32'
|
return '_WIN32'
|
||||||
}
|
}
|
||||||
|
@ -2785,27 +2787,36 @@ fn comp_if_to_ifdef(name string) string {
|
||||||
'android' {
|
'android' {
|
||||||
return '__ANDROID__'
|
return '__ANDROID__'
|
||||||
}
|
}
|
||||||
'js' {
|
|
||||||
return '_VJS'
|
|
||||||
}
|
|
||||||
'solaris' {
|
'solaris' {
|
||||||
return '__sun'
|
return '__sun'
|
||||||
}
|
}
|
||||||
'haiku' {
|
'haiku' {
|
||||||
return '__haiku__'
|
return '__haiku__'
|
||||||
}
|
}
|
||||||
'tinyc' {
|
|
||||||
return 'tinyc'
|
|
||||||
}
|
|
||||||
'debug' {
|
|
||||||
return '_VDEBUG'
|
|
||||||
}
|
|
||||||
'linux_or_macos' {
|
'linux_or_macos' {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
'js' {
|
||||||
|
return '_VJS'
|
||||||
|
}
|
||||||
|
// compilers:
|
||||||
|
'tinyc' {
|
||||||
|
return '__TINYC__'
|
||||||
|
}
|
||||||
|
'clang' {
|
||||||
|
return '__clang__'
|
||||||
|
}
|
||||||
'mingw' {
|
'mingw' {
|
||||||
return '__MINGW32__'
|
return '__MINGW32__'
|
||||||
}
|
}
|
||||||
|
'msvc' {
|
||||||
|
return '_MSC_VER'
|
||||||
|
}
|
||||||
|
// other:
|
||||||
|
'debug' {
|
||||||
|
return '_VDEBUG'
|
||||||
|
}
|
||||||
'glibc' {
|
'glibc' {
|
||||||
return '__GLIBC__'
|
return '__GLIBC__'
|
||||||
}
|
}
|
||||||
|
@ -3015,24 +3026,24 @@ fn (g mut Gen) comp_if(it ast.CompIf) {
|
||||||
// NOTE: g.defer_ifdef is needed for defers called witin an ifdef
|
// NOTE: g.defer_ifdef is needed for defers called witin an ifdef
|
||||||
// in v1 this code would be completely excluded
|
// in v1 this code would be completely excluded
|
||||||
g.defer_ifdef = if it.is_not {
|
g.defer_ifdef = if it.is_not {
|
||||||
'#ifndef ' + ifdef
|
'\n#ifndef ' + ifdef
|
||||||
} else {
|
} else {
|
||||||
'#ifdef ' + ifdef
|
'\n#ifdef ' + ifdef
|
||||||
}
|
}
|
||||||
// println('comp if stmts $g.file.path:$it.pos.line_nr')
|
// println('comp if stmts $g.file.path:$it.pos.line_nr')
|
||||||
g.stmts(it.stmts)
|
g.stmts(it.stmts)
|
||||||
g.defer_ifdef = ''
|
g.defer_ifdef = ''
|
||||||
if it.has_else {
|
if it.has_else {
|
||||||
g.writeln('#else')
|
g.writeln('\n#else')
|
||||||
g.defer_ifdef = if it.is_not {
|
g.defer_ifdef = if it.is_not {
|
||||||
'#ifdef ' + ifdef
|
'\n#ifdef ' + ifdef
|
||||||
} else {
|
} else {
|
||||||
'#ifndef ' + ifdef
|
'\n#ifndef ' + ifdef
|
||||||
}
|
}
|
||||||
g.stmts(it.else_stmts)
|
g.stmts(it.else_stmts)
|
||||||
g.defer_ifdef = ''
|
g.defer_ifdef = ''
|
||||||
}
|
}
|
||||||
g.writeln('#endif')
|
g.writeln('\n#endif')
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (g mut Gen) go_stmt(node ast.GoStmt) {
|
fn (g mut Gen) go_stmt(node ast.GoStmt) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ const (
|
||||||
#define V64_PRINTFORMAT "0x%"PRIx64
|
#define V64_PRINTFORMAT "0x%"PRIx64
|
||||||
#elif defined(__WIN32__)
|
#elif defined(__WIN32__)
|
||||||
#define V64_PRINTFORMAT "0x%I64x"
|
#define V64_PRINTFORMAT "0x%I64x"
|
||||||
#elif defined(__LINUX__) && defined(__LP64__)
|
#elif defined(__linux__) && defined(__LP64__)
|
||||||
#define V64_PRINTFORMAT "0x%lx"
|
#define V64_PRINTFORMAT "0x%lx"
|
||||||
#else
|
#else
|
||||||
#define V64_PRINTFORMAT "0x%llx"
|
#define V64_PRINTFORMAT "0x%llx"
|
||||||
|
|
Loading…
Reference in New Issue