| 1 | import os |
| 2 | |
| 3 | fn test_sharedlive_windows_cgen_reuses_host_sokol_backend() { |
| 4 | tmp_dir := os.join_path(os.vtmp_dir(), 'live_windows_shared_graphics_cgen') |
| 5 | os.mkdir_all(tmp_dir)! |
| 6 | defer { |
| 7 | os.rmdir_all(tmp_dir) or {} |
| 8 | } |
| 9 | c_path := os.join_path(tmp_dir, 'graph_sharedlive_windows.c') |
| 10 | graph_path := os.join_path(@VEXEROOT, 'examples', 'hot_reload', 'graph.v') |
| 11 | build_cmd := '${os.quoted_path(@VEXE)} -nocolor -os windows -sharedlive -o ${os.quoted_path(c_path)} ${os.quoted_path(graph_path)}' |
| 12 | build_res := os.execute(build_cmd) |
| 13 | assert build_res.exit_code == 0 |
| 14 | c_source := os.read_file(c_path)! |
| 15 | assert !c_source.contains('#define SOKOL_APP_IMPL') |
| 16 | assert !c_source.contains('#define SOKOL_GFX_IMPL') |
| 17 | assert !c_source.contains('#define SOKOL_IMPL') |
| 18 | } |
| 19 | |
| 20 | fn test_sharedlive_macos_does_not_export_sokol_objc_classes() { |
| 21 | $if !macos { |
| 22 | return |
| 23 | } |
| 24 | nm_path := os.find_abs_path_of_executable('nm') or { panic(err) } |
| 25 | tmp_dir := os.join_path(os.vtmp_dir(), 'live_macos_objc_duplication') |
| 26 | os.mkdir_all(tmp_dir)! |
| 27 | defer { |
| 28 | os.rmdir_all(tmp_dir) or {} |
| 29 | } |
| 30 | dylib_path := os.join_path(tmp_dir, 'graph_sharedlive.dylib') |
| 31 | graph_path := os.join_path(@VEXEROOT, 'examples', 'hot_reload', 'graph.v') |
| 32 | build_cmd := '${os.quoted_path(@VEXE)} -nocolor -cc clang -sharedlive -shared -o ${os.quoted_path(dylib_path)} ${os.quoted_path(graph_path)}' |
| 33 | build_res := os.execute(build_cmd) |
| 34 | assert build_res.exit_code == 0 |
| 35 | nm_res := os.execute('${os.quoted_path(nm_path)} -gjU ${os.quoted_path(dylib_path)}') |
| 36 | assert nm_res.exit_code == 0 |
| 37 | assert !nm_res.output.contains(r'_OBJC_CLASS_$_MyView2') |
| 38 | assert !nm_res.output.contains(r'_OBJC_CLASS_$__sapp_macos_') |
| 39 | assert !nm_res.output.contains(r'_OBJC_METACLASS_$__sapp_macos_') |
| 40 | } |
| 41 | |