OSDN Git Service

Improved build script.
[mhash384/mhash384.git] / Make.cmd
index 1b6ec3e..a208038 100644 (file)
--- a/Make.cmd
+++ b/Make.cmd
@@ -6,18 +6,17 @@ REM ///////////////////////////////////////////////////////////////////////////
 REM // Setup environment
 REM ///////////////////////////////////////////////////////////////////////////
 
-set "MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC"
-set "PDOC_PATH=C:\Program Files (x86)\Pandoc"
+REM Build Tool-Chain
+set "MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build"
 set "GIT2_PATH=C:\Program Files\Git\bin"
+set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_162"
+set "DELPHI_PATH=C:\Program Files (x86)\Borland\Delphi7"
 
-REM Java Paths
-set "JDK_HOME=C:\Program Files\Java\jdk1.8.0_77"
-set "ANT_HOME=C:\Eclipse\apache-ant"
-
-REM Python Paths
-set "PYTHON_HOME_X86=C:\Program Files (x86)\Python35-32"
-set "PYTHON_HOME_X64=C:\Program Files\Python35"
-
+REM Prerequisites
+set "PDOC_PATH=%~dp0\..\Prerequisites\Pandoc"
+set "ANT_HOME=%~dp0\..\Prerequisites\Ant"
+set "HTMLCMPR_PATH=%~dp0\..\Prerequisites\HTMLCompressor\bin"
+set "CSS_INC_PATH=%~dp0\..\Prerequisites\Pandoc\css"
 
 REM ///////////////////////////////////////////////////////////////////////////
 REM // Check paths
@@ -38,13 +37,13 @@ if not exist "%GIT2_PATH%\git.exe" (
        pause & goto:eof
 )
 
-if not exist "%JDK_HOME%\lib\tools.jar" (
-       "%~dp0\tools\cecho.exe" RED "\nJava not found.\n%JDK_HOME:\=\\%\\lib\\tools.jar\n"
+if not exist "%JAVA_HOME%\lib\tools.jar" (
+       "%~dp0\tools\cecho.exe" RED "\nJava not found.\n%JAVA_HOME:\=\\%\\lib\\tools.jar\n"
        pause & goto:eof
 )
 
-if not exist "%JDK_HOME%\bin\javac.exe" (
-       "%~dp0\tools\cecho.exe" RED "\nJava not found.\n%JDK_HOME:\=\\%\\bin\\javac.exe\n"
+if not exist "%JAVA_HOME%\bin\javac.exe" (
+       "%~dp0\tools\cecho.exe" RED "\nJava not found.\n%JAVA_HOME:\=\\%\\bin\\javac.exe\n"
        pause & goto:eof
 )
 
@@ -58,17 +57,11 @@ if not exist "%ANT_HOME%\lib\ant.jar" (
        pause & goto:eof
 )
 
-if not exist "%PYTHON_HOME_X86%\include\Python.h" (
-       "%~dp0\tools\cecho.exe" RED "\nPython-x86 not found.\n%PYTHON_HOME_X86:\=\\%\\include\\Python.h\n"
-       pause & goto:eof
-)
-
-if not exist "%PYTHON_HOME_X64%\include\Python.h" (
-       "%~dp0\tools\cecho.exe" RED "\nPython-x64 not found.\n%PYTHON_HOME_X64:\=\\%\\include\\Python.h\n"
+if not exist "%DELPHI_PATH%\bin\dcc32.exe" (
+       "%~dp0\tools\cecho.exe" RED "\nDelphi not found.\n%DELPHI_PATH:\=\\%\\bin\\dcc32.exe\n"
        pause & goto:eof
 )
 
-
 REM ///////////////////////////////////////////////////////////////////////////
 REM // Get current date and time (in ISO format)
 REM ///////////////////////////////////////////////////////////////////////////
@@ -90,19 +83,19 @@ REM ///////////////////////////////////////////////////////////////////////////
 "%~dp0\tools\cecho.exe" YELLOW "\n========[ CLEAN UP ]========\n"
 
 for %%i in (bin,obj) do (
-       del /Q /S /F "%~dp0\%%i\*.*"
+       del /Q /S /F "%~dp0\%%i\*.*"  2> NUL
 )
 
-for %%i in (bin,MHashDotNet384.Example\obj,MHashDotNet384.Wrapper\obj) do (
-       del /Q /S /F "%~dp0\bindings\Microsoft.NET\%%i\*.*"
-)
-
-for %%i in (native\obj,native\bin,warapper\bin,warapper\out) do (
-       del /Q /S /F "%~dp0\bindings\Java\%%i\*.*"
+for %%i in (Microsoft.NET,Java,Delphi,Python) do (
+       for %%j in (native,library,wrapper,example) do (
+               for %%k in (bin,obj,out) do (
+                       del /Q /S /F "%~dp0\bindings\%%i\%%j\%%k\*.*" 2> NUL
+               )
+       )
 )
 
-for %%i in (native\obj,native\out) do (
-       del /Q /S /F "%~dp0\bindings\Python\%%i\*.*"
+for %%i in (exe,dcu) do (
+       del /Q /S /F "%~dp0\bindings\Delphi\*.%%i" 2> NUL
 )
 
 
@@ -112,26 +105,43 @@ REM ///////////////////////////////////////////////////////////////////////////
 
 "%~dp0\tools\cecho.exe" YELLOW "\n========[ COMPILE ]========"
 
-set "JAVA_HOME=%JDK_HOME%"
-set "ANT_HOME=%ANT_HOME%"
-call "%MSVC_PATH%\vcvarsall.bat"
+call "%MSVC_PATH%\vcvarsall.bat" x86
 
 set "MSVC_PROJECTS=MHashLib.sln"
-set "MSVC_PROJECTS=%MSVC_PROJECTS%,bindings\Microsoft.NET\MHashDotNet384.sln"
-set "MSVC_PROJECTS=%MSVC_PROJECTS%,bindings\Java\native\MHashJava384.sln"
-set "MSVC_PROJECTS=%MSVC_PROJECTS%,bindings\Python\native\MHashPy384_Native.sln"
-
+set "MSVC_CONFIGS=Release,Release_SSE2,Release_AVX"
 for %%q in (%MSVC_PROJECTS%) do (
        for %%p in (x86,x64) do (
-               "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~nq (%%~p) ]----\n"
-               MSBuild.exe /property:Platform=%%p /property:Configuration=Release /target:Clean   "%~dp0\%%~q"
-               if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
-               MSBuild.exe /property:Platform=%%p /property:Configuration=Release /target:Rebuild "%~dp0\%%~q"
+               for %%c in (%MSVC_CONFIGS%) do (
+                       "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~nq (%%p,%%c) ]----\n"
+                       MSBuild.exe /property:Platform=%%p /property:Configuration=%%c /target:Clean   "%~dp0\%%~q"
+                       if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
+                       MSBuild.exe /property:Platform=%%p /property:Configuration=%%c /target:Rebuild "%~dp0\%%~q"
+                       if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
+               )
+       )
+)
+
+set "DOTNET_PROJECTS=bindings\Microsoft.NET\MHashDotNet384.sln"
+for %%q in (%DOTNET_PROJECTS%) do (
+       "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~nq (%%~p) ]----\n"
+       MSBuild.exe /property:Platform="Any CPU" /property:Configuration=Release /target:Clean   "%~dp0\%%~q"
+       if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
+       MSBuild.exe /property:Platform="Any CPU" /property:Configuration=Release /target:Rebuild "%~dp0\%%~q"
+       if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
+)
+
+for %%q in (example) do (
+       echo pushd "%~dp0\bindings\Delphi\%%~q"
+       pushd "%~dp0\bindings\Delphi\%%~q"
+       for %%p in (*.dpr) do (
+               "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~np ]----\n"
+               "%DELPHI_PATH%\bin\dcc32.exe" -B -CG -$O+ -E"bin" -N"obj" "%%~nxp"
                if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
        )
+       popd
 )
 
-for %%q in (wrapper,example) do (
+for %%q in (library,example) do (
        "%~dp0\tools\cecho.exe" CYAN "\n----[ %%~nq ]----\n"
        pushd "%~dp0\bindings\Java\%%~q"
        call "%ANT_HOME%\bin\ant.bat" clean jar
@@ -144,7 +154,7 @@ REM ///////////////////////////////////////////////////////////////////////////
 REM // Generate Docs
 REM ///////////////////////////////////////////////////////////////////////////
 
-"%PDOC_PATH%\pandoc.exe" --from markdown --to html5 --toc -N --standalone --output "%~dp0\README.html" "%~dp0\README.md"
+"%PDOC_PATH%\pandoc.exe" --from markdown_github+pandoc_title_block+header_attributes+implicit_figures --to html5 --toc -N --standalone -H "%CSS_INC_PATH%\github-pandoc.inc" "%%~i" | "%JAVA_HOME%\bin\java.exe" -jar "%HTMLCMPR_PATH%\htmlcompressor-1.5.3.jar" --compress-css -o "%%~dpni.html"
 if not "%ERRORLEVEL%"=="0" goto BuildHasFailed
 
 
@@ -158,14 +168,12 @@ set COUNTER=
 set REVISON=
 
 :GenerateOutfileNameNext
-set "OUT_PATH_BIN_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.bin-msvc-x86.zip"
-set "OUT_PATH_BIN_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.bin-msvc-x64.zip"
-set "OUT_PATH_NET_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.dotnet-x86.zip"
-set "OUT_PATH_NET_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.dotnet-x64.zip"
-set "OUT_PATH_JNI_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.java-win-x86.zip"
-set "OUT_PATH_JNI_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.java-win-x64.zip"
-set "OUT_PATH_PYC_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.python-win-x86.zip"
-set "OUT_PATH_PYC_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.python-win-x64.zip"
+set "OUT_PATH_BIN_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.msvc-x86.zip"
+set "OUT_PATH_BIN_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.msvc-x64.zip"
+set "OUT_PATH_NET_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.dotnet.zip"
+set "OUT_PATH_JNI_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.java.zip"
+set "OUT_PATH_PYC_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.python.zip"
+set "OUT_PATH_PAS_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.delphi-x86.zip"
 set "OUT_PATH_SRC_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.sources.tar.gz"
 
 set /a COUNTER=COUNTER+1
@@ -173,12 +181,11 @@ set REVISON=.update-%COUNTER%
 
 if exist "%OUT_PATH_BIN_X86%" goto GenerateOutfileNameNext
 if exist "%OUT_PATH_BIN_X64%" goto GenerateOutfileNameNext
-if exist "%OUT_PATH_NET_X86%" goto GenerateOutfileNameNext
-if exist "%OUT_PATH_NET_X64%" goto GenerateOutfileNameNext
-if exist "%OUT_PATH_JNI_X86%" goto GenerateOutfileNameNext
-if exist "%OUT_PATH_JNI_X64%" goto GenerateOutfileNameNext
+if exist "%OUT_PATH_NET_GEN%" goto GenerateOutfileNameNext
+if exist "%OUT_PATH_JNI_GEN%" goto GenerateOutfileNameNext
 if exist "%OUT_PATH_PYC_X86%" goto GenerateOutfileNameNext
 if exist "%OUT_PATH_PYC_X64%" goto GenerateOutfileNameNext
+if exist "%OUT_PATH_PAS_X86%" goto GenerateOutfileNameNext
 if exist "%OUT_PATH_SRC_GEN%" goto GenerateOutfileNameNext
 
 
@@ -188,20 +195,115 @@ REM ///////////////////////////////////////////////////////////////////////////
 
 "%~dp0\tools\cecho.exe" YELLOW "\n========[ PACKAGING ]========\n"
 
-"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_BIN_X86%" "%~dp0\bin\Win32\Release\mhash_384.x86.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
-"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_BIN_X64%" "%~dp0\bin\x64\.\Release\mhash_384.x64.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
+set "PACK_PATH=%TMP%\%RANDOM%%RANDOM%"
+mkdir "%PACK_PATH%"
+echo  "%PACK_PATH%"
+
+"%~dp0\tools\cecho.exe" CYAN "\n----[ Binaries (x86) ]----\n"
+
+mkdir "%PACK_PATH%\bin_x86"
+mkdir "%PACK_PATH%\bin_x86\img"
+mkdir "%PACK_PATH%\bin_x86\img\mhash"
 
-"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_NET_X86%" "%~dp0\bindings\Microsoft.NET\bin\x86\Release\MHashDotNet384.x86.dll" "%~dp0\bindings\Microsoft.NET\bin\x86\Release\MHashDotNet384.Example.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
-"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_NET_X64%" "%~dp0\bindings\Microsoft.NET\bin\x64\Release\MHashDotNet384.x64.dll" "%~dp0\bindings\Microsoft.NET\bin\x64\Release\MHashDotNet384.Example.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
+copy "%~dp0\COPYING.txt"                                   "%PACK_PATH%\bin_x86"
+copy "%~dp0\README.html"                                   "%PACK_PATH%\bin_x86"
+copy "%~dp0\img\mhash\*.jpg"                               "%PACK_PATH%\bin_x86\img\mhash"
+copy "%~dp0\bin\Win32\Release\mhash_384.x86-i386.exe"      "%PACK_PATH%\bin_x86"
+copy "%~dp0\bin\Win32\Release_SSE2\mhash_384.x86-sse2.exe" "%PACK_PATH%\bin_x86"
+copy "%~dp0\bin\Win32\Release_AVX\mhash_384.x86-avx.exe"   "%PACK_PATH%\bin_x86"
 
-"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_JNI_X86%" "%~dp0\bindings\Java\native\bin\x86\Release\MHashJava384.x86.dll" "%~dp0\bindings\Java\wrapper\out\MHashJava384-Wrapper.jar" "%~dp0\bindings\Java\example\out\MHashJava384-Example.jar" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
-"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_JNI_X64%" "%~dp0\bindings\Java\native\bin\x64\Release\MHashJava384.x64.dll" "%~dp0\bindings\Java\wrapper\out\MHashJava384-Wrapper.jar" "%~dp0\bindings\Java\example\out\MHashJava384-Example.jar" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
+pushd "%PACK_PATH%\bin_x86"
+"%~dp0\tools\zip.exe" -r -9 -z "%OUT_PATH_BIN_X86%" "." < "%~dp0\COPYING.txt"
+popd
 
-"%~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\Example.py" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
-"%~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\Example.py" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
+"%~dp0\tools\cecho.exe" CYAN "\n----[ Binaries (x64) ]----\n"
 
+mkdir "%PACK_PATH%\bin_x64"
+mkdir "%PACK_PATH%\bin_x64\img"
+mkdir "%PACK_PATH%\bin_x64\img\mhash"
+
+copy "%~dp0\COPYING.txt"                                   "%PACK_PATH%\bin_x64"
+copy "%~dp0\README.html"                                   "%PACK_PATH%\bin_x64"
+copy "%~dp0\img\mhash\*.jpg"                               "%PACK_PATH%\bin_x64\img\mhash"
+copy "%~dp0\bin\x64\Release\mhash_384.x64-sse2.exe"        "%PACK_PATH%\bin_x64"
+copy "%~dp0\bin\x64\Release_AVX\mhash_384.x64-avx.exe"     "%PACK_PATH%\bin_x64"
+
+pushd "%PACK_PATH%\bin_x64"
+"%~dp0\tools\zip.exe" -r -9 -z "%OUT_PATH_BIN_X64%" "." < "%~dp0\COPYING.txt"
+popd
+
+"%~dp0\tools\cecho.exe" CYAN "\n----[ Microsoft.NET ]----\n"
+
+mkdir "%PACK_PATH%\dot_net"
+mkdir "%PACK_PATH%\dot_net\img"
+mkdir "%PACK_PATH%\dot_net\img\mhash"
+
+copy "%~dp0\COPYING.txt"                                                           "%PACK_PATH%\dot_net"
+copy "%~dp0\README.html"                                                           "%PACK_PATH%\dot_net"
+copy "%~dp0\img\mhash\*.jpg"                                                       "%PACK_PATH%\dot_net\img\mhash"
+copy "%~dp0\bindings\Microsoft.NET\library\bin\Release\MHashDotNet384.dll"         "%PACK_PATH%\dot_net"
+copy "%~dp0\bindings\Microsoft.NET\example\bin\Release\MHashDotNet384.Example.exe" "%PACK_PATH%\dot_net"
+
+pushd "%PACK_PATH%\dot_net"
+"%~dp0\tools\zip.exe" -r -9 -z "%OUT_PATH_NET_GEN%" "." < "%~dp0\COPYING.txt"
+popd
+
+"%~dp0\tools\cecho.exe" CYAN "\n----[ Java ]----\n"
+
+mkdir "%PACK_PATH%\java"
+mkdir "%PACK_PATH%\java\img"
+mkdir "%PACK_PATH%\java\img\mhash"
+
+copy "%~dp0\COPYING.txt"                                                           "%PACK_PATH%\java"
+copy "%~dp0\README.html"                                                           "%PACK_PATH%\java"
+copy "%~dp0\img\mhash\*.jpg"                                                       "%PACK_PATH%\java\img\mhash"
+copy "%~dp0\bindings\Java\library\out\MHashJava384.jar"                            "%PACK_PATH%\java"
+copy "%~dp0\bindings\Java\example\out\MHashJava384-Example.jar"                    "%PACK_PATH%\java"
+
+pushd "%PACK_PATH%\java"
+"%~dp0\tools\zip.exe" -r -9 -z "%OUT_PATH_JNI_GEN%" "." < "%~dp0\COPYING.txt"
+popd
+
+"%~dp0\tools\cecho.exe" CYAN "\n----[ Python ]----\n"
+
+mkdir "%PACK_PATH%\python"
+mkdir "%PACK_PATH%\python\img"
+mkdir "%PACK_PATH%\python\img\mhash"
+
+copy "%~dp0\COPYING.txt"                                                           "%PACK_PATH%\python"
+copy "%~dp0\README.html"                                                           "%PACK_PATH%\python"
+copy "%~dp0\img\mhash\*.jpg"                                                       "%PACK_PATH%\python\img\mhash"
+copy "%~dp0\bindings\Python\library\MHashPy384.py"                                 "%PACK_PATH%\python"
+copy "%~dp0\bindings\Python\example\MHashPy384_Example.py"                         "%PACK_PATH%\python"
+
+pushd "%PACK_PATH%\python"
+"%~dp0\tools\zip.exe" -r -9 -z "%OUT_PATH_PYC_GEN%" "." < "%~dp0\COPYING.txt"
+popd
+
+"%~dp0\tools\cecho.exe" CYAN "\n----[ Delphi ]----\n"
+
+mkdir "%PACK_PATH%\delphi"
+mkdir "%PACK_PATH%\delphi\img"
+mkdir "%PACK_PATH%\delphi\img\mhash"
+
+copy "%~dp0\COPYING.txt"                                                           "%PACK_PATH%\delphi"
+copy "%~dp0\README.html"                                                           "%PACK_PATH%\delphi"
+copy "%~dp0\img\mhash\*.jpg"                                                       "%PACK_PATH%\delphi\img\mhash"
+copy "%~dp0\bindings\Delphi\library\MHash384.pas"                                  "%PACK_PATH%\delphi"
+copy "%~dp0\bindings\Delphi\example\bin\Example.exe"                               "%PACK_PATH%\delphi"
+
+pushd "%PACK_PATH%\delphi"
+"%~dp0\tools\zip.exe" -r -9 -z "%OUT_PATH_PAS_X86%" "." < "%~dp0\COPYING.txt"
+popd
+
+"%~dp0\tools\cecho.exe" CYAN "\n----[ Source ]----\n"
+
+cd "%~dp0"
 "%GIT2_PATH%\git.exe" archive --format tar.gz -9 --verbose --output "%OUT_PATH_SRC_GEN%" HEAD
 
+"%~dp0\tools\cecho.exe" CYAN "\n----[ Clean Up ]----\n"
+
+rmdir /S /Q "%PACK_PATH%"
 
 REM ///////////////////////////////////////////////////////////////////////////
 REM // Completed