-
Notifications
You must be signed in to change notification settings - Fork 2
/
BuildMyApp.bat
143 lines (115 loc) · 3.62 KB
/
BuildMyApp.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
135
136
137
138
139
140
141
142
143
REM CommandInterpreter: $(COMSPEC)
@echo off
rem Script name
set me=%~n0
set SCRIPT_DIR=%~dp0
IF %SCRIPT_DIR:~-1%==\ set SCRIPT_DIR=%SCRIPT_DIR:~0,-1%
:SetGeneralsettings
set ProjectName=MyApp
:SetPathToProjectFiles
set ProjectResources=%SCRIPT_DIR%\Resources
set Sources=%SCRIPT_DIR%\Source
set SourceIncludings=%Sources%;%Sources%\util;%Sources%\logger;^
%Sources%\lib\synapse-r203-private1512
:SetPathToUsedLibs
rem Create new named var for a new lib path and add to INCLUDE_DIRS below
rem Lib path
set D7Lib=%ProgramFiles%\borland\delphi7\lib
rem MadExcept
set MadCollection=%ProgramFiles%\madCollection
set MadExcept=%MadCollection%\madExcept\Delphi 7
set MadBasic=%MadCollection%\madBasic\Delphi 7
set MadDisasm=%MadCollection%\MadDisasm\Delphi 7
rem Add your lib vars below
rem END SetPathToUsedLibs
:startBuild
echo:
echo %me%
echo -------------------------------------------------------------------------------
echo:
:compileResources
echo Compile Resources...
setlocal
call "%SCRIPT_DIR%\CompileResource.bat" "%ProjectResources%\versioninfo\MyAppVersionInfo.rc"
endlocal
if errorlevel 1 (
set ERRSTR=Resources Compilation failed
goto error
)
set PROJECT_FILE=%SCRIPT_DIR%\Projects\%ProjectName%.dpr
echo CheckMyAppDprRequiredIfDefs...
setlocal
call "%SCRIPT_DIR%\CheckMyAppDprRequiredIfDefs.bat" "%PROJECT_FILE%"
endlocal
if errorlevel 1 (
set ERRSTR=CheckMyAppDprRequiredIfDefs failed
goto error
)
:setBuildDateForApp
echo Set Build Date...
rem MyAppBuildDate.inc included in project
call "%SCRIPT_DIR%\SetBuildDate.bat" "%SCRIPT_DIR%\source\MyAppBuildDate.inc"
:compileProject
rem Compile params
set DEFINED_CONDITIONALS=Release;madExcept
: A8 Aligned record fields ON
: C- Assretions OFF
: D- Debug information OFF
: J- Writeable structured consts (OFF)
: L Local debug symbols
: O- Optimization OFF
: Q- Integer overflow checking OFF
: R- Range checking OFF
: Y Symbol reference info
: W- Stack frames OFF
: I- I/O Checks OFF
rem Release
set COMP_DIRECTIVE=-B -Q -W- -H- -GD ^
-$A8 -$D- -$J- -$L- -$O- -$Q- -$R- -$Y- -$C- -$I- -$B- -$P+ -$H+
set SRC_DIRS=%SourceIncludings%
rem Add required lib's vars below
set INCLUDE_DIRS=%D7Lib%;%MadExcept%;%MadBasic%;%MadDisasm%;%SRC_DIRS%
set BIN_DIR=%SCRIPT_DIR%\Build\bin
set DCU_DIR=%SCRIPT_DIR%\Build\dcu
set RESOURCE_DIRS=%INCLUDE_DIRS%;%ProjectResources%
rem USAGE:
rem Compile.bat PROJECT_FILE DEFINED_CONDITIONALS COMP_DIRECTIVE SRC_DIRS INCLUDE_DIRS RESOURCE_DIRS BIN_DIR DCU_DIR
setlocal
call "%SCRIPT_DIR%\Compile.bat" "%PROJECT_FILE%" "%DEFINED_CONDITIONALS%" "%COMP_DIRECTIVE%" "%SRC_DIRS%" "%INCLUDE_DIRS%" "%RESOURCE_DIRS%" "%BIN_DIR%" "%DCU_DIR%"
endlocal
if errorlevel 1 (
set ERRSTR=Compilation failed
goto error
)
:madExceptPatchBinary
rem MadExceptPatching tool madExceptPatch File.exe
set MADEXTOOLS_DIR=%ProgramFiles%\madCollection\madExcept\Tools
rem USAGE:
rem MadExceptPatchExe.bat MadExceptTools ExePath MadExceptSettings
setlocal
call "%SCRIPT_DIR%\MadExceptPatchExe.bat" "%MADEXTOOLS_DIR%" ^
"%BIN_DIR%\%ProjectName%.exe" "%SCRIPT_DIR%\Projects\%ProjectName%.mes"
endlocal
if errorlevel 1 (
set ERRSTR=MadExcept Patch failed
goto error
)
:allOK
rem When all OK
echo:
echo:
echo -------------------------------------------------------------------------------
echo %me%: OK
echo ===============================================================================
echo:
set errorCode=0
goto :end
:error
echo:
echo #############################################################################
echo %me%: FAIL %ERRSTR%
echo =============================================================================
set errorCode=1
goto :end
:end
exit /b %errorCode%