forked from Xilinx/XRT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-win19.sh
140 lines (124 loc) · 3.21 KB
/
build-win19.sh
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
# Use this script within a bash shell under WSL
# No need to use Visual Studio separate shell.
# Clone workspace must be on /mnt/c
set -e
BUILDDIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
CORE=`grep -c ^processor /proc/cpuinfo`
CMAKE="/mnt/c/Program Files/CMake/bin/cmake.exe"
XRT=/mnt/c/Xilinx/xrt
BOOST=$XRT/ext
KHRONOS=$XRT/ext
BOOST=$(sed -e 's|/mnt/\([A-Za-z]\)/\(.*\)|\1:/\2|' -e 's|/|\\|g' <<< $BOOST)
KHRONOS=$(sed -e 's|/mnt/\([A-Za-z]\)/\(.*\)|\1:/\2|' -e 's|/|\\|g' <<< $KHRONOS)
usage()
{
echo "Usage: build.sh [options]"
echo
echo "[-help] List this help"
echo "[clean|-clean] Remove build directories"
echo "[-cmake] CMAKE executable (default: $CMAKE)"
echo "[-xrt] XRT root directory (default: $XRT)"
echo "[-boost] BOOST libaries root directory (default: $BOOST)"
echo "[-nocmake] Do not rerun cmake generation, just build"
echo "[-noabi] Do compile with ABI version check"
echo "[-j <n>] Compile parallel (default: system cores)"
echo "[-dbg] Build debug library (default: optimized)"
echo "[-all] Build debug and optimized library (default: optimized)"
exit 1
}
clean=0
jcore=$CORE
nocmake=0
noabi=0
dbg=0
release=1
cmake_flags="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
while [ $# -gt 0 ]; do
case "$1" in
-help)
usage
;;
clean|-clean)
clean=1
shift
;;
-cmake)
shift
CMAKE="$1"
shift
;;
-xrt)
shift
XRT="$1"
shift
;;
-dbg)
dbg=1
release=0
shift
;;
-all)
dbg=1
release=1
shift
;;
-boost)
shift
BOOST="$1"
shift
;;
-j)
shift
jcore=$1
shift
;;
-nocmake)
nocmake=1
shift
;;
-noabi)
cmake_flags+=" -DDISABLE_ABI_CHECK=1"
shift
;;
*)
echo "unknown option '$1'"
usage
;;
esac
done
here=$PWD
cd $BUILDDIR
if [[ $clean == 1 ]]; then
echo $PWD
echo "/bin/rm -rf WRelease WDebug"
/bin/rm -rf WRelease WDebug
exit 0
fi
cmake_flags+=" -DMSVC_PARALLEL_JOBS=$jcore"
cmake_flags+=" -DKHRONOS=$KHRONOS"
cmake_flags+=" -DBOOST_ROOT=$BOOST"
echo "${cmake_flags[@]}"
if [ $dbg == 1 ]; then
cmake_flags+=" -DCMAKE_BUILD_TYPE=Debug"
mkdir -p WDebug
cd WDebug
if [ $nocmake == 0 ]; then
"$CMAKE" -G "Visual Studio 16 2019" $cmake_flags ../../src
fi
"$CMAKE" --build . --verbose --config Debug
"$CMAKE" --build . --verbose --config Debug --target install
cd $BUILDDIR
fi
if [ $release == 1 ]; then
cmake_flags+=" -DCMAKE_BUILD_TYPE=Release"
mkdir -p WRelease
cd WRelease
if [ $nocmake == 0 ]; then
"$CMAKE" -G "Visual Studio 16 2019" $cmake_flags ../../src
fi
"$CMAKE" --build . --verbose --config Release
"$CMAKE" --build . --verbose --config Release --target install
cd $BUILDDIR
fi
cd $here