Repository navigation
Expand file tree
/
Copy pathshow_graph.bat
More file actions
59 lines (54 loc) · 2.08 KB
/
Copy pathshow_graph.bat
File metadata and controls
59 lines (54 loc) · 2.08 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
@echo off
setlocal
rem Render a Graphviz .dot file to .svg (next to it) and open it with the default app.
rem Usage: show_graph.bat [path\to\graph.dot]
rem No argument: renders sample_game_frame.dot AND opens the average-run trace SVGs
rem (sample_game_frame_avg_baseline.svg / _optimised.svg / _fixed_rate.svg) if present --
rem the set macrame_playground --dot / --trace produces.
rem If Graphviz is missing, offers to install it via winget.
set "DOTFILE=%~1"
if "%DOTFILE%"=="" set "DOTFILE=sample_game_frame.dot"
set "DOTEXE=dot"
where dot >nul 2>nul
if not errorlevel 1 goto have_dot
set "DOTEXE=C:\Program Files\Graphviz\bin\dot.exe"
if exist "%DOTEXE%" goto have_dot
call :install_graphviz
if errorlevel 1 exit /b 1
:have_dot
if not exist "%DOTFILE%" (
echo '%DOTFILE%' not found; generate it with: macrame_playground --dot
exit /b 1
)
set "SVGFILE=%DOTFILE:.dot=.svg%"
"%DOTEXE%" -Tsvg "%DOTFILE%" -o "%SVGFILE%"
if errorlevel 1 exit /b 1
echo wrote %SVGFILE%
start "" "%SVGFILE%"
if not "%~1"=="" exit /b 0
if exist "sample_game_frame_avg_baseline.svg" start "" "sample_game_frame_avg_baseline.svg"
if exist "sample_game_frame_avg_optimised.svg" start "" "sample_game_frame_avg_optimised.svg"
if exist "sample_game_frame_avg_fixed_rate.svg" start "" "sample_game_frame_avg_fixed_rate.svg"
exit /b 0
:install_graphviz
where winget >nul 2>nul
if errorlevel 1 (
echo Graphviz 'dot' not found, and winget is unavailable to install it.
echo Install Graphviz manually: https://graphviz.org/download/
exit /b 1
)
choice /m "Graphviz 'dot' not found. Install it now via winget"
if errorlevel 2 (
echo Skipped. Install later with: winget install Graphviz.Graphviz
exit /b 1
)
winget install --id Graphviz.Graphviz -e --accept-source-agreements --accept-package-agreements
if errorlevel 1 (
echo winget install failed; install Graphviz manually: https://graphviz.org/download/
exit /b 1
)
if not exist "C:\Program Files\Graphviz\bin\dot.exe" (
echo Installed, but dot.exe is not at the expected path yet -- open a new terminal so PATH refreshes, then re-run.
exit /b 1
)
exit /b 0