-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.bat
134 lines (120 loc) · 2.81 KB
/
make.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
@echo off
setlocal enabledelayedexpansion
rem Mod info
set "MOD_DIR=NaviCustUncompress_EXE3"
rem Install locations
set "VOL1_DIR=C:\Program Files (x86)\Steam\steamapps\common\MegaMan_BattleNetwork_LegacyCollection_Vol1"
rem Build folder
set "BUILD_DIR=_build"
set "BUILD_DIR_VOL1=!BUILD_DIR!\!MOD_DIR!"
set "INSTALL_DIR_VOL1=!VOL1_DIR!\exe\mods\!MOD_DIR!"
set "TARGET=%1"
if /I [%1]==[] (
set "TARGET=release"
)
if /I [!TARGET!]==[clean] (
set "DO_CLEAN=1"
)
if /I [!TARGET!]==[install] (
set "DO_UNINSTALL=1"
set "DO_INSTALL=1"
)
if /I [!TARGET!]==[uninstall] (
set "DO_UNINSTALL=1"
)
if /I [!TARGET!]==[debug] (
set "DO_BUILD=1"
set "CARGO_OPTS="
set "TARGET_DIR=debug"
set "COPY_PDB=1"
)
if /I [!TARGET!]==[release] (
set "DO_BUILD=1"
set "CARGO_OPTS=--release"
set "TARGET_DIR=release"
)
if defined DO_CLEAN (
echo Running cargo clean...
cargo clean ^
1> nul || goto :error
echo Removing build folder...
if exist "!BUILD_DIR!" (
rmdir /S /Q "!BUILD_DIR!" ^
1> nul || goto :error
)
echo.
)
if defined DO_BUILD (
rem Build mod
echo Building for Volume 1...
rem Clean build folder
call :clean_folder "!BUILD_DIR_VOL1!"
echo Running cargo build...
cargo build !CARGO_OPTS! ^
1> nul || goto :error
echo Copying mod files...
copy "target\!TARGET_DIR!\patch.dll" "!BUILD_DIR_VOL1!" ^
1> nul || goto :error
if defined COPY_PDB (
copy "target\!TARGET_DIR!\patch.*" "!BUILD_DIR_VOL1!" ^
1> nul || goto :error
)
copy /Y "info.toml" "!BUILD_DIR_VOL1!\info.toml" ^
1> nul || goto :error
copy /Y "init.lua" "!BUILD_DIR_VOL1!\init.lua" ^
1> nul || goto :error
copy /Y "mod_readme.md" "!BUILD_DIR_VOL1!\README.md" ^
1> nul || goto :error
copy /Y "license.txt" "!BUILD_DIR_VOL1!\license.txt" ^
1> nul || goto :error
echo.
rem Copy miscellaneous files
copy /Y "readme.md" "!BUILD_DIR!\readme.txt" ^
1> nul || goto :error
)
if defined DO_UNINSTALL (
if exist "!VOL1_DIR!" (
echo Uninstalling for Volume 1...
if exist "!INSTALL_DIR_VOL1!" (
rmdir /S /Q "!INSTALL_DIR_VOL1!" ^
1> nul || goto :error
)
) else (
echo Volume 1 not installed; skipping...
)
echo.
)
if defined DO_INSTALL (
if exist "!VOL1_DIR!" (
if exist "!BUILD_DIR_VOL1!" (
echo Installing for Volume 1...
echo Copying mod folder...
if exist "!INSTALL_DIR_VOL1!" (
del /F /S /Q "!INSTALL_DIR_VOL1!\*" 1> nul || goto :error
) else (
mkdir "!INSTALL_DIR_VOL1!" 1> nul || goto :error
)
robocopy /E "!BUILD_DIR_VOL1!" "!INSTALL_DIR_VOL1!" 1> nul
if errorlevel 8 goto :error
) else (
echo Volume 1 not built; skipping...
)
) else (
echo Volume 1 not installed; skipping...
)
echo.
)
:done
echo Done.
echo.
exit /b 0
:error
echo Error occurred, failed to build.
echo.
exit /b 1
:clean_folder
if exist "%1" (
del /F /S /Q "%1\*" 1> nul || goto :error
) else (
mkdir "%1" 1> nul || goto :error
)