-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·88 lines (73 loc) · 2.04 KB
/
build.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
#!/bin/bash
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="OTHER"
esac
echo Machine: ${machine}, Name: ${unameOut}
if [ "$machine" == "OTHER" ]; then
echo "Unsupported platform"
exit 1
fi
flags="-DNUM_CHANLS=1"
num_chanls=1
while getopts "D:N:" opt; do
case $opt in
D)
flags="${flags} -DLOGGING_LEVEL=$OPTARG"
;;
N)
flags="${flags} -DNUM_CHANLS=$OPTARG"
num_chanls=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
# create the cmake_build folder
rm -rf cmake_build
mkdir cmake_build
cd cmake_build
# run cmake and build the shared library
if [ "${machine}" == "MinGw" ]; then
cmake .. -G "MinGW Makefiles" $flags
elif [ "${machine}" == "Cygwin" ]; then
cmake .. -G "Unix Makefiles" $flags
elif [ "${machine}" == "Linux" ]; then
cmake .. -G "Unix Makefiles" $flags
fi
# Run the Python script to modify pmu_estimator.h
python3 ../scripts/process_header.py ../src/pmu_estimator.h $num_chanls
make PmuEstimatorStatic
make PmuEstimatorShared
# installing the library
cmake --install .
# create the build folder and copy the necessary files
rm -rf ../build
mkdir ../build
mkdir ../build/config
mkdir ../build/headers
if [ "${machine}" == "MinGw" ]; then
cp libpmu_estimator.a ../build
cp libpmu_estimator.dll ../build
elif [ "${machine}" == "Cygwin" ]; then
cp libpmu_estimator.a ../build
cp libpmu_estimator.dll ../build
elif [ "${machine}" == "Linux" ]; then
cp libpmu_estimator.a ../build
cp libpmu_estimator.so ../build
fi
cp ../config/config.ini ../build/config
cp ../config/m_class_config.ini ../build/config
cp ../config/p_class_config.ini ../build/config
cp ../src/pmu_estimator.h ../build/headers
cp ../src/func_stubs.h ../build/headers
# Run the Python script to modify pmu_estimator.h back to it's original value
python3 ../scripts/process_after_build.py ../src/pmu_estimator.h
# remove the cmake_build folder
cd ..
rm -rf cmake_build