forked from intel/ipu6-camera-hal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·176 lines (148 loc) · 5.05 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/bin/bash
function check_result() {
local res=$1
local func=$2
if [ $res -eq 0 ] ; then
echo "###############" " $func OK " "#############"
else
echo "###############" " $func FAIL " "#############"
exit 1
fi
}
function parse_argument() {
export SOURCE_DIR=${PWD}
export INSTALL_DIR=${PWD}/out
export BOARD_LIST="ipu_tgl ipu_adl ipu_mtl"
export BUILD_RPM=ON
while true; do
case $1 in
-s|--source)
export SOURCE_DIR=$2
echo "$2"
shift
;;
-i|--install)
export INSTALL_DIR=$2
echo "$2"
shift
;;
--no-rpm)
export BUILD_RPM=OFF
;;
--board)
shift
export BOARD_LIST=$@
echo "$$"
break
;;
-?*)
echo "WARNING: not supported option: $1"
;;
*)
break
esac
shift
done
echo "=========================== Build Config ============================"
echo "SOURCE_DIR: $SOURCE_DIR"
echo "INSTALL_DIR: $INSTALL_DIR"
echo "BUILD_RPM: $BUILD_RPM"
echo "BOARD_LIST: $BOARD_LIST"
echo "====================================================================="
}
function print_helper() {
echo
echo "========================= Command Helper ============================"
echo "./build_release.sh -s source_dir -i install_dir --board target1 targert2 ..."
echo "====================================================================="
echo
}
standardize_pkg_config_path(){
if [[ ! -f $1 ]]; then echo "file $1 not exsist."; exit 0; fi
sed -i '1c prefix=\/usr' $*
}
function build_target() {
rm -fr build && mkdir -p build && cd build
local target=$1
export IPU_VERSION=
if [ "$target" = "ipu_tgl" ]; then
IPU_VERSION=ipu6
elif [ "$target" = "ipu_adl" ]; then
IPU_VERSION=ipu6ep
elif [ "$target" = "ipu_mtl" ]; then
IPU_VERSION=ipu6epmtl
else
echo "Error: unsupport the target name : $target"
exit -1
fi
# indicate the install folder of binary package
# export PKG_CONFIG_PATH=~/work/linux/camera_submit/camera/out/install/lib/$target/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/lib/$target/pkgconfig:$PKG_CONFIG_PATH
command cmake -DCMAKE_BUILD_TYPE=Release \
-DIPU_VER=$IPU_VERSION \
-DBUILD_CAMHAL_TESTS=OFF \
-DUSE_PG_LITE_PIPE=ON \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR/install \
-DCMAKE_INSTALL_SUB_PATH=$target ..
# make and install
make -j`nproc`
check_result $? "$FUNCNAME: $target"
make install
check_result $? "$FUNCNAME: $target"
standardize_pkg_config_path ${INSTALL_DIR}/install/usr/lib/${target}/pkgconfig/libcamhal.pc
cd ..
}
function build_hal() {
cd $SOURCE_DIR/ipu6-camera-hal
for target in $BOARD_LIST
do
build_target $target
done
}
function build_hal_adaptor() {
cd $SOURCE_DIR/ipu6-camera-hal/src/hal/hal_adaptor
rm -fr build && mkdir -p build && cd build
command cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR/install ../
# make and install
make -j
check_result $? $FUNCNAME
make install
check_result $? $FUNCNAME
standardize_pkg_config_path ${INSTALL_DIR}/install/lib/pkgconfig/hal_adaptor.pc
}
function build_icamerasrc() {
cd $SOURCE_DIR/icamerasrc/
export CAMHAL_LIBS="-L$INSTALL_DIR/install/lib -lhal_adaptor"
export CAMHAL_CFLAGS="-I$INSTALL_DIR/install/include/hal_adaptor \
-I$INSTALL_DIR/install/include/hal_adaptor/api \
-I$INSTALL_DIR/install/include/hal_adaptor/utils \
-I$INSTALL_DIR/install/include/hal_adaptor/linux"
export CHROME_SLIM_CAMHAL=ON
export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:${PKG_CONFIG_PATH}"
rm -fr config.h.in autom4te.cache/ aclocal.m4 *-libtool config.guess compile \
config.sub configure depcomp install-sh ltmain.sh m4
autoreconf --install
CFLAGS="-O2" CXXFLAGS="-O2" ./configure --with-haladaptor=yes ${CONFIGURE_FLAGS} \
--prefix=$INSTALL_DIR/install DEFAULT_CAMERA=0
check_result $? $FUNCNAME
make clean
make -j
check_result $? $FUNCNAME
make install
check_result $? $FUNCNAME
find $INSTALL_DIR/install/ -name "*.la" -exec rm -f "{}" \;
standardize_pkg_config_path ${INSTALL_DIR}/install/lib/pkgconfig/libgsticamerasrc.pc
}
function main () {
parse_argument $@
if [ -z "$SOURCE_DIR" ] || [ -z "$INSTALL_DIR" ] || [ -z "$BOARD_LIST" ]; then
print_helper
exit 1
fi
rm -fr $INSTALL_DIR/install $INSTALL_DIR/rpm && mkdir -p $INSTALL_DIR/install $INSTALL_DIR/rpm
build_hal
build_hal_adaptor
build_icamerasrc
# TODO: Generate the RPM for hal, hal_adaptor and icamerasrc together
}
main $@