forked from dotnet/machinelearning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·110 lines (97 loc) · 3.43 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·110 lines (97 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env bash
set -e
usage()
{
echo "Usage: $0 --arch <Architecture> "
echo ""
echo "Options:"
echo " --arch <Architecture> Target Architecture (x64, x86)"
echo " --configuration <Configuration> Build Configuration (Debug, Release)"
echo " --stripSymbols Enable symbol stripping (to external file)"
echo " --mkllibpath Path to mkl library."
exit 1
}
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
RootRepo="$DIR/../.."
__build_arch=
__strip_argument=
__configuration=Debug
__rootBinPath="$RootRepo/bin"
__baseIntermediateOutputPath="$__rootBinPath/obj"
__versionSourceFile="$__baseIntermediateOutputPath/version.c"
__mkllibpath=""
__mkllibrpath=""
while [ "$1" != "" ]; do
lowerI="$(echo $1 | awk '{print tolower($0)}')"
case $lowerI in
-h|--help)
usage
exit 1
;;
--arch)
shift
__build_arch=$1
;;
--configuration)
shift
__configuration=$1
;;
--mkllibpath)
shift
__mkllibpath=$1
;;
--mkllibrpath)
shift
__mkllibrpath=$1
;;
--stripsymbols)
__strip_argument="-DSTRIP_SYMBOLS=true"
;;
*)
echo "Unknown argument to build.sh $1"; usage; exit 1
esac
shift
done
__cmake_defines="-DCMAKE_BUILD_TYPE=${__configuration} ${__strip_argument} -DMKL_LIB_PATH=${__mkllibpath} -DMKL_LIB_RPATH=${__mkllibrpath}"
__IntermediatesDir="$__baseIntermediateOutputPath/$__build_arch.$__configuration/Native"
__BinDir="$__rootBinPath/$__build_arch.$__configuration/Native"
mkdir -p "$__BinDir"
mkdir -p "$__IntermediatesDir"
# Set up the environment to be used for building with clang.
if command -v "clang-3.5" > /dev/null 2>&1; then
export CC="$(command -v clang-3.5)"
export CXX="$(command -v clang++-3.5)"
elif command -v "clang-3.6" > /dev/null 2>&1; then
export CC="$(command -v clang-3.6)"
export CXX="$(command -v clang++-3.6)"
elif command -v "clang-3.9" > /dev/null 2>&1; then
export CC="$(command -v clang-3.9)"
export CXX="$(command -v clang++-3.9)"
elif command -v clang > /dev/null 2>&1; then
export CC="$(command -v clang)"
export CXX="$(command -v clang++)"
else
echo "Unable to find Clang Compiler"
echo "Install clang-3.5 or clang3.6 or clang3.9"
exit 1
fi
# Specify path to be set for CMAKE_INSTALL_PREFIX.
# This is where all built native libraries will copied to.
export __CMakeBinDir="$__BinDir"
if [ ! -f $__versionSourceFile ]; then
__versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
echo $__versionSourceLine > $__versionSourceFile
fi
__cmake_defines="${__cmake_defines} -DVERSION_FILE_PATH:STRING=${__versionSourceFile}"
cd "$__IntermediatesDir"
echo "Building Machine Learning native components from $DIR to $(pwd)"
set -x # turn on trace
cmake "$DIR" -G "Unix Makefiles" $__cmake_defines
set +x # turn off trace
make install