OSDN Git Service

Limit row iterator to "ROW_NUM / (THREAD_COUNT / 2)" + reset the row iterator on...
[mhash384/mhash384.git] / Make.cmd
1 @echo off
2 setlocal enabledelayedexpansion
3 cd /d "%~dp0"
4
5 REM ///////////////////////////////////////////////////////////////////////////
6 REM // Setup environment
7 REM ///////////////////////////////////////////////////////////////////////////
8
9 REM Build Tool-Chain
10 set "MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC"
11 set "GIT2_PATH=C:\Program Files\Git\bin"
12 set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131"
13 set "DELPHI_PATH=C:\Program Files (x86)\Borland\Delphi7"
14
15 REM Prerequisites
16 set "PDOC_PATH=%~dp0\..\Prerequisites\Pandoc"
17 set "ANT_HOME=%~dp0\..\Prerequisites\Ant"
18 set "PYTHON_HOME_INC=%~dp0\..\Prerequisites\Python3\include"
19 set "PYTHON_HOME_LIB32=%~dp0\..\Prerequisites\Python3\lib\Win32"
20 set "PYTHON_HOME_LIB64=%~dp0\..\Prerequisites\Python3\lib\x64"
21
22
23 REM ///////////////////////////////////////////////////////////////////////////
24 REM // Check paths
25 REM ///////////////////////////////////////////////////////////////////////////
26
27 if not exist "%MSVC_PATH%\vcvarsall.bat" (
28         "%~dp0\tools\cecho.exe" RED "\nMSVC not found.\n%MSVC_PATH:\=\\%\\vcvarsall.bat\n"
29         pause & goto:eof
30 )
31
32 if not exist "%PDOC_PATH%\pandoc.exe" (
33         "%~dp0\tools\cecho.exe" RED "\nPandoc not found.\n%PDOC_PATH:\=\\%\\pandoc.exe\n"
34         pause & goto:eof
35 )
36
37 if not exist "%GIT2_PATH%\git.exe" (
38         "%~dp0\tools\cecho.exe" RED "\nGIT not found.\n%GIT2_PATH:\=\\%\\git.exe\n"
39         pause & goto:eof
40 )
41
42 if not exist "%JAVA_HOME%\lib\tools.jar" (
43         "%~dp0\tools\cecho.exe" RED "\nJava not found.\n%JAVA_HOME:\=\\%\\lib\\tools.jar\n"
44         pause & goto:eof
45 )
46
47 if not exist "%JAVA_HOME%\bin\javac.exe" (
48         "%~dp0\tools\cecho.exe" RED "\nJava not found.\n%JAVA_HOME:\=\\%\\bin\\javac.exe\n"
49         pause & goto:eof
50 )
51
52 if not exist "%ANT_HOME%\bin\ant.bat" (
53         "%~dp0\tools\cecho.exe" RED "\nAnt not found.\n%ANT_HOME:\=\\%\\bin\\ant.cmd\n"
54         pause & goto:eof
55 )
56
57 if not exist "%ANT_HOME%\lib\ant.jar" (
58         "%~dp0\tools\cecho.exe" RED "\nAnt not found.\n%ANT_HOME:\=\\%\\lib\\ant.jar\n"
59         pause & goto:eof
60 )
61
62 if not exist "%DELPHI_PATH%\bin\dcc32.exe" (
63         "%~dp0\tools\cecho.exe" RED "\nDelphi not found.\n%DELPHI_PATH:\=\\%\\bin\\dcc32.exe\n"
64         pause & goto:eof
65 )
66
67 REM ///////////////////////////////////////////////////////////////////////////
68 REM // Get current date and time (in ISO format)
69 REM ///////////////////////////////////////////////////////////////////////////
70
71 set "ISO_DATE="
72 set "ISO_TIME="
73 for /F "tokens=1,2 delims=:" %%a in ('"%~dp0\tools\date.exe" +ISODATE:%%Y-%%m-%%d') do (
74         if "%%a"=="ISODATE" set "ISO_DATE=%%b"
75 )
76 for /F "tokens=1,2,3,4 delims=:" %%a in ('"%~dp0\tools\date.exe" +ISOTIME:%%T') do (
77         if "%%a"=="ISOTIME" set "ISO_TIME=%%b:%%c:%%d"
78 )
79
80
81 REM ///////////////////////////////////////////////////////////////////////////
82 REM // Clean up temp files
83 REM ///////////////////////////////////////////////////////////////////////////
84
85 "%~dp0\tools\cecho.exe" YELLOW "\n========[ CLEAN UP ]========\n"
86
87 for %%i in (bin,obj) do (
88         del /Q /S /F "%~dp0\%%i\*.*"  2> NUL
89 )
90
91 for %%i in (Microsoft.NET,Java,Delphi,Python) do (
92         for %%j in (native,library,wrapper,example) do (
93                 for %%k in (bin,obj,out) do (
94                         del /Q /S /F "%~dp0\bindings\%%i\%%j\%%k\*.*" 2> NUL
95                 )
96         )
97 )
98
99 for %%i in (exe,dcu) do (
100         del /Q /S /F "%~dp0\bindings\Delphi\*.%%i" 2> NUL
101 )
102
103
104 REM ///////////////////////////////////////////////////////////////////////////
105 REM // Build the binaries
106 REM ///////////////////////////////////////////////////////////////////////////
107
108 "%~dp0\tools\cecho.exe" YELLOW "\n========[ COMPILE ]========"
109
110 call "%MSVC_PATH%\vcvarsall.bat"
111
112 set "MSVC_PROJECTS=MHashLib.sln"
113 set "MSVC_CONFIGS=Release,Release_SSE2,Release_AVX"
114 for %%q in (%MSVC_PROJECTS%) do (
115         for %%p in (x86,x64) do (
116                 for %%c in (%MSVC_CONFIGS%) do (
117                         "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~nq (%%p,%%c) ]----\n"
118                         MSBuild.exe /property:Platform=%%p /property:Configuration=%%c /target:Clean   "%~dp0\%%~q"
119                         if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
120                         MSBuild.exe /property:Platform=%%p /property:Configuration=%%c /target:Rebuild "%~dp0\%%~q"
121                         if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
122                 )
123         )
124 )
125
126 set "DOTNET_PROJECTS=bindings\Microsoft.NET\MHashDotNet384.sln"
127 for %%q in (%DOTNET_PROJECTS%) do (
128         "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~nq (%%~p) ]----\n"
129         MSBuild.exe /property:Platform="Any CPU" /property:Configuration=Release /target:Clean   "%~dp0\%%~q"
130         if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
131         MSBuild.exe /property:Platform="Any CPU" /property:Configuration=Release /target:Rebuild "%~dp0\%%~q"
132         if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
133 )
134
135 for %%q in (example) do (
136         echo pushd "%~dp0\bindings\Delphi\%%~q"
137         pushd "%~dp0\bindings\Delphi\%%~q"
138         for %%p in (*.dpr) do (
139                 "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~np ]----\n"
140                 "%DELPHI_PATH%\bin\dcc32.exe" -B -CG -$O+ -E"bin" -N"obj" "%%~nxp"
141                 if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
142         )
143         popd
144 )
145
146 for %%q in (library,example) do (
147         "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~nq ]----\n"
148         pushd "%~dp0\bindings\Java\%%~q"
149         call "%ANT_HOME%\bin\ant.bat" clean jar
150         if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
151         popd
152 )
153
154
155 REM ///////////////////////////////////////////////////////////////////////////
156 REM // Generate Docs
157 REM ///////////////////////////////////////////////////////////////////////////
158
159 "%PDOC_PATH%\pandoc.exe" --from markdown --to html5 --toc -N --standalone -H "%~dp0\etc\css\style.inc" --output "%~dp0\README.html" "%~dp0\README.md"
160 if not "%ERRORLEVEL%"=="0" goto BuildHasFailed
161
162
163 REM ///////////////////////////////////////////////////////////////////////////
164 REM // Generate output name
165 REM ///////////////////////////////////////////////////////////////////////////
166
167 mkdir "%~dp0\out" 2> NUL
168
169 set COUNTER=
170 set REVISON=
171
172 :GenerateOutfileNameNext
173 set "OUT_PATH_BIN_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.msvc-x86.zip"
174 set "OUT_PATH_BIN_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.msvc-x64.zip"
175 set "OUT_PATH_NET_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.dotnet.zip"
176 set "OUT_PATH_JNI_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.java.zip"
177 set "OUT_PATH_PYC_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.python.zip"
178 set "OUT_PATH_PAS_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.delphi-x86.zip"
179 set "OUT_PATH_SRC_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.sources.tar.gz"
180
181 set /a COUNTER=COUNTER+1
182 set REVISON=.update-%COUNTER%
183
184 if exist "%OUT_PATH_BIN_X86%" goto GenerateOutfileNameNext
185 if exist "%OUT_PATH_BIN_X64%" goto GenerateOutfileNameNext
186 if exist "%OUT_PATH_NET_GEN%" goto GenerateOutfileNameNext
187 if exist "%OUT_PATH_JNI_GEN%" goto GenerateOutfileNameNext
188 if exist "%OUT_PATH_PYC_X86%" goto GenerateOutfileNameNext
189 if exist "%OUT_PATH_PYC_X64%" goto GenerateOutfileNameNext
190 if exist "%OUT_PATH_PAS_X86%" goto GenerateOutfileNameNext
191 if exist "%OUT_PATH_SRC_GEN%" goto GenerateOutfileNameNext
192
193
194 REM ///////////////////////////////////////////////////////////////////////////
195 REM // Build ZIP package
196 REM ///////////////////////////////////////////////////////////////////////////
197
198 "%~dp0\tools\cecho.exe" YELLOW "\n========[ PACKAGING ]========\n"
199
200 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_BIN_X86%" "%~dp0\include\mhash_384.h" "%~dp0\README.html" "%~dp0\COPYING.txt" "%~dp0\bin\Win32\Release\mhash_384.x86-i386.exe" "%~dp0\bin\Win32\Release_SSE2\mhash_384.x86-sse2.exe" "%~dp0\bin\Win32\Release_AVX\mhash_384.x86-avx.exe" < "%~dp0\COPYING.txt"
201 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_BIN_X64%" "%~dp0\include\mhash_384.h" "%~dp0\README.html" "%~dp0\COPYING.txt" "%~dp0\bin\x64\Release\mhash_384.x64-sse2.exe" "%~dp0\bin\x64\Release_AVX\mhash_384.x64-avx.exe" < "%~dp0\COPYING.txt"
202
203 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_NET_GEN%" "%~dp0\bindings\Microsoft.NET\library\bin\Release\MHashDotNet384.dll" "%~dp0\bindings\Microsoft.NET\example\bin\Release\MHashDotNet384.Example.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
204
205 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_JNI_GEN%" "%~dp0\bindings\Java\library\out\MHashJava384.jar" "%~dp0\bindings\Java\example\out\MHashJava384-Example.jar" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
206
207 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_PYC_GEN%" "%~dp0\bindings\Python\library\MHashPy384.py" "%~dp0\bindings\Python\example\MHashPy384_Example.py" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
208
209 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_PAS_X86%" "%~dp0\bindings\Delphi\library\MHash384.pas" "%~dp0\bindings\Delphi\example\bin\Example.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
210
211 "%GIT2_PATH%\git.exe" archive --format tar.gz -9 --verbose --output "%OUT_PATH_SRC_GEN%" HEAD
212
213
214 REM ///////////////////////////////////////////////////////////////////////////
215 REM // Completed
216 REM ///////////////////////////////////////////////////////////////////////////
217
218 "%~dp0\tools\cecho.exe" GREEN "\nBUILD COMPLETED.\n"
219 pause
220 goto:eof
221
222
223 REM ///////////////////////////////////////////////////////////////////////////
224 REM // Failed
225 REM ///////////////////////////////////////////////////////////////////////////
226
227 :BuildHasFailed
228 "%~dp0\tools\cecho.exe" RED "\nBUILD HAS FAILED.\n"
229 pause
230 goto:eof