1 Star 0 Fork 4

saigon/plugin_modbus

forked from wasome/plugin_modbus 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build.sh 3.86 KB
一键复制 编辑 原始数据 按行查看 历史
kevin 提交于 2023-06-20 20:06 . build
#!/bin/bash
#Copyright (c) Beijing Wansheng Intelligent Corp. All rights reserved.
#Licensed under the LGPL v3.0 license.
SCRIPT=$(readlink -f "$0")
script_path=$(cd "$(dirname "$0")/" && pwd)
repo_root_dir=$script_path
platform=host
clean=
pack=
usage ()
{
echo "[options]"
echo " -h print help infomation"
echo " -c clean build"
echo " -a pack"
echo " -p [host | arm-a7] set target toolchain"
exit 1
}
while getopts "cahp:" arg
do
case $arg in
p)
platform=$OPTARG;;
a)
pack="yes";;
c)
clean="yes";;
h)
usage;;
?)
echo $arg
usage;;
esac
done
if [ -z "$WA_IOT_EDGE_SDK_REPO_DIR" ]; then
echo "WA_IOT_EDGE_SDK_REPO_DIR not set. exit.."
echo "Please first download wa-iot-edge-sdk repository using command:"
echo " git clone https://gitee.com/wasome/wa-iot-edge-sdk.git"
echo "Then set the WA_IOT_EDGE_SDK_REPO_DIR to the directory of wa-iot-edge-sdk"
exit 1
fi
if [ ! -d "$WA_IOT_EDGE_SDK_REPO_DIR" ]; then
echo "WA_IOT_EDGE_SDK_REPO_DIR=[$WA_IOT_EDGE_SDK_REPO_DIR], the path not present. exit.."
exit 1
fi
platforms_dir=$WA_IOT_EDGE_SDK_REPO_DIR/scripts/platforms
echo platforms_dir=[$platforms_dir]
if [ "$platform" != "host" ]; then
[ -f $platforms_dir/$platform/toolchain.cmake ] || echo "toolchain.cmake is not present under $platforms_dir/$platform/" || exit 1
toolchain_def="-DCMAKE_TOOLCHAIN_FILE=$platforms_dir/$platform/toolchain.cmake"
setenv_file=$platforms_dir/$platform/setenv.sh
fi
[ -n "$WA_SDK_DIR" ] || WA_SDK_DIR=$WA_IOT_EDGE_SDK_REPO_DIR/wa-iot-sdk/$platform
if [ ! -d $WA_SDK_DIR ]; then
echo "Can find sdk path for WA_SDK_DIR"
exit 1
fi
[ ! -f $WA_SDK_DIR/wa-sdk.cmake ] && echo "No wa-sdk.cmake file under WA_SDK_DIR [$WA_SDK_DIR]. exit.." && exit 1
CMAKE_WA_SDK_DIR="-DWA_SDK_DIR=$WA_SDK_DIR"
echo "WA_SDK_DIR=$WA_SDK_DIR"
if [ ! -f $repo_root_dir/deps/libmodbus/src/modbus.c ]; then
git submodule update --init --recursive
[ $? -eq 0 ] || exit $?
fi
build_dir=$script_path/out
[ -d $build_dir ] || mkdir $build_dir
cd $build_dir
cmd="cmake .. -DCMAKE_BUILD_TYPE=Debug $toolchain_def $CMAKE_WA_SDK_DIR -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$build_dir/bin"
echo $cmd
$cmd
[ $? -eq 0 ] || exit $?
make
[ $? -eq 0 ] || exit $?
echo "Great! Build successful. plugin modules generated in folder:"
echo " $build_dir/bin"
if [ "$pack" = "yes" ]; then
[ -d pack ] && rm -r pack
echo ""
echo "start to pack the plugins..."
cd $build_dir
mkdir -p $build_dir/pack/staging
mkdir -p $build_dir/pack/staging/host
cp $script_path/pack/package.info ./pack/staging
cp -r $script_path/pack/ams pack/staging/host
cp -r $script_path/pack/plugin.manifest pack/staging/host
cp $build_dir/bin/*so pack/staging/host
manifest_version=`cat pack/staging/host/plugin.manifest |grep "version" | head -n 1`
echo "manifest_version=$manifest_version"
pack_version=$(echo "$manifest_version" | awk -F '"' '{print $4}')
echo "pack_version=$pack_version"
pattern="^[0-9]+\.[0-9]+\.[0-9]+$"
if [[ $pack_version =~ $pattern ]]; then
echo "Version is valid."
else
echo "Version got from plugin.manifest is invalid."
exit 1
fi
package_file_name=$build_dir/pack/plugin_modbus_$pack_version
[ -f $package_file_name ] && rm $package_file_name
echo "packing from the folder: [$build_dir/pack/staging]"
tree $build_dir/pack/staging
cmd="python3 $WA_SDK_DIR/tools/wa_pack.py -f $build_dir/pack/staging -o $package_file_name -v $pack_version"
echo "cmd=$cmd"
$cmd
if [ -f $package_file_name.zip ]; then
echo "Successful to generate $package_file_name"
else
echo "pack failed"
fi
fi
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/saigonshu/plugin_modbus.git
git@gitee.com:saigonshu/plugin_modbus.git
saigonshu
plugin_modbus
plugin_modbus
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385