2 setlocal enabledelayedexpansion
5 REM ///////////////////////////////////////////////////////////////////////////
6 REM // Setup environment
7 REM ///////////////////////////////////////////////////////////////////////////
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"
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"
23 REM ///////////////////////////////////////////////////////////////////////////
25 REM ///////////////////////////////////////////////////////////////////////////
27 if not exist "%MSVC_PATH%\vcvarsall.bat" (
28 "%~dp0\tools\cecho.exe" RED "\nMSVC not found.\n%MSVC_PATH:\=\\%\\vcvarsall.bat\n"
32 if not exist "%PDOC_PATH%\pandoc.exe" (
33 "%~dp0\tools\cecho.exe" RED "\nPandoc not found.\n%PDOC_PATH:\=\\%\\pandoc.exe\n"
37 if not exist "%GIT2_PATH%\git.exe" (
38 "%~dp0\tools\cecho.exe" RED "\nGIT not found.\n%GIT2_PATH:\=\\%\\git.exe\n"
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"
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"
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"
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"
62 if not exist "%PYTHON_HOME_INC%\Python.h" (
63 "%~dp0\tools\cecho.exe" RED "\nPython includes not found.\n%PYTHON_HOME_INC:\=\\%\\Python.h\n"
67 if not exist "%PYTHON_HOME_LIB32%\python3.lib" (
68 "%~dp0\tools\cecho.exe" RED "\nPython-x86 not found.\n%PYTHON_HOME_LIB32:\=\\%\\python3.lib\n"
72 if not exist "%PYTHON_HOME_LIB64%\python3.lib" (
73 "%~dp0\tools\cecho.exe" RED "\nPython-x64 not found.\n%PYTHON_HOME_LIB64:\=\\%\\python3.lib\n"
77 if not exist "%DELPHI_PATH%\bin\dcc32.exe" (
78 "%~dp0\tools\cecho.exe" RED "\nDelphi not found.\n%DELPHI_PATH:\=\\%\\bin\\dcc32.exe\n"
82 REM ///////////////////////////////////////////////////////////////////////////
83 REM // Get current date and time (in ISO format)
84 REM ///////////////////////////////////////////////////////////////////////////
88 for /F "tokens=1,2 delims=:" %%a in ('"%~dp0\tools\date.exe" +ISODATE:%%Y-%%m-%%d') do (
89 if "%%a"=="ISODATE" set "ISO_DATE=%%b"
91 for /F "tokens=1,2,3,4 delims=:" %%a in ('"%~dp0\tools\date.exe" +ISOTIME:%%T') do (
92 if "%%a"=="ISOTIME" set "ISO_TIME=%%b:%%c:%%d"
96 REM ///////////////////////////////////////////////////////////////////////////
97 REM // Clean up temp files
98 REM ///////////////////////////////////////////////////////////////////////////
100 "%~dp0\tools\cecho.exe" YELLOW "\n========[ CLEAN UP ]========\n"
102 for %%i in (bin,obj) do (
103 del /Q /S /F "%~dp0\%%i\*.*" 2> NUL
106 for %%i in (Microsoft.NET,Java,Delphi,Python) do (
107 for %%j in (native,library,wrapper,example) do (
108 for %%k in (bin,obj,out) do (
109 del /Q /S /F "%~dp0\bindings\%%i\%%j\%%k\*.*" 2> NUL
114 for %%i in (exe,dcu) do (
115 del /Q /S /F "%~dp0\bindings\Delphi\*.%%i" 2> NUL
119 REM ///////////////////////////////////////////////////////////////////////////
120 REM // Build the binaries
121 REM ///////////////////////////////////////////////////////////////////////////
123 "%~dp0\tools\cecho.exe" YELLOW "\n========[ COMPILE ]========"
125 call "%MSVC_PATH%\vcvarsall.bat"
127 set "MSVC_PROJECTS=MHashLib.sln"
128 set "MSVC_PROJECTS=%MSVC_PROJECTS%,bindings\Python\native\MHashPy384_Native.sln"
129 set "MSVC_PROJECTS=%MSVC_PROJECTS%,bindings\Delphi\native\MHashDelphi384.sln"
130 for %%q in (%MSVC_PROJECTS%) do (
131 for %%p in (x86,x64) do (
132 "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~nq (%%~p) ]----\n"
133 MSBuild.exe /property:Platform=%%p /property:Configuration=Release /target:Clean "%~dp0\%%~q"
134 if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
135 MSBuild.exe /property:Platform=%%p /property:Configuration=Release /target:Rebuild "%~dp0\%%~q"
136 if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
140 set "DOTNET_PROJECTS=bindings\Microsoft.NET\MHashDotNet384.sln"
141 for %%q in (%DOTNET_PROJECTS%) do (
142 "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~nq (%%~p) ]----\n"
143 MSBuild.exe /property:Platform="Any CPU" /property:Configuration=Release /target:Clean "%~dp0\%%~q"
144 if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
145 MSBuild.exe /property:Platform="Any CPU" /property:Configuration=Release /target:Rebuild "%~dp0\%%~q"
146 if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
149 for %%q in (example) do (
150 echo pushd "%~dp0\bindings\Delphi\%%~q"
151 pushd "%~dp0\bindings\Delphi\%%~q"
152 for %%p in (*.dpr) do (
153 "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~np ]----\n"
154 "%DELPHI_PATH%\bin\dcc32.exe" -B -CG -$O+ -E"bin" -N"obj" "%%~nxp"
155 if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
160 for %%q in (library,example) do (
161 "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~nq ]----\n"
162 pushd "%~dp0\bindings\Java\%%~q"
163 call "%ANT_HOME%\bin\ant.bat" clean jar
164 if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
169 REM ///////////////////////////////////////////////////////////////////////////
171 REM ///////////////////////////////////////////////////////////////////////////
173 "%PDOC_PATH%\pandoc.exe" --from markdown --to html5 --toc -N --standalone -H "%~dp0\etc\css\style.inc" --output "%~dp0\README.html" "%~dp0\README.md"
174 if not "%ERRORLEVEL%"=="0" goto BuildHasFailed
177 REM ///////////////////////////////////////////////////////////////////////////
178 REM // Generate output name
179 REM ///////////////////////////////////////////////////////////////////////////
181 mkdir "%~dp0\out" 2> NUL
186 :GenerateOutfileNameNext
187 set "OUT_PATH_BIN_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.bin-msvc-x86.zip"
188 set "OUT_PATH_BIN_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.bin-msvc-x64.zip"
189 set "OUT_PATH_NET_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.bin-dotnet.zip"
190 set "OUT_PATH_JNI_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.bin-java.zip"
191 set "OUT_PATH_PYC_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.python-win-x86.zip"
192 set "OUT_PATH_PYC_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.python-win-x64.zip"
193 set "OUT_PATH_PAS_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.delphi-win-x86.zip"
194 set "OUT_PATH_SRC_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.sources.tar.gz"
196 set /a COUNTER=COUNTER+1
197 set REVISON=.update-%COUNTER%
199 if exist "%OUT_PATH_BIN_X86%" goto GenerateOutfileNameNext
200 if exist "%OUT_PATH_BIN_X64%" goto GenerateOutfileNameNext
201 if exist "%OUT_PATH_NET_GEN%" goto GenerateOutfileNameNext
202 if exist "%OUT_PATH_JNI_GEN%" goto GenerateOutfileNameNext
203 if exist "%OUT_PATH_PYC_X86%" goto GenerateOutfileNameNext
204 if exist "%OUT_PATH_PYC_X64%" goto GenerateOutfileNameNext
205 if exist "%OUT_PATH_PAS_X86%" goto GenerateOutfileNameNext
206 if exist "%OUT_PATH_SRC_GEN%" goto GenerateOutfileNameNext
209 REM ///////////////////////////////////////////////////////////////////////////
210 REM // Build ZIP package
211 REM ///////////////////////////////////////////////////////////////////////////
213 "%~dp0\tools\cecho.exe" YELLOW "\n========[ PACKAGING ]========\n"
215 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_BIN_X86%" "%~dp0\bin\Win32\Release\mhash_384.x86.exe" "%~dp0\include\mhash_384.h" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
216 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_BIN_X64%" "%~dp0\bin\x64\.\Release\mhash_384.x64.exe" "%~dp0\include\mhash_384.h" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
218 "%~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"
220 "%~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"
222 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_PYC_X86%" "%~dp0\bindings\Python\native\bin\x86\Release\MHashPy384_Native.x86.pyd" "%~dp0\bindings\Python\wrapper\MHashPy384_Wrapper.py" "%~dp0\bindings\Python\wrapper\mhash.pth" "%~dp0\bindings\Python\example\MHashPy384_Example.py" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
223 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_PYC_X64%" "%~dp0\bindings\Python\native\bin\x64\Release\MHashPy384_Native.x64.pyd" "%~dp0\bindings\Python\wrapper\MHashPy384_Wrapper.py" "%~dp0\bindings\Python\wrapper\mhash.pth" "%~dp0\bindings\Python\example\MHashPy384_Example.py" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
225 "%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_PAS_X86%" "%~dp0\bindings\Delphi\native\bin\x86\Release\MHashDelphi384.x86.dll" "%~dp0\bindings\Delphi\wrapper\MHash384.pas" "%~dp0\bindings\Delphi\example\bin\Example.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
227 "%GIT2_PATH%\git.exe" archive --format tar.gz -9 --verbose --output "%OUT_PATH_SRC_GEN%" HEAD
230 REM ///////////////////////////////////////////////////////////////////////////
232 REM ///////////////////////////////////////////////////////////////////////////
234 "%~dp0\tools\cecho.exe" GREEN "\nBUILD COMPLETED.\n"
239 REM ///////////////////////////////////////////////////////////////////////////
241 REM ///////////////////////////////////////////////////////////////////////////
244 "%~dp0\tools\cecho.exe" RED "\nBUILD HAS FAILED.\n"