2019-08-09 19:02:42 +03:00
#!/usr/bin/env bash
2020-02-11 22:48:49 +03:00
# Copyright (C) 2018-2020 Intel Corporation
2019-08-09 19:02:42 +03:00
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
error( ) {
local code = " ${ 3 :- 1 } "
if [ [ -n " $2 " ] ] ; then
echo " Error on or near line $1 : $2 ; exiting with status ${ code } "
else
echo " Error on or near line $1 ; exiting with status ${ code } "
fi
exit " ${ code } "
}
trap 'error ${LINENO}' ERR
SAMPLES_PATH = " $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd ) "
printf "\nSetting environment variables for building samples...\n"
if [ -z " $INTEL_OPENVINO_DIR " ] ; then
2020-02-11 22:48:49 +03:00
if [ -e " $SAMPLES_PATH /../../../bin/setupvars.sh " ] ; then
2019-08-09 19:02:42 +03:00
setvars_path = " $SAMPLES_PATH /../../../bin/setupvars.sh "
2020-02-11 22:48:49 +03:00
elif [ -e " $SAMPLES_PATH /../../../../bin/setupvars.sh " ] ; then
setvars_path = " $SAMPLES_PATH /../../../../bin/setupvars.sh "
2019-08-09 19:02:42 +03:00
else
printf "Error: Failed to set the environment variables automatically. To fix, run the following command:\n source <INSTALL_DIR>/bin/setupvars.sh\n where INSTALL_DIR is the OpenVINO installation directory.\n\n"
exit 1
fi
2020-02-11 22:48:49 +03:00
if ! source " $setvars_path " ; then
2019-08-09 19:02:42 +03:00
printf "Unable to run ./setupvars.sh. Please check its presence. \n\n"
exit 1
fi
else
# case for run with `sudo -E`
source " $INTEL_OPENVINO_DIR /bin/setupvars.sh "
fi
if ! command -v cmake & >/dev/null; then
printf "\n\nCMAKE is not installed. It is required to build Inference Engine samples. Please install it. \n\n"
exit 1
fi
2020-02-11 22:48:49 +03:00
samples_type = $( basename " $PWD " )
build_dir = " $HOME /inference_engine_ ${ samples_type } _samples_build "
2019-08-09 19:02:42 +03:00
OS_PATH = $( uname -m)
NUM_THREADS = "-j2"
2020-02-11 22:48:49 +03:00
if [ " $OS_PATH " = = "x86_64" ] ; then
2019-08-09 19:02:42 +03:00
OS_PATH = "intel64"
NUM_THREADS = "-j8"
fi
2020-02-11 22:48:49 +03:00
if [ -e " $build_dir /CMakeCache.txt " ] ; then
rm -rf " $build_dir /CMakeCache.txt "
2019-08-09 19:02:42 +03:00
fi
2020-02-11 22:48:49 +03:00
mkdir -p " $build_dir "
cd " $build_dir "
cmake -DCMAKE_BUILD_TYPE= Release " $SAMPLES_PATH "
2019-08-09 19:02:42 +03:00
make $NUM_THREADS
2020-02-11 22:48:49 +03:00
printf " \nBuild completed, you can find binaries for all samples in the $build_dir /%s/Release subfolder.\n\n " " $OS_PATH "