fix zlib download, create parameterized batch files for protobuf and zlib compilation

This commit is contained in:
Wolfgang Manousek 2017-01-09 17:44:35 +01:00
Родитель eac7334254
Коммит 4ac873f91a
5 изменённых файлов: 245 добавлений и 114 удалений

Просмотреть файл

@ -134,8 +134,8 @@ Function main
$operation += OpBoost160VS15 -cache $localCache -targetFolder $localDir
$operation += OpCNTKMKL3 -cache $localCache -targetFolder $localDir
$operation += OpSwig3010 -cache $localCache -targetFolder $localDir
$operation += OpProtoBuf310VS15 -cache $localCache -targetFolder $localDir
$operation += OpZlibVS15 -cache $localCache -targetFolder $localDir
$operation += OpProtoBuf310VS15 -cache $localCache -targetFolder $localDir -repoDirectory $CloneDirectory
$operation += OpZlibVS15 -cache $localCache -targetFolder $localDir -repoDirectory $CloneDirectory
$operation += OpOpenCV31 -cache $localCache -targetFolder $localDir
if ($ServerLocation) {
$operation += OpProtoBuf310VS15Internal -server $ServerLocation -cache $localCache -targetFolder $localDir

Просмотреть файл

@ -0,0 +1,108 @@
@REM Copyright (c) Microsoft. All rights reserved.
@REM Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
@REM
@REM batch script to build protobuf library for CNTK
@echo off
if /I "%CMDCMDLINE%" neq ""%COMSPEC%" " (
@echo.
@echo Please execute this script from inside a regular Windows command prompt.
@echo.
exit /b 0
)
if "%1"=="" ( goto HELP )
if "%1"=="-?" ( goto HELP )
if /I "%1"=="-h" ( goto HELP )
if /I "%1"=="-help" ( goto HELP )
if "%2"=="" ( goto HELP )
if not "%3"=="" ( goto HELP )
SET SOURCEDIR=%~f1
SET TARGETDIR=%~f2
IF "%SOURCEDIR:~-1%"=="\" SET SOURCEDIR=%SOURCEDIR:~,-1%
IF "%TARGETDIR:~-1%"=="\" SET TARGETDIR=%TARGETDIR:~,-1%
if not exist "%SOURCEDIR%\build" (
@echo Error: "%SOURCEDIR%" is not a valid ProtoBuf source directory
goto FIN
)
set cmakePath=
for %%f in ("cmake.exe") do set cmakePath=%%~$PATH:f
if "%cmakePath%"=="" (
@echo Error: CMAKE.EXE not found in PATH!
goto FIN
)
SET VCDIRECTORY=%VS140COMNTOOLS%
if "%VCDIRECTORY%"=="" (
@echo Environment variable VS140COMNTOOLS not defined.
@echo Make sure Visual Studion 2015 Update 3 is installed.
goto FIN
)
IF "%VCDIRECTORY:~-1%"=="\" SET VCDIRECTORY=%VCDIRECTORY:~,-1%
if not exist "%VCDIRECTORY%\..\..\VC\vcvarsall.bat" (
echo Error: "%VCDIRECTORY%\..\..\VC\vcvarsall.bat" not found.
echo Make sure you have installed Visual Studion 2015 Update 3 correctly.
goto FIN
)
@echo.
@echo This will build Protobuf-3.1.0 using Visual Studio 2015
@echo -------------------------------------------------------
@echo The configured settings for the batch file:
@echo Visual Studio directory: %VCDIRECTORY%
@echo Protobuf source directory: %SOURCEDIR%
@echo Protobuf target directory: %TARGETDIR%
@echo.
pause
call "%VCDIRECTORY%\..\..\VC\vcvarsall.bat" amd64
pushd "%SOURCEDIR%"
cd cmake
md build && cd build
md debug && cd debug
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -DCMAKE_INSTALL_PREFIX="%TARGETDIR%" ..\..
nmake
nmake install
cd ..
md release && cd release
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -DCMAKE_INSTALL_PREFIX="%TARGETDIR%" ..\..
nmake
nmake install
cd ..
popd
setx PROTOBUF_PATH %TARGETDIR%
set PROTOBUF_PATH=%TARGETDIR%
goto FIN
:HELP
@echo.
@echo Use this script to build the Protobuf library for CNTK.
@echo The script requires two parameter
@echo Parameter 1: The complete path to the ProtoBuf source directory
@echo i.e: C:\local\src\protobuf-3.1.0
@echo Parameter 2: The target path for the created binaries
@echo i.e. C:\local\protobuf-3.1.0-vs15
@echo The sript will also set the environment variable PROTOBUF_PATH to
@echo the target directory
@echo.
goto FIN
:FIN
REM vim:set expandtab shiftwidth=2 tabstop=2:

Просмотреть файл

@ -0,0 +1,108 @@
@REM Copyright (c) Microsoft. All rights reserved.
@REM Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
@REM
@REM batch script to build image compression libraries for CNTK
@echo off
if /I "%CMDCMDLINE%" neq ""%COMSPEC%" " (
@echo.
@echo Please execute this script from inside a regular Windows command prompt.
@echo.
exit /b 0
)
if "%1"=="" ( goto HELP )
if "%1"=="-?" ( goto HELP )
if /I "%1"=="-h" ( goto HELP )
if /I "%1"=="-help" ( goto HELP )
if "%2"=="" ( goto HELP )
if "%3"=="" ( goto HELP )
if not "%4"=="" ( goto HELP )
SET LIBZIPSOURCEDIR=%~f1
set ZLIBSOURCEDIR=%~f2
SET TARGETDIR=%~f3
IF "%LIBZIPSOURCEDIR:~-1%"=="\" SET LIBZIPSOURCEDIR=%LIBZIPSOURCEDIR:~,-1%
IF "%ZLIBSOURCEDIR:~-1%"=="\" SET ZLIBSOURCEDIR=%ZLIBSOURCEDIR:~,-1%
IF "%TARGETDIR:~-1%"=="\" SET TARGETDIR=%TARGETDIR:~,-1%
if not exist "%LIBZIPSOURCEDIR%\CMakeLists.txt" (
@echo Error: "%LIBZIPSOURCEDIR%" not a valid LibZib directory
goto :FIN
)
if not exist "%ZLIBSOURCEDIR%\CMakeLists.txt" (
@echo Error: "%ZLIBSOURCEDIR%" not a valid ZLib directory
goto :FIN
)
SET VCDIRECTORY=%VS140COMNTOOLS%
if "%VCDIRECTORY%"=="" (
@echo Environment variable VS140COMNTOOLS not defined.
@echo Make sure Visual Studion 2015 Update 3 is installed.
goto FIN
)
IF "%VCDIRECTORY:~-1%"=="\" SET VCDIRECTORY=%VCDIRECTORY:~,-1%
if not exist "%VCDIRECTORY%\..\..\VC\vcvarsall.bat" (
echo Error: "%VCDIRECTORY%\..\..\VC\vcvarsall.bat" not found.
echo Make sure you have installed Visual Studion 2015 Update 3 correctly.
goto FIN
)
@SET CMAKEGEN="Visual Studio 14 2015 Win64"
@echo.
@echo This will build compression libraries for CNTK using Visual Studio 2015
@echo -----------------------------------------------------------------------
@echo The configured settings for the batch file:
@echo Visual Studio directory: %VCDIRECTORY%
@echo CMake Generator: %CMAKEGEN%
@echo LibZip source directory: %LIBZIPSOURCEDIR%
@echo Zlib source directory: %ZLIBSOURCEDIR%
@echo Zlib-VS15 target directory: %TARGETDIR%
@echo.
@pause
call "%VCDIRECTORY%\..\..\VC\vcvarsall.bat" amd64
@pushd "%ZLIBSOURCEDIR%"
@mkdir build
@cd build
@cmake .. -G%CMAKEGEN% -DCMAKE_INSTALL_PREFIX="%TARGETDIR%"
@msbuild /P:Configuration=Release INSTALL.vcxproj
@popd
@pushd "%LIBZIPSOURCEDIR%"
@md build
@cd build
@cmake .. -G%CMAKEGEN% -DCMAKE_INSTALL_PREFIX="%TARGETDIR%"
@msbuild libzip.sln /t:zip /P:Configuration=Release
@cmake -DBUILD_TYPE=Release -P cmake_install.cmake
@popd
setx ZLIB_PATH %TARGETDIR%
set ZLIB_PATH=%TARGETDIR%
goto FIN
:HELP
@echo.
@echo Use this script to build the image compression libraries for CNTK.
@echo The script requires three parameter
@echo Parameter 1: The complete path to the LibZip source directory
@echo i.e: C:\local\src\libzip-1.1.3
@echo Parameter 1: The complete path to the ZLib source directory
@echo i.e: C:\local\src\zlib-1.2.8
@echo Parameter 2: The target path for the created binaries
@echo i.e. C:\local\zlib-vs15
@echo The sript will also set the environment variable ZLIB_PATH to
@echo the target directory
@echo.
goto FIN
:FIN
REM vim:set expandtab shiftwidth=2 tabstop=2:

Просмотреть файл

@ -523,11 +523,12 @@ function CreateBuildProtobufBatch(
$filename = $table["FileName"]
$sourceDir = $table["SourceDir"]
$targetDir = $table["TargetDir"]
$repoDirectory = $table["repoDirectory"]
if ($Execute) {
Remove-Item -Path $filename -ErrorAction SilentlyContinue | Out-Null
$batchScript = GetBatchBuildProtoBuf $sourceDir $targetDir
$batchScript = GetBatchBuildProtoBuf $sourceDir $targetDir $repoDirectory
add-content -Path $filename -Encoding Ascii -Value $batchScript
}
@ -543,11 +544,12 @@ function CreateBuildZlibBatch(
$zlibSourceDir = $table["zlibSourceDir"]
$libzipSourceDir = $table["libzipSourceDir"]
$targetDir = $table["TargetDir"]
$repoDirectory = $table["repoDirectory"]
if ($Execute) {
Remove-Item -Path $filename -ErrorAction SilentlyContinue | Out-Null
$batchScript = GetBatchBuildZlibBuf $zlibSourceDir $libzipSourceDir $targetDir
$batchScript = GetBatchBuildZlibBuf $zlibSourceDir $libzipSourceDir $targetDir $repoDirectory
add-content -Path $filename -Encoding Ascii -Value $batchScript
}
@ -703,116 +705,26 @@ function CallGetCommand(
function GetBatchBuildProtoBuf(
[string] $sourceDir,
[string] $targetDir)
[string] $targetDir,
[string] $repoDirectory)
{
$batchscript = @"
@SET VCDIRECTORY=C:\Program Files (x86)\Microsoft Visual Studio 14.0
@SET SOURCEDIR=$sourceDir
@SET TARGETDIR=$targetDir
@echo.
@echo This will build Protobuf-3.1.0
@echo ------------------------------
@echo The configured settings for the batch file:
@echo Visual Studio directory: %VCDIRECTORY%
@echo Protobuf source directory: %SOURCEDIR%
@echo Protobuf target directory: %TARGETDIR%
@echo.
@echo.
@echo Please edit the batch file if this doesn't match your directory layout!
@echo.
@pause
@call "%VCDIRECTORY%\VC\vcvarsall.bat" amd64
@pushd %SOURCEDIR%
@cd cmake
@md build && cd build
@md debug && cd debug
@cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -DCMAKE_INSTALL_PREFIX="%TARGETDIR%" ..\..
@nmake
@nmake install
@cd ..
@md release && cd release
@cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -DCMAKE_INSTALL_PREFIX="%TARGETDIR%" ..\..
@nmake
@nmake install
@cd ..
@popd
setx PROTOBUF_PATH %TARGETDIR%
$batchFile = join-path $repoDirectory "Scripts\devInstall\Windows\buildProtoVS15.bat"
@"
call $batchFile $sourceDir $targetDir
"@
return $batchscript
}
function GetBatchBuildZlibBuf(
[string] $zlibSourceDir,
[string] $libzipSourceDir,
[string] $targetDir)
[string] $targetDir,
[string] $repoDirectory)
{
$batchscript = @"
@SET VCDIRECTORY=C:\Program Files (x86)\Microsoft Visual Studio 14.0
@SET LIBZIPSOURCEDIR=$libzipSourceDir
@SET ZLIBSOURCEDIR=$zlibSourceDir
@SET TARGETDIR=$targetDir
@SET CMAKEGEN="Visual Studio 14 2015 Win64"
$batchFile = join-path $repoDirectory "Scripts\devInstall\Windows\buildZlibVS15.bat"
@echo.
@echo This will build ZLib using Visual Studio 2015
@echo ---------------------------------------------
@echo The configured settings for the batch file:
@echo Visual Studio directory: %VCDIRECTORY%
@echo CMake Generator: %CMAKEGEN%
@echo LibZip source directory: %LIBZIPSOURCEDIR%
@echo Zlib source directory: %ZLIBSOURCEDIR%
@echo Zlib-VS15 target directory: %TARGETDIR%
@echo.
@echo.
@echo Please edit the batch file if this doesn't match your directory layout!
@echo.
@pause
@call "%VCDIRECTORY%\VC\vcvarsall.bat" amd64
@pushd %ZLIBSOURCEDIR%
@mkdir build
@cd build
@cmake .. -G%CMAKEGEN% -DCMAKE_INSTALL_PREFIX="%TARGETDIR%"
@msbuild /P:Configuration=Release INSTALL.vcxproj
@popd
@pushd %LIBZIPSOURCEDIR%
@md build
@cd build
@cmake .. -G%CMAKEGEN% -DCMAKE_INSTALL_PREFIX="%TARGETDIR%"
@msbuild libzip.sln /t:zip /P:Configuration=Release
@cmake -DBUILD_TYPE=Release -P cmake_install.cmake
@popd
setx ZLIB_PATH %TARGETDIR%
@"
call $batchFile $libzipSourceDir $zlibSourceDir $targetDir
"@
return $batchscript
}
function GetCygwinBashScript
{
$batchscript = @"
easy_install-2.7 pip
pip install six
pip install pytest
"@
return $batchscript
}
# vim:set expandtab shiftwidth=2 tabstop=2:

Просмотреть файл

@ -211,7 +211,8 @@ function OpOpenCV31(
function OpProtoBuf310VS15(
[parameter(Mandatory=$true)][string] $cache,
[parameter(Mandatory=$true)][string] $targetFolder)
[parameter(Mandatory=$true)][string] $targetFolder,
[parameter(Mandatory=$true)][string] $repoDirectory)
{
# unzip protobuf source in $protoSourceDir = $targetfolder\src\$prodsubdir
# create batch file to build protobuf files in $scriptDirectory = $targetFolder\script
@ -221,9 +222,10 @@ function OpProtoBuf310VS15(
$prodFile = "protobuf310.zip"
$prodName = "protobuf-3.1.0"
$prodSubDir = "protobuf-3.1.0-vs15"
$batchFile = "buildProto.cmd"
$batchFile = "buildProtoVS15.cmd"
$protoSourceDir = join-path $targetFolder "src"
$completeProtoSourceDir = join-Path $protoSourceDir $prodName
$scriptDirectory = join-path $targetFolder "script"
$targetPath = join-path $targetFolder $prodSubDir
$envVar = "PROTOBUF_PATH"
@ -232,11 +234,11 @@ function OpProtoBuf310VS15(
$downloadSize = 5648581
@( @{ShortName = "PROTO310VS15"; VerifyInfo = "Checking for $prodName in $targetPath"; ActionInfo = "Installing $prodName";
Verification = @( @{Function = "VerifyDirectory"; Path = $protoSourceDir } );
Verification = @( @{Function = "VerifyDirectory"; Path = $completeProtoSourceDir } );
Download = @( @{ Function = "Download"; Method = "WebRequest"; Source = $downloadSource; Destination = "$cache\$prodFile"; ExpectedSize = $downloadSize} );
Action = @( @{Function = "ExtractAllFromZip"; zipFileName = "$cache\$prodFile"; destination = $protoSourceDir; zipSubTree =$prodName; destinationFolder =$prodName },
Action = @( @{Function = "ExtractAllFromZip"; zipFileName = "$cache\$prodFile"; destination = $protoSourceDir; zipSubTree = $prodName; destinationFolder = $prodName },
@{Function = "MakeDirectory"; Path = $scriptDirectory },
@{Function = "CreateBuildProtobufBatch"; FileName = "$scriptDirectory\$batchFile"; SourceDir = (join-path $protoSourceDir $prodName); TargetDir = $targetPath } );
@{Function = "CreateBuildProtobufBatch"; FileName = "$scriptDirectory\$batchFile"; SourceDir = $completeProtoSourceDir; TargetDir = $targetPath; RepoDirectory = $repoDirectory } );
} )
}
@ -313,16 +315,17 @@ function OpCheckCuda8
function OpZlibVS15(
[parameter(Mandatory=$true)][string] $cache,
[parameter(Mandatory=$true)][string] $targetFolder)
[parameter(Mandatory=$true)][string] $targetFolder,
[parameter(Mandatory=$true)][string] $repoDirectory)
{
# unzip protobuf source in $protoSourceDir = $targetfolder\src\$prodsubdir
# create batch file to build protobuf files in $scriptDirectory = $targetFolder\script
# the script file can be used to create the compiled protobuf libraries in $targetPath = $targetFolder\$prodSubDir
$prodName = "zlib / libzip from source"
$zlibProdName = "zlib-1.2.10"
$zlibFilename = "zlib1210.zip"
$zlibDownloadSource = "http://zlib.net/zlib1210.zip"
$zlibProdName = "zlib-1.2.8"
$zlibFilename = "zlib128.zip"
$zlibDownloadSource= "https://netix.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib128.zip"
$downloadSizeZlib = 0
$libzipProdName = "libzip-1.1.3"
@ -348,7 +351,7 @@ function OpZlibVS15(
Action = @( @{Function = "ExtractAllFromZip"; zipFileName = "$cache\$zlibFilename"; destination = $sourceCodeDir; zipSubTree =$zlibProdName; destinationFolder =$zlibProdName },
@{Function = "ExtractAllFromTarGz"; SourceFile = "$cache\$libzipFilename"; TargzFileName = "$libzipFilename"; destination = $sourceCodeDir },
@{Function = "MakeDirectory"; Path = $scriptDirectory },
@{Function = "CreateBuildZlibBatch"; FileName = "$scriptDirectory\$batchFile"; zlibSourceDir = (join-path $sourceCodeDir $zlibProdName); libzipSourceDir = (join-path $sourceCodeDir $libzipProdName); TargetDir = $targetPath } );
@{Function = "CreateBuildZlibBatch"; FileName = "$scriptDirectory\$batchFile"; zlibSourceDir = (join-path $sourceCodeDir $zlibProdName); libzipSourceDir = (join-path $sourceCodeDir $libzipProdName); TargetDir = $targetPath; RepoDirectory = $repoDirectory } );
} )
}