Binary drop script. Linux. Addressed Code Review comments

This commit is contained in:
Alexey Orlov 2016-03-11 13:19:01 +01:00
Родитель cac9e50ef8
Коммит 294e370509
2 изменённых файлов: 70 добавлений и 66 удалений

1
.gitattributes поставляемый
Просмотреть файл

@ -21,6 +21,7 @@ configure text eol=lf
generate_build_info text eol=lf generate_build_info text eol=lf
run-test text eol=lf run-test text eol=lf
run-test-common text eol=lf run-test-common text eol=lf
make_binary_drop_linux text eol=lf
Makefile text Makefile text
*.sln text *.sln text

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

@ -16,64 +16,69 @@ verbose=false
# Process Command line parameters # Process Command line parameters
usage="Usage: make_binary_drop_linux -b build_configuration -t target_configuration [-v]\n-v Verbose output\nExample: make_binary_drop_linux -b Release -t gpu -v" usage="Usage: make_binary_drop_linux -b build_configuration -t target_configuration [-v] [-h]\nBuild and Target configurations should correspond to Jenkins environment\n-v Verbose output\n-h Displays this message\nExample: make_binary_drop_linux -b Release -t gpu -v"
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
echo "Command line parameters are missing" >&2 echo "Command line parameters are missing" >&2
echo -e $usage >&2
exit 1
fi
while getopts ":b::t::v" opt; do
case $opt in
b)
# Supposed to be taken from Jenkins BUILD_CONFIGURATION
buildConfig=$OPTARG
;;
t)
# Supposed to be taken from Jenkins TARGET_CONFIGURATION
targetConfig=$OPTARG
;;
v)
# Enables verbose output
verbose=true
;;
h)
# Display Usage message and exit
echo -e $usage
exit 0
;;
\?)
echo "Invalid parameter: -$OPTARG" >&2
echo -e $usage >&2 echo -e $usage >&2
exit 1 exit 1
fi ;;
:)
while getopts ":b::t::v" opt; do echo "Parameter -$OPTARG requires an argument." >&2
case $opt in echo -e $usage >&2
b) exit 1
# Supposed to be taken from Jenkins BUILD_CONFIGURATION ;;
buildConfig=$OPTARG esac
;;
t)
# Supposed to be taken from Jenkins TARGET_CONFIGURATION
targetConfig=$OPTARG
;;
v)
# Enables verbose output
verbose=true
;;
\?)
echo "Invalid parameter: -$OPTARG" >&2
echo -e $usage >&2
exit 1
;;
:)
echo "Paremeter -$OPTARG requires an argument." >&2
echo -e $usage >&2
exit 1
;;
esac
done done
# Check mandatory parameters presence # Check mandatory parameters presence
if [[ -z "$buildConfig" ]]; then if [[ -z "$buildConfig" ]]; then
echo "Parameter -b is missing." >&2 echo "Parameter -b is missing." >&2
echo -e $usage >&2 echo -e $usage >&2
exit 1 exit 1
fi fi
if [[ -z "$targetConfig" ]]; then if [[ -z "$targetConfig" ]]; then
echo "Parameter -t is missing." >&2 echo "Parameter -t is missing." >&2
echo -e $usage >&2 echo -e $usage >&2
exit 1 exit 1
fi fi
# Make buildConfig and targetConfig lowercase # Make buildConfig and targetConfig lowercase
buildConfig=$(echo $buildConfig | tr '[:upper:]' '[:lower:]') buildConfig=$(echo ${buildConfig} | tr '[:upper:]' '[:lower:]')
targetConfig=$(echo $targetConfig | tr '[:upper:]' '[:lower:]') targetConfig=$(echo ${targetConfig} | tr '[:upper:]' '[:lower:]')
# Enable "verbose" mode if needed # Enable "verbose" mode if needed
# stderr is NOT changed # stderr is NOT changed
if [[ "$verbose" == true ]]; then if [[ "$verbose" == true ]]; then
exec 3>&1 exec 3>&1
else else
exec 3>/dev/null exec 3>/dev/null
fi fi
# Define helper function # Define helper function
@ -82,22 +87,21 @@ fi
# usage: CopyFilesFromList source_path file_name_array destination_path # usage: CopyFilesFromList source_path file_name_array destination_path
function CopyFilesFromList () function CopyFilesFromList ()
{ {
declare -a fileNames=(${!2}) declare -a fileNames=(${!2})
for fileName in "${fileNames[@]}" for fileName in "${fileNames[@]}"
do do
cp "$1"/"$fileName" "$3" cp "$1/$fileName" "$3"
done done
} }
# Main script # Main script
echo "Making binary drops..." >&3 echo "Making binary drops..." >&3
# If not a Release build quit # If not a Release build quit
if [[ $buildConfig != "release" ]]; then if [[ $buildConfig != "release" ]]; then
echo "Not a release build. No binary drops generaion" >&3 echo "Not a release build. No binary drops generation" >&3
exit 0 exit 0
fi fi
# Dependency files # Dependency files
@ -106,10 +110,9 @@ fi
declare -a acmlFiles=("libacml_mp.so" "libiomp5.so") declare -a acmlFiles=("libacml_mp.so" "libiomp5.so")
# Open CV # Open CV
declare -a opencvFiles=("libopencv_core.so.3.0" "libopencv_imgproc.so.3.0" declare -a opencvFiles=("libopencv_core.so.3.0" "libopencv_imgproc.so.3.0" "libopencv_imgproc.so.3.0" "libopencv_imgcodecs.so.3.0")
"libopencv_imgproc.so.3.0" "libopencv_imgcodecs.so.3.0")
# CUDA # CUDA
declare -a cudaFiles=("libcudart.so.7.0" "libcublas.so.7.0" "libcurand.so.7.0" "libcusparse.so.7.0") declare -a cudaFiles=("libcudart.so.7.0" "libcublas.so.7.0" "libcurand.so.7.0" "libcusparse.so.7.0")
# cuDNN # cuDNN
@ -122,19 +125,19 @@ cudaPath="/usr/local/cuda/lib64"
cudnnPath="/usr/local/cudnn-4.0/cuda/lib64" cudnnPath="/usr/local/cudnn-4.0/cuda/lib64"
# Set build paths # Set build paths
buildPath="build/"$targetConfig"/release" buildPath="build/$targetConfig/release"
basePath="BinaryDrops" basePath="BinaryDrops"
baseDropPath=$basePath"/cntk" baseDropPath="$basePath/cntk"
baseBinariesPath=$baseDropPath"/cntk" baseBinariesPath="$baseDropPath/cntk"
baseDependenciesPath=$baseBinariesPath"/dependencies/lib" baseDependenciesPath="$baseBinariesPath/dependencies/lib"
extrasPath="Tools/cntk-binary-drop/linux/"$targetConfig extrasPath="Tools/cntk-binary-drop/linux/$targetConfig"
gzipFile="BinaryDrops.tar.gz" gzipFile="BinaryDrops.tar.gz"
# Make BinaryDrops directory # Make BinaryDrops directory
mkdir -p $baseBinariesPath mkdir -p $baseBinariesPath
# Copy build binaries # Copy build binaries
echo "Copying build binaries..." >&3 echo "Copying build binaries..." >&3
cp -r $buildPath/* $baseBinariesPath cp -r $buildPath/* $baseBinariesPath
# Copy Examples # Copy Examples
@ -162,13 +165,13 @@ CopyFilesFromList $opencvPath opencvFiles[@] $baseDependenciesPath
# GPU Drops only # GPU Drops only
if [[ $targetConfig != "cpu" ]]; then if [[ $targetConfig != "cpu" ]]; then
# Copy CUDA # Copy CUDA
echo "Copying CUDA..." >&3 echo "Copying CUDA..." >&3
CopyFilesFromList $cudaPath cudaFiles[@] $baseDependenciesPath CopyFilesFromList $cudaPath cudaFiles[@] $baseDependenciesPath
# Copy cuDNN # Copy cuDNN
echo "Copying cuDNN..." >&3 echo "Copying cuDNN..." >&3
CopyFilesFromList $cudnnPath cudnnFiles[@] $baseDependenciesPath CopyFilesFromList $cudnnPath cudnnFiles[@] $baseDependenciesPath
fi fi
@ -176,10 +179,10 @@ echo "Making Archive and cleaning up..." >&3
# Make GZipped TAR # Make GZipped TAR
cd $basePath cd $basePath
if [[ "$verbose" == true ]]; then if [[ "$verbose" == true ]]; then
tar -cvzf $gzipFile cntk tar -cvzf $gzipFile cntk
else else
tar -czf $gzipFile cntk tar -czf $gzipFile cntk
fi fi
# Remove TAR sources # Remove TAR sources
rm -r cntk rm -r cntk