-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.bat
More file actions
47 lines (40 loc) · 1.05 KB
/
Copy pathrun.bat
File metadata and controls
47 lines (40 loc) · 1.05 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
@ECHO OFF
SETLOCAL EnableDelayedExpansion
FOR /f "delims=" %%F IN ('dir /b /s "src\%1.go" 2^>NUL') DO SET filepath=%%F
FOR %%F IN (%filepath%) DO SET filename=%%~nF
SET INPUT=io\in.txt
SET OUTPUT=io\out.txt
SET ERROR=io\err.txt
SET COMPILE=go build -o "bin\%filename%.exe" "%filepath%"
IF NOT EXIST "bin\" (
MKDIR "bin"
)
IF DEFINED filepath (
ECHO === Compiling: %filepath%
%COMPILE% 2> %ERROR%
IF ERRORLEVEL 1 (
ECHO === Compilation failed. See "%ERROR%" for details.
ECHO.
TYPE "%ERROR%"
ECHO.
) ELSE (
ECHO === Compilation successful.
ECHO.
"bin\%filename%.exe" < %INPUT% > %OUTPUT% 2> %ERROR% ^
&& SET success=true ^
|| SET success=
TYPE "%OUTPUT%"
ECHO.
if DEFINED success (
ECHO === Execution successful.
) ELSE (
ECHO === The program crashed. See "%ERROR%" for details.
ECHO.
TYPE "%ERROR%"
ECHO.
)
)
) ELSE (
ECHO === ERROR: File not found!
)
ENDLOCAL