-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathPreBuildProcessor.bat
106 lines (90 loc) · 3.03 KB
/
PreBuildProcessor.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
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
IF [%1]==[] GOTO usage
IF [%2]==[] GOTO usage
IF [%3]==[] GOTO usage
IF [%4]==[] GOTO usage
IF [%5]==[] GOTO end
SET EngineDir=%1
SET ProjectDir=%2
SET TargetConfiguration=%3
SET TargetType=%4
SET Enabled=%5
IF NOT %Enabled%==True GOTO end
SET ConfigFile="%ProjectDir:"=%\Config\DefaultGame.ini"
SET OriginalConfigFile="%ConfigFile:"=%.orig"
SET BuildVersionFile="%EngineDir:"=%\Build\Build.version"
SET IniSection=+IniSectionBlacklist
SET ServerSettingsSectionList=/Script/AccelByteUe4Sdk.AccelByteServerSettings ^
/Script/AccelByteUe4Sdk.AccelByteServerSettingsDev ^
/Script/AccelByteUe4Sdk.AccelByteServerSettingsCert ^
/Script/AccelByteUe4Sdk.AccelByteServerSettingsProd
SET PackagingSettingSection=[/Script/UnrealEd.ProjectPackagingSettings]
CALL :get_engine_version Version
IF %Version%==5 SET IniSection=+IniSectionDenylist
IF NOT %TargetConfiguration%==Shipping GOTO end
IF %TargetType%==Editor GOTO end
IF %TargetType%==Server GOTO end
COPY /y %ConfigFile% %OriginalConfigFile% >NUL
CALL :append_section_blacklist
EXIT /b 0
:usage
ECHO Usage: PreBuildProcessor.bat {engine_dir} {project_dir} {target_configuration} {target_type} {enabled=False}
EXIT /b 1
:append_section_blacklist
SET ConfigFileTmp="%ConfigFile:"=%.tmp"
SET CurrentSection=
SET FirstLine=True
SET IsPackagingSettingSection=False
(FOR /f "usebackq eol=` delims=" %%i IN (%ConfigFile%) DO (
SET Line=%%i
IF "x!Line:~0,1!"=="x[" (
IF !FirstLine!==True (
SET FirstLine=False
) ELSE (
ECHO:
)
SET CurrentSection=!Line!
IF !CurrentSection!==!PackagingSettingSection! (
SET IsPackagingSettingSection=True
)
) ELSE (
IF !CurrentSection!==!PackagingSettingSection! (
FOR %%a IN (!ServerSettingsSectionList!) DO (
IF !Line!==!IniSection!=%%a (
SET Line=
)
)
) ELSE (
IF !IsPackagingSettingSection!==True (
FOR %%a IN (!ServerSettingsSectionList!) DO (
ECHO !IniSection!=%%a
)
SET IsPackagingSettingSection=False
)
)
)
IF NOT [!Line!] == [] ECHO !Line!
))>%ConfigFileTmp%
IF !IsPackagingSettingSection!==True (
(FOR %%a IN (!ServerSettingsSectionList!) DO (
ECHO !IniSection!=%%a
))>>"%ConfigFileTmp%"
)
COPY /y %ConfigFileTmp% %ConfigFile% >NUL
DEL %ConfigFileTmp%
EXIT /B 0
:get_engine_version
SET BuildVersion=
FOR /f "usebackq tokens=1,2" %%a IN (%BuildVersionFile%) DO (
SET VersionInfoKey=%%a
SET VersionInfoValue=%%b
SET MajorVersionKey=!VersionInfoKey:MajorVersion=!
IF NOT !VersionInfoKey!==!MajorVersionKey! (
SET BuildVersion=!VersionInfoValue:,=!
)
)
SET %~1=%BuildVersion%
EXIT /B 0
:end
ENDLOCAL