-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy path_windows_readback_codegen_test.v
More file actions
76 lines (69 loc) · 1.97 KB
/
Copy path_windows_readback_codegen_test.v
File metadata and controls
76 lines (69 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
module gui
import os
import time
const windows_readback_codegen_prefix = 'gui_windows_readback_codegen_'
fn windows_readback_codegen_temp_dir() !string {
base := os.temp_dir()
name := '${windows_readback_codegen_prefix}${os.getpid()}_${time.now().unix_micro()}'
path := os.join_path(base, name)
os.mkdir_all(path)!
return path
}
fn windows_readback_codegen_compile_printing(tmp_dir string, output_name string, extra_flags []string) !string {
example_path := os.join_path(os.dir(@FILE), 'examples', 'printing.v')
output_path := os.join_path(tmp_dir, output_name)
mut args := [
os.quoted_path(@VEXE),
'-keepc',
'-no-parallel',
'-cc',
'msvc',
]
args << extra_flags
args << [
'-o',
os.quoted_path(output_path),
os.quoted_path(example_path),
]
result := os.execute(args.join(' '))
if result.exit_code != 0 {
return error(result.output)
}
c_path := os.join_path(tmp_dir, 'vtmp', '${output_name}.tmp.c')
return os.read_file(c_path)!
}
fn test_windows_printing_export_codegen_routes_readback_by_backend() {
$if !windows {
return
}
tmp_dir := windows_readback_codegen_temp_dir() or {
assert false, err.msg()
return
}
old_vtmp := os.getenv('VTMP')
os.setenv('VTMP', os.join_path(tmp_dir, 'vtmp'), true)
defer {
if old_vtmp == '' {
os.unsetenv('VTMP')
} else {
os.setenv('VTMP', old_vtmp, true)
}
os.rmdir_all(tmp_dir) or {}
}
default_c := windows_readback_codegen_compile_printing(tmp_dir, 'printing_default.exe', []) or {
assert false, err.msg()
return
}
assert default_c.contains('raster PDF export is not supported on Windows OpenGL yet')
assert !default_c.contains('sg_d3d11_query_image_info')
d3d11_c := windows_readback_codegen_compile_printing(tmp_dir, 'printing_d3d11.exe', [
'-d',
'sokol_d3d11',
]) or {
assert false, err.msg()
return
}
assert d3d11_c.contains('sg_d3d11_query_image_info')
assert d3d11_c.contains('readback_d3d11_texture')
assert !d3d11_c.contains('raster PDF export is not supported on Windows OpenGL yet')
}