PassengerStatistics/resources/build.sh

130 lines
5.0 KiB
Bash
Raw Normal View History

2024-03-12 14:46:37 +08:00
#!/bin/bash
cross_compile=true
TARGET_IP="192.168.8.115"
TARGET_PATH="/data/sdcard/PassengerStatistics"
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/toolchain.cmake
else
toolchain_file="-DCROSS_BUILD=OFF"
fi
if [ ! -d ${build_path} ]; then
mkdir ${build_path}
fi
cmake \
-G Ninja \
-S ${base_path} \
-B ${build_path} \
$toolchain_file \
-DCMAKE_BUILD_TYPE=Debug
}
function build() {
2024-03-13 11:40:55 +08:00
if [ -n "$1" ]; then
TARGET_IP=$1
fi
2024-03-12 14:46:37 +08:00
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 init() {
if [ -n "$1" ]; then
TARGET_IP=$1
fi
echo "deploy libs to target $TARGET_IP..."
BOOST_LIBDIR=/opt/aarch64-v01c01-linux-gnu-gcc/lib/boost_1_84_0/lib
chmod 600 resources/ssh_host_rsa_key_ok
ssh -i resources/ssh_host_rsa_key_ok root@${TARGET_IP} "mount -o remount rw /;mount -o remount rw /system/"
echo "put ${base_path}/resources/authorized_keys /system/.ssh" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
echo "put /opt/aarch64-v01c01-linux-gnu-gcc/lib/gdb-10.2/bin/gdbserver /system/bin" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-13 18:01:36 +08:00
ssh -i resources/ssh_host_rsa_key_ok root@${TARGET_IP} "mkdir -p /data/sdcard/PassengerStatistics/lib"
echo "put /opt/aarch64-v01c01-linux-gnu-gcc/lib/ZLMediaKit/lib/libmk_api.so /data/sdcard/PassengerStatistics/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-23 11:57:23 +08:00
echo "put /opt/aarch64-v01c01-linux-gnu-gcc/lib/LeakTracer/libleaktracer.so /data/sdcard/PassengerStatistics/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-12 14:46:37 +08:00
# echo "put ${BOOST_LIBDIR}/libboost_date_time* /system/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-13 11:40:55 +08:00
echo "put ${BOOST_LIBDIR}/libboost_regex.so.1.84.0 /system/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-13 18:01:36 +08:00
echo "put ${BOOST_LIBDIR}/libboost_log_setup.so.1.84.0 /system/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
echo "put ${BOOST_LIBDIR}/libboost_log.so.1.84.0 /system/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-13 11:40:55 +08:00
echo "put ${BOOST_LIBDIR}/libboost_atomic.so.1.84.0 /system/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-13 18:01:36 +08:00
echo "put ${BOOST_LIBDIR}/libboost_chrono.so.1.84.0 /system/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-13 11:40:55 +08:00
echo "put ${BOOST_LIBDIR}/libboost_container.so.1.84.0 /system/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-13 18:01:36 +08:00
echo "put ${BOOST_LIBDIR}/libboost_filesystem.so.1.84.0 /system/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-13 11:40:55 +08:00
echo "put ${BOOST_LIBDIR}/libboost_thread.so.1.84.0 /system/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
echo "put ${BOOST_LIBDIR}/libboost_url.so.1.84.0 /system/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
echo "put ${BOOST_LIBDIR}/libboost_json.so.1.84.0 /system/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
echo "put ${BOOST_LIBDIR}/libboost_program_options.so.1.84.0 /system/lib" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-12 14:46:37 +08:00
ssh -i resources/ssh_host_rsa_key_ok root@${TARGET_IP} "echo 'mount -o remount rw /' >> /etc/profile"
ssh -i resources/ssh_host_rsa_key_ok root@${TARGET_IP} "echo 'mount -o remount rw /system/' >> /etc/profile"
2024-03-13 18:01:36 +08:00
ssh -i resources/ssh_host_rsa_key_ok root@${TARGET_IP} "echo 'export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/system/lib:/data/sdcard/PassengerStatistics/lib' >> /etc/profile"
2024-03-12 14:46:37 +08:00
}
function deploy() {
if [ -n "$1" ]; then
TARGET_IP=$1
fi
echo "deploy to target $TARGET_IP, path: ${TARGET_PATH} ..."
echo "put ${build_path}/Main/PassengerStatistics ${TARGET_PATH}" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
echo "put ${build_path}/Tools/VideoRecoder/VideoRecoder ${TARGET_PATH}" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-23 11:57:23 +08:00
echo "put ${build_path}/Tools/LeakTracer/LeakTracer ${TARGET_PATH}" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
2024-03-12 14:46:37 +08:00
ssh -i resources/ssh_host_rsa_key_ok root@${TARGET_IP} "sync"
}
function clean() {
if [ -d ${build_path} ]; then
rm -fr ${build_path}
fi
}
function main() {
local cmd=$1
shift 1
case $cmd in
build)
2024-03-13 11:40:55 +08:00
build $@
2024-03-12 14:46:37 +08:00
;;
scan)
cmake_scan
;;
clean)
clean
;;
deploy)
deploy $@
;;
init)
init $@
;;
*)
build
;;
esac
}
main $@