From e50389c1d659ce9cd6907cb4b4e24889e3844c3b Mon Sep 17 00:00:00 2001 From: IllusionLee <1115451437@qq.com> Date: Sat, 28 Sep 2019 15:38:39 +0800 Subject: [PATCH] repair make_mac_stm32cubeide_code scripts. --- tools/make_mac_stm32cubeide_code.sh | 132 +++++++++++++++++++++------- 1 file changed, 101 insertions(+), 31 deletions(-) mode change 100644 => 100755 tools/make_mac_stm32cubeide_code.sh diff --git a/tools/make_mac_stm32cubeide_code.sh b/tools/make_mac_stm32cubeide_code.sh old mode 100644 new mode 100755 index fbb8232f..73a183eb --- a/tools/make_mac_stm32cubeide_code.sh +++ b/tools/make_mac_stm32cubeide_code.sh @@ -1,41 +1,111 @@ #!/bin/bash -declare mcu_map=(["1"]="stm32f1xx" ["2"]="stm32f4xx" ["3"]="stm32l4xx" ["4"]="stm32f7xx") -declare cortex_map=(["1"]="cortex-m3" ["2"]="cortex-m4" ["3"]="cortex-m4" ["4"]="cortex-m7") -mcu="stm32f1xx" -cortex="cortex-m3" +# 主目录 +# Main directory +TOP_FOLDER=$(cd `dirname $0`/../../; pwd) +# Git源码文件夹 +# Git source directory +TENCENTOS_FOLDER="TencentOS-tiny" +# 项目文件夹 +# Project directory +PROJECT_FOLDER="tiny" + + +# 如果 TOP_FOLDER 变量为空 则会发生不可预料的风险 +# 必须保证该变量有值 +# Unexpected risks occur if the TOP_FOLDER variable is empty +# Must ensure that the variable has a value +if [ ! -n "$TOP_FOLDER" ]; then + echo "TOP_FOLDER is Empty!" + exit 0 +fi + +# 如果 $TOP_FOLDER"/"$TENCENTOS_FOLDER 不存在 则会发生不可预料的风险 +# 必须保证拥有该文件夹 +# Unexpected risk occurs if $TOP_FOLDER"/"$TENCENTOS_FOLDER does not exist +# Must ensure that you have this folder +if [ ! -d $TOP_FOLDER"/"$TENCENTOS_FOLDER ]; then + echo "TENCENTOS_FOLDER non-existent!" + exit 0 +fi + +# 选择主控型号 +# Select the MCU model +declare MCU_MAP=( + ["1"]="stm32f1xx" + ["2"]="stm32f4xx" + ["3"]="stm32l4xx" + ["4"]="stm32f7xx" + ) +declare CORTEX_MAP=( + ["1"]="cortex-m3" + ["2"]="cortex-m4" + ["3"]="cortex-m4" + ["4"]="cortex-m7" + ) +# TODO:需要进一步优化 当前只适配了 arm-v7m +# TODO:Need to further optimize the current only fit arm-v7m +declare ARCH_MAP=( + ["1"]="arm-v7m" + ["2"]="arm-v7m" + ["3"]="arm-v7m" + ["4"]="arm-v7m" + ) + +MCU="stm32f4xx" +CORTEX="cortex-m4" +ARCH="arm-v7m" while :; do - read -p "Choose Your MCU: [1:stm32f1xx, 2:stm32f4xx, 3:stm32l4xx, 4:stm32f7xx] " n - mcu=${mcu_map[$n]} - cortex=${cortex_map[$n]} - if [ ! -z $mcu ]; then - echo "You choose: " $mcu + index=1 + for i in ${MCU_MAP[@]} + do + echo $index:${i} + let index++ + done + echo "Choose Your MCU Number: " + read n + MCU=${MCU_MAP[$n]} + CORTEX=${CORTEX_MAP[$n]} + ARCH=${ARCH_MAP[$n]} + if [ ! -z $MCU ]; then + echo "You Choose: " $MCU break fi done +# 创建项目文件夹 +# Create project directory +if [ -d "$TOP_FOLDER/$PROJECT_FOLDER" ]; then + read -p "Has project folder:"$TOP_FOLDER"/"$PROJECT_FOLDER", delete it? [yes/no] " choose + if [ "$choose" = "yes" ]; then + echo "Delete "$TOP_FOLDER"/"$PROJECT_FOLDER + rm -rf $TOP_FOLDER"/"$PROJECT_FOLDER + mkdir $TOP_FOLDER"/"$PROJECT_FOLDER + else + echo "Keep "$TOP_FOLDER"/"$PROJECT_FOLDER + fi +else + mkdir $TOP_FOLDER"/"$PROJECT_FOLDER +fi -rm -rf tiny -cp -rf TencentOS_tiny tiny -cd tiny +# 将必要的文件拷贝到项目文件夹中 +# Copy the necessary files into the project folder +REQUIRE_FOLDER=( "arch" "kernel" "osal" ) +for f in ${REQUIRE_FOLDER[@]} +do + cp -R $TOP_FOLDER"/"$TENCENTOS_FOLDER"/"$f $TOP_FOLDER"/"$PROJECT_FOLDER +done -rm -rf .git -ls | egrep -v "arch|kernel|osal|components|devices|net|platform|test" | xargs rm -rf +# 删除其他IDE的工程文件 +# Delete project files for other IDEs +find $TOP_FOLDER"/"$PROJECT_FOLDER -type d \( -name "armcc" -o -name "iccarm" \) | xargs rm -rf -find . -type d \( -name "armcc" -o -name "iccarm" \) | xargs rm -rf -cd arch/arm/arm-v7m && ls | egrep -v "$cortex|common" | xargs rm -rf && cd - - -rm -rf components/connectivity/TencentCloud_SDK/qcloud-iot-sdk-embedded-c/samples -rm -rf components/connectivity/TencentCloud_SDK/qcloud-iot-sdk-embedded-c/sdk-tests/ -rm -rf components/connectivity/TencentCloud_SDK/samples -cd components/connectivity/TencentCloud_SDK/qcloud-iot-sdk-embedded-c/src/ && ls | egrep -v "device|mqtt|sdk-impl|system|utils" | xargs rm -rf && cd - -# radio目录下的文件夹视情况而删除 -#rm -rf components/connectivity/LoraWAN/radio/sx1272/ -#rm -rf components/connectivity/LoraWAN/radio/sx1276/ -rm -rf components/connectivity/LoraWAN -rm -rf platform/vendor_bsp/ -rm -rf platform/hal/nationz/ - -cd platform/hal/st/ && ls | egrep -v "$mcu" | xargs rm -rf && cd - - -cd .. +# 删除其他架构的文件 +# TODO:需要进一步优化 当前只适配了 arm-v7m +# Delete files for other Arch +# TODO:Need to further optimize the current only fit arm-v7m +ls $TOP_FOLDER"/"$PROJECT_FOLDER"/arch/arm/$ARCH" | sed "s:^:$TOP_FOLDER/$PROJECT_FOLDER/arch/arm/$ARCH/:" | egrep -v "$CORTEX|common" | xargs rm -rf +ls $TOP_FOLDER"/"$PROJECT_FOLDER"/arch/arm" | sed "s:^:$TOP_FOLDER/$PROJECT_FOLDER/arch/arm/:" | egrep -v "$ARCH" | xargs rm -rf +# risc-v 架构将完全删除 +# The risc-v directory will be completely removed +rm -rf $TOP_FOLDER"/"$PROJECT_FOLDER"/arch/risc-v"