forked from MFlowCode/MFC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mfc.bat
91 lines (69 loc) · 1.76 KB
/
mfc.bat
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@echo off
if "%1" == "docker" goto label_docker
goto label_windows
:label_windows
if not exist "%cd%\toolchain\mfc.py" (
echo.
echo ^[mfc.bat^] You must call this script from within MFC's root folder
echo.
exit /b 1
)
mkdir "%cd%\build" 2> NUL
if not exist "%cd%\build\venv" (
python3 -m venv "%cd%\build\venv"
if %errorlevel% neq 0 (
echo.
echo ^[mfc.bat^] Failed to create the Python virtual environment. Delete the build/venv folder and try again.
echo.
exit /b 1
)
)
call "%cd%\build\venv\Scripts\activate.bat"
if %errorlevel% neq 0 (
echo.
echo ^[mfc.bat^] Failed to activate the Python virtual environment.
echo.
exit /b 1
)
fc /b "%cd%\build\requirements.txt" "%cd%\toolchain\requirements.txt" 2> NUL
if %errorlevel% neq 0 (
pip3 install -r toolchain/requirements.txt
copy "%cd%\toolchain\requirements.txt" "%cd%\build" 2> NUL
)
python3 "%cd%\toolchain\mfc.py" %*
set main_py_err=%errorlevel%
call "%cd%\build\venv\Scripts\deactivate.bat"
if %main_py_err% neq 0 (
echo.
echo ^[mfc.bat^] Failed to run MFC.
echo.
)
exit /b %main_py_err%
:label_windows_after
:label_docker
where docker >nul 2>nul
if %errorlevel% neq 0 (
echo.
echo ^[mfc.bat^] You must have Docker installed.
echo Please install Docker and try again.
exit /b 1
)
echo ^[mfc.bat^] Fetching image...
docker pull henryleberre/mfc
if %errorlevel% neq 0 (
echo.
echo ^[mfc.bat^] Docker: Failed to fetch image.
echo Pleasure ensure docker is running.
exit /b 1
)
echo ^[mfc.bat^] Starting container...
docker run --interactive --tty --rm ^
--mount type=bind,source="%cd%",target=/home/me/MFC ^
henryleberre/mfc
if %errorlevel% neq 0 (
echo.
echo Docker: Fatal container runtime error.
exit /b 1
)
exit /b 0
:label_docker_after