#!/usr/bin/env bash

ROOT=$(dirname `pwd`)
echo $ROOT

source ${ROOT}/scripts/default.env
cd ${ROOT}/scripts

mdc_dir=root@${MDC_SOC_A}:/opt/usr/home/mdc/${USERNAME}/${PROJECTNAME}
BuildDir=${ROOT}/build/cmake-build-${debug_or_release}-default_toolchain/clang-aos_gea-aarch64
scripts_dir=${ROOT}/scripts
src_dir=${ROOT}

# 本地临时目录
save_dir_a=${ROOT}/tmpa

if [ ! -d $save_dir_a ]; then
    mkdir $save_dir_a
else
    rm -rf $save_dir_a/*
fi

# 先拷贝到本地临时目录
#can
bash copy_one_module.sh $BuildDir/modules/can $save_dir_a $src_dir can canMsg \
    ${ROOT}/outputcfg/HostMachine/can_msg_node/CANMsgNodeProcess
#dpc_dm
bash copy_one_module.sh $BuildDir/modules/DPC/decision $save_dir_a $src_dir decision dpc_decision \
    ${ROOT}/outputcfg/HostMachine/dpc_dm/DPCDMProcess
#dpc_sm
bash copy_one_module.sh $BuildDir/modules/DPC/SM_SDK $save_dir_a $src_dir SM_SDK dpc_sm \
    ${ROOT}/outputcfg/HostMachine/dpc_sm/DPCSMProcess
#dpc_em
bash copy_one_module.sh $BuildDir/modules/DPC/dpc_em $save_dir_a $src_dir dpc_em mpc_drv_ctap_rm \
    ${ROOT}/outputcfg/HostMachine/dpc_em/DPCEMProcess
#slam
bash copy_one_module.sh $BuildDir/modules/DPC/salme_src/jac_slam $save_dir_a $src_dir salme_src SlamExe \
    ${ROOT}/outputcfg/HostMachine/slam/SLAMProcess
#dpc_trpc_lat
bash copy_one_module.sh $BuildDir/modules/DPC/TRPC_Lat_SDK $save_dir_a $src_dir TRPC_Lat_SDK dpc_trpclat \
    ${ROOT}/outputcfg/HostMachine/dpc_trpc_lat/DPCTRPCLatProcess
#dpc_trpc_long
bash copy_one_module.sh $BuildDir/modules/DPC/TRPC_Long_SDK $save_dir_a $src_dir TRPC_Long_SDK dpc_trpclong \
    ${ROOT}/outputcfg/HostMachine/dpc_trpc_long/DPCTRPCLongProcess
#dpc_ved
bash copy_one_module.sh $BuildDir/modules/DPC/VED_SDK $save_dir_a $src_dir VED_SDK dpc_ved \
    ${ROOT}/outputcfg/HostMachine/dpc_ved/DPCVEDProcess

# 拷贝一键启动脚本
mkdir ${save_dir_a}/scripts
SCRIPTS=(
    "run_all.sh"
    "kill_all.sh"
)
for f in ${SCRIPTS[@]}
do
    cp ${scripts_dir}/${f} ${save_dir_a}/scripts/${f}
done

# 拷贝到远程目录
sshpass -p Huawei12#$ scp -r -o StrictHostKeyChecking=no $save_dir_a/* $mdc_dir

# 删除本地临时目录
rm -rf $save_dir_a
