forked from ModTheGungeon/ETGMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bat
79 lines (68 loc) · 1.65 KB
/
build.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
@echo off
setlocal ENABLEDELAYEDEXPANSION
:: Requirements
where xbuild >nul 2>nul
if not %errorlevel%==0 (
where msbuild >nul 2>nul
if not !errorlevel!==0 (
echo ERROR: Neither xbuild nor msbuild were found. Make sure you have Mono or .NET Framework installed and the binaries are available in the PATH.
goto _exit
)
)
set sevenz=7z
if exist C:\Program Files\7-Zip\7z.exe (
set sevenz="C:\Program Files\7-Zip\7z.exe"
) else (
where 7z >nul 2>nul
if not %errorlevel%==0 (
echo ERROR: 7zip was not found. Make sure that you have it installed and in the PATH.
goto _exit
)
)
:: Prepare the target
set target=Debug
if %1.==release. goto _if_setrelease
goto _ifj_setrelease
:_if_setrelease
set target=Release
:_ifj_setrelease
:: Prepare the build directory
set build_base=build
set build_etgmod=ETGMOD
set "build=%build_base%\%build_etgmod%"
set "build_zip=%build_base%\%build_etgmod%.zip"
if exist "%build_base%" rmdir /q /s "%build_base%"
mkdir "%build_base%" 2>nul
mkdir "%build%" 2>nul
:: Build
where xbuild >nul 2>nul
if %errorlevel%==0 (
::call xbuild
rem
) else (
call msbuild
)
for /f "tokens=*" %%L in (build-files) do (
set "line=%%L"
set "line=!line:/=\!"
if not "!line:~0,1!"=="#" (
set "file=!line:{TARGET}=%target%!"
for %%f in (!file!) do set target=%%~nxf
rem
echo Copying '!file!' to '%build%/!target!'
for %%i in (!file!) do (
if exist %%~si\nul (
robocopy "!file!" "%build%/!target!" /s /e
) else (
copy "!file!" "%build%/!target!"
)
)
)
)
:: Zipping it all up
pushd "%build%"
%sevenz% a ETGMOD.zip *
popd
move "%build%\ETGMOD.zip" "%build_zip%"
:: The End
:_exit