FaceAccess/resources/build.sh
2024-06-28 15:33:38 +08:00

227 lines
10 KiB
Bash
Executable File

#!/bin/bash
cross_compile=true
build_hisi=false
debug_deploy=false
TARGET_IP="172.16.103.92"
TARGET_PATH="/system/bin"
base_path=$(pwd)
libraries_root="/opt/Libraries"
if [ $base_path==/home/* ]; then
build_path=${base_path}/build
else
build_path=/tmp/build
fi
echo "build directory: $build_path"
function cmake_scan() {
if [ $cross_compile = true ]; then
toolchain_file=-DCMAKE_TOOLCHAIN_FILE=resources/cmake/toolchain.cmake
else
toolchain_file="-DCROSS_BUILD=OFF"
fi
if [ ! -d ${build_path} ]; then
mkdir ${build_path}
fi
if [ $debug_deploy = true ]; then
build_debug=-DCMAKE_BUILD_TYPE=Debug
else
build_debug=""
fi
cmake \
-G Ninja \
-S ${base_path} \
-B ${build_path} \
$build_debug \
$toolchain_file
}
function qtmoc(){
/opt/Qt/5.9.4/gcc_64/bin/moc src/qt/mainUi/mainUi.h -o src/qt/mainUi/moc_mainUi.cpp
/opt/Qt/5.9.4/gcc_64/bin/moc src/qt/utility/UiTools.h -o src/qt/utility/moc_UiTools.cpp
/opt/Qt/5.9.4/gcc_64/bin/moc src/qt/videoChatUi/CallWaittingPage.h -o src/qt/videoChatUi/moc_CallWaittingPage.cpp
/opt/Qt/5.9.4/gcc_64/bin/moc src/qt/videoChatUi/DialPadPage.h -o src/qt/videoChatUi/moc_DialPadPage.cpp
/opt/Qt/5.9.4/gcc_64/bin/moc src/qt/videoChatUi/VideoChatPage.h -o src/qt/videoChatUi/moc_VideoChatPage.cpp
/opt/Qt/5.9.4/gcc_64/bin/moc src/qt/recoUi/recoUi.h -o src/qt/recoUi/moc_recoUi.cpp
/opt/Qt/5.9.4/gcc_64/bin/moc src/qt/recoUi/recoUiRecognize.h -o src/qt/recoUi/moc_recoUiRecognize.cpp
/opt/Qt/5.9.4/gcc_64/bin/moc src/qt/utility/DndModeCountDownItem.h -o src/qt/utility/moc_DndModeCountDownItem.cpp
}
function build() {
if [ ! -f "${build_path}/CMakeCache.txt" ]; then
cmake_scan
fi
if [ $? -ne 0 ]; then
exit 1
fi
cmake \
--build ${build_path} \
--target all
if [ $? -ne 0 ]; then
exit 1
fi
if [ $cross_compile = true ]; then
deploy
fi
}
function deploy() {
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/system/lib
if [ -n "$1" ]; then
TARGET_IP=$1
fi
if [ $debug_deploy = true ]; then
TARGET_PATH="/data/sdcard"
fi
echo "deploy to target $TARGET_IP, path: ${TARGET_PATH} ..."
ssh -i resources/ssh_host_rsa_key_ok root@${TARGET_IP} "mount -o remount rw /system/"
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "killall start-app.sh; pgrep -f GateFace | xargs kill -s 9"
ssh -i resources/ssh_host_rsa_key_ok root@${TARGET_IP} "pgrep -f VoucherVerifyServer | xargs kill -s 9"
ssh -i resources/ssh_host_rsa_key_ok root@${TARGET_IP} "pgrep -f Record | xargs kill -s 9"
scp -i ~/Projects/ssh_host_rsa_key_ok ${build_path}/src/gate_face/GateFace root@${TARGET_IP}:${TARGET_PATH}
# scp -i ~/Projects/ssh_host_rsa_key_ok ${build_path}/ThirdParty/librwSrvProtocol.so root@${TARGET_IP}:/system/lib/
scp -i resources/ssh_host_rsa_key_ok ${build_path}/Tools/Record/Record root@${TARGET_IP}:/sdcard/
scp -i resources/ssh_host_rsa_key_ok ${build_path}/Tools/Record/rkmedia_audio_test root@${TARGET_IP}:/sdcard/
scp -i resources/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/mpp/rk-libs/libeasymedia.so.1.0.1 root@${TARGET_IP}:/system/lib/
ssh -i resources/ssh_host_rsa_key_ok root@${TARGET_IP} "sync"
if [ $debug_deploy != true ]; then
echo "reboot remote device."
ssh -i resources/ssh_host_rsa_key_ok root@${TARGET_IP} "reboot"
fi
}
function clean() {
if [ -d ${build_path} ]; then
rm -fr ${build_path}
fi
}
function copy_ssh() {
if [ -n "$1" ]; then
TARGET_IP=$1
fi
SSH_KEY=$(cat ~/.ssh/id_rsa.pub)
echo "ssh copy id to ${TARGET_IP} ..."
# chmod 600 ./resources/ssh_host_rsa_key_ok
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "mount -o remount rw /oem/;mount -o remount rw /system/; mount -o remount rw /"
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "if [ ! -f /usr/bin/scp ]; then cp /oem/bin/scp /usr/bin/; else echo 'scp exist'; fi"
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "echo ${SSH_KEY} >> /oem/.ssh/authorized_keys"
scp -i ~/Projects/ssh_host_rsa_key_ok /mnt/e/Documents/gdb-rk root@${TARGET_IP}:/sdcard/gdb
scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/mpp/rk-libs/libeasymedia.so.1.0.1 root@${TARGET_IP}:/usr/lib/
scp -i ~/Projects/ssh_host_rsa_key_ok /opt/toolchains/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/bin/gdbserver root@${TARGET_IP}:/sdcard
scp -i ~/Projects/ssh_host_rsa_key_ok /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/boost_1_84_0/lib/libboost_url* root@${TARGET_IP}:/system/lib
scp -i ~/Projects/ssh_host_rsa_key_ok /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/boost_1_84_0/lib/libboost_log* root@${TARGET_IP}:/system/lib
scp -i ~/Projects/ssh_host_rsa_key_ok /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/boost_1_84_0/lib/libboost_program_options* root@${TARGET_IP}:/system/lib
scp -i ~/Projects/ssh_host_rsa_key_ok /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/boost_1_84_0/lib/libboost_date_time* root@${TARGET_IP}:/system/lib
scp -i ~/Projects/ssh_host_rsa_key_ok /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/boost_1_84_0/lib/libboost_filesystem* root@${TARGET_IP}:/system/lib
scp -i ~/Projects/ssh_host_rsa_key_ok /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/boost_1_84_0/lib/libboost_thread* root@${TARGET_IP}:/system/lib
scp -i ~/Projects/ssh_host_rsa_key_ok /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/boost_1_84_0/lib/libboost_regex* root@${TARGET_IP}:/system/lib
scp -i ~/Projects/ssh_host_rsa_key_ok /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/boost_1_84_0/lib/libboost_chrono* root@${TARGET_IP}:/system/lib
scp -i ~/Projects/ssh_host_rsa_key_ok /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/boost_1_84_0/lib/libboost_atomic* root@${TARGET_IP}:/system/lib
scp -i ~/Projects/ssh_host_rsa_key_ok /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/boost_1_84_0/lib/libboost_container* root@${TARGET_IP}:/system/lib
scp -i ~/Projects/ssh_host_rsa_key_ok /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/boost_1_84_0/lib/libboost_json* root@${TARGET_IP}:/system/lib
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "sync"
}
function deploy_old(){
if [ -n "$1" ]; then
TARGET_IP=$1
fi
if [ $debug_deploy = true ]; then
TARGET_PATH="/data/sdcard"
fi
# qtmoc
# if [ $? -ne 0 ]; then
# exit 1
# fi
if [ $build_hisi = true ]; then
docker run -it --rm --user 1000:1000 -v /opt:/opt -v $(pwd):$(pwd) -w $(pwd) frp-by1.wwvvww.cn:45288/nanopb:0.3.9.3 make server_protocol
docker run -it --rm --user 1000:1000 -v /opt:/opt -v $(pwd):$(pwd) -w $(pwd) frp-by1.wwvvww.cn:45288/nanopb:0.3.9.3 make -j4
else
docker run -it --rm --user 1000:1000 -v /opt:/opt -v $(pwd):$(pwd) -w $(pwd) -e PATH="/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin:$PATH" frp-by1.wwvvww.cn:45288/nanopb:0.3.9.3 make PLATFORM=rv1109 server_protocol
make PLATFORM=rv1109 -j4
fi
if [ $? -ne 0 ]; then
exit 1
fi
echo "deply to $TARGET_IP, path $TARGET_PATH"
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "mount -o remount rw /; mount -o remount rw /system/"
if [ $build_hisi = true ]; then
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "killall start-app.sh; killall GateFace; sleep 1"
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "killall start-app.sh; killall GateFace"
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "killall start-app.sh; killall GateFace"
else
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "killall start-app.sh; killall GateFace; killall netconfig"
fi
# scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/mpp/rk-libs/libeasymedia.so.1.0.1 root@${TARGET_IP}:/usr/lib/
# scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/rkap_3a/lib/libRKAP_3A.so root@${TARGET_IP}:/system/lib/
# scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/rkap_3a/lib/libRKAP_Common.so root@${TARGET_IP}:/system/lib/
# scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/rkap_3a/lib/libRKAP_ANR.so root@${TARGET_IP}:/system/lib/
# scp -r -i ~/Projects/ssh_host_rsa_key_ok src/web/php/*.php root@${TARGET_IP}:/system/www/web/
scp -i ~/Projects/ssh_host_rsa_key_ok ./build/GateFace root@${TARGET_IP}:$TARGET_PATH
# scp -i ~/Projects/ssh_host_rsa_key_ok ./build/netconfig root@${TARGET_IP}:$TARGET_PATH
# scp -i ~/Projects/ssh_host_rsa_key_ok ./src/netlink/libRwNetlink.so root@${TARGET_IP}:/system/lib/
if [ $build_hisi = true ]; then
scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-himix200-linux/rwStageProtocol/lib/librwSrvProtocol.so root@${TARGET_IP}:/system/lib/
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "reboot"
else
# scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/librwhscheckpw/lib/librwhscheckpw.so root@${TARGET_IP}:/system/lib/
scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/rwStageProtocol/lib/librwSrvProtocol.so root@${TARGET_IP}:/system/lib/
# scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/ffmepg/lib/libavdevice.so.58 root@${TARGET_IP}:/system/lib/
# scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/ffmepg/lib/libavfilter.so.7 root@${TARGET_IP}:/system/lib/
# scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/ffmepg/lib/libavformat.so.58 root@${TARGET_IP}:/system/lib/
# scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/ffmepg/lib/libavutil.so.56 root@${TARGET_IP}:/system/lib/
# scp -i ~/Projects/ssh_host_rsa_key_ok ./3rdparty/arm-linux-gnueabihf/ffmepg/lib/libswresample.so.3 root@${TARGET_IP}:/system/lib/
fi
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "sync"
if [ $debug_deploy = false ]; then
if [ $build_hisi = false ]; then
ssh -i ~/Projects/ssh_host_rsa_key_ok root@${TARGET_IP} "echo 1 > /dev/watchdog"
fi
fi
}
function main() {
local cmd=$1
shift 1
case $cmd in
build)
build
;;
scan)
cmake_scan
;;
clean)
clean
;;
old)
deploy_old $@
;;
ssh)
copy_ssh $@
;;
*)
build
;;
esac
}
main $@