-
Notifications
You must be signed in to change notification settings - Fork 9
/
make_package.bat
195 lines (183 loc) · 7.79 KB
/
make_package.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
@echo off
rem Script builds C API framework and configured projects from
rem dxf_master\dxf_master.csproj. The dxf_master project contains references to
rem all other projects and targets to build.
rem Dependencies:
rem 1. MSBuild 14
rem 2. MSBuild Command Prompt for VS2015
rem 3. MSBuild Extesion Pack 4.0
rem 4. nunit 2.6
rem 5*. All dependencies from %C_API_PATH%\%C_API_SCRIPT_NAME%
rem The operation order:
rem 1. Build C API library
rem 2. Copy %C_API_LIB_NAME%(d)(_64)%C_API_LIB_EXT% libraries to lib\*
rem folder of current project
rem 3. Build next targets from dxf_master: "Clean;UpdateVersion;Build;
rem RunUnitTests*;CopySources;GenerateSolution;CreatePackage"
rem where
rem Clean - Cleanup all projects.
rem UpdateVersion - Update assembly version for each project; the
rem version number passed through $(AssemblyVersion)
rem MSBuild parameter.
rem Build - Build all projects and copy binaries to
rem bin\dxfeed-net-api-<major.minor.patch>\bin of
rem dxf_master project.
rem RunUnitTests* - Build and run unit tests from
rem dxf_tests\dxf_tests.csproj; the list of running
rem tests configured in dxf_master\MakePackageTestList.txt;
rem * means that this target can be skipped if input
rem script parameter 'no-test' will be specified.
rem CopySources - Copy reference project source files to output
rem direcory of dxf_master project.
rem GenerateSolution- Filter projects, its dependencies and
rem configurations from original solution file and
rem generates new once.
rem CreatePackage - Create zip archive containing sources and
rem binaries.
rem
rem Usage:
rem make_package <major.minor.patch> <c-api-path> [no-test] [no-c-build]
rem Where
rem <major.minor.patch> - Version of package, i.e. 1.2.6
rem <c-api-path> - The path to C API directory where
rem %C_API_SCRIPT_NAME% is located
rem [no-test] - build testing will not be started (optional)
rem [no-c-build] - skip C build, it should be done already (optional)
rem
rem The result of build is located in dxf_master\bin
setlocal
rem Check msbuild application in PATH
where /q msbuild
if %ERRORLEVEL% GEQ 1 (
echo The 'msbuild' application is missing. Ensure it is installed and placed in your PATH.
goto exit_error
)
rem Check nunit-console application in PATH
where /q nunit-console
if %ERRORLEVEL% GEQ 1 (
echo The 'nunit-console' application is missing. Ensure it is installed and placed in your PATH.
goto exit_error
)
set VERSION=%1
set C_API_PATH=%2
set C_API_SCRIPT_NAME=make_package.bat
set C_API_BUILD=%C_API_PATH%\%C_API_SCRIPT_NAME%
set C_API_LIB_NAME=DXFeed
set C_API_LIB_EXT=.dll
set C_API_LIB_PDB_EXT=.pdb
set C_API_BIN_DIR_NAME=bin
set C_API_RELEASE_DIR_NAME=
set C_API_DEBUG_DIR_NAME=
set TARGET_TEST=RunUnitTests;
set C_API_NO_TEST=
set C_API_NO_BUIILD=
set C_API_NO_TLS=
set AssemblySuffix=
set C_API_NO_CI=
for %%A in (%*) do (
if [%%A] EQU [no-test] (
set TARGET_TEST=
set C_API_NO_TEST=no-test
)
if [%%A] EQU [no-c-build] (
set C_API_NO_BUIILD=yes
)
if [%%A] EQU [no-tls] (
set C_API_NO_TLS=yes
set AssemblySuffix=-no-tls
)
if [%%A] EQU [no-ci] (
set C_API_NO_CI=yes
)
)
rem Check version parameter
if [%VERSION%] EQU [] (
echo ERROR: The version of package is not specified or invalid^!
goto usage
)
rem Check C API path parameter
if [%C_API_PATH%] EQU [] (
echo ERROR: The c-api-path is not specified or invalid^!
goto usage
)
if [%C_API_NO_BUIILD%] EQU [yes] (
echo Skip C API build
if [%C_API_NO_CI%] EQU [yes] (
echo No CI
set C_API_BIN_DIR_NAME=build
set C_API_RELEASE_DIR_NAME=Release\
set C_API_DEBUG_DIR_NAME=Debug\
)
goto copy_c
)
if NOT EXIST %C_API_BUILD% (
echo ERROR: The build script '%C_API_BUILD%' is not exist^!
goto usage
)
rem === BUILD C API ===
set HOME_DIR=%cd%
cd %C_API_PATH%
call %C_API_SCRIPT_NAME% %VERSION% %C_API_NO_TEST%
set C_API_ERRORLEVEL=%ERRORLEVEL%
cd %HOME_DIR%
if %C_API_ERRORLEVEL% GEQ 1 (
echo C API build failed^!
goto exit_error
)
set C_API_BIN_DIR_NAME=build
set C_API_RELEASE_DIR_NAME=Release\
set C_API_DEBUG_DIR_NAME=Debug\
:copy_c
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x86\%C_API_RELEASE_DIR_NAME%%C_API_LIB_NAME%%C_API_LIB_EXT% %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x86\%C_API_RELEASE_DIR_NAME%%C_API_LIB_NAME%%C_API_LIB_PDB_EXT% %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x86\%C_API_DEBUG_DIR_NAME%%C_API_LIB_NAME%d%C_API_LIB_EXT% %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x86\%C_API_DEBUG_DIR_NAME%%C_API_LIB_NAME%d%C_API_LIB_PDB_EXT% %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x86\%C_API_DEBUG_DIR_NAME%libcrypto*.dll %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x86\%C_API_DEBUG_DIR_NAME%libssl*.dll %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x86\%C_API_DEBUG_DIR_NAME%libtls*.dll %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x64\%C_API_RELEASE_DIR_NAME%%C_API_LIB_NAME%_64%C_API_LIB_EXT% %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x64\%C_API_RELEASE_DIR_NAME%%C_API_LIB_NAME%_64%C_API_LIB_PDB_EXT% %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x64\%C_API_DEBUG_DIR_NAME%%C_API_LIB_NAME%d_64%C_API_LIB_EXT% %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x64\%C_API_DEBUG_DIR_NAME%%C_API_LIB_NAME%d_64%C_API_LIB_PDB_EXT% %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x64\%C_API_DEBUG_DIR_NAME%libcrypto*.dll %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x64\%C_API_DEBUG_DIR_NAME%libssl*.dll %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x64\%C_API_DEBUG_DIR_NAME%libtls*.dll %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
xcopy /Y /I %C_API_PATH%\%C_API_BIN_DIR_NAME%\x64\%C_API_DEBUG_DIR_NAME%vcruntime140.dll %~dp0\lib\
if %ERRORLEVEL% GEQ 1 goto exit_error
rem === BUILD PROJECTS ===
msbuild %~dp0\dxf_master\dxf_master.csproj /m /t:Clean;UpdateVersion;Build;%TARGET_TEST%CopySources;GenerateSolution;CreatePackage /p:Configuration=Release;Platform=AnyCPU;AssemblyVersion=%VERSION%
if %ERRORLEVEL% GEQ 1 goto exit_error
rem === FINISH ===
goto exit_success
:usage
echo.
echo Usage: %0 ^<major.minor.patch^> ^<c-api-path^> [no-test] [no-c-build]
echo ^<major.minor.patch^> - Version of package, i.e. 1.2.6
echo ^<c-api-path^> - The path to C API directory where %C_API_SCRIPT_NAME%
echo is located
echo [no-test] - build tests will not be started (optional)
echo [no-c-build] - skip C build, it should be done already (optional)
goto exit_error
:exit_success
echo.
echo Making package complete successfully.
exit /b 0
:exit_error
echo.
echo Making package failed^!
exit /b 1
:end