1#!/bin/bash 2 3# There are two files tx_port.h and tx_secure_interface.h that cover three architectures: M33/M55/M85 and three tools: ac6/gnu/iar. 4# These files are in threadx/ports/armv8-m/inc. 5 6set -e 7 8ports_folder="ports" 9source_folder="ports_arch/ARMv8-M/threadx" 10target_mcu="cortex_m33 cortex_m55 cortex_m85" 11source_inc_folder="$source_folder/inc" 12target_inc_mcu=$target_mcu 13target_inc_ide="ac6 gnu iar" 14target_inc_folder="inc" 15source_src_ide="ac6 gnu iar" 16target_src_mcu=$target_mcu 17src_folder="src" 18readme="readme_threadx.txt" 19cmake="CMakeLists.txt" 20source_string="Cortex-Mxx" 21target_string_pre="Cortex-M" 22 23cd $(dirname `realpath $0`)/.. 24 25# Copy port files 26for mcu in $target_mcu; 27do 28 for ide in $target_inc_ide; 29 do 30 # Copy files 31 target=$ports_folder/$mcu/$ide/$target_inc_folder 32 [ -d "$target" ] || mkdir -p $target 33 echo "$source_inc_folder -> $target" 34 rm -rf $target 35 cp -rf $source_inc_folder $target 36 37 # String replacement 38 mcu_string="$target_string_pre${mcu: -2}" 39 if [ "$ide" == "keil" ]; 40 then 41 ide_string="Keil" 42 mcu_ide_string="$mcu_string\/$ide_string" 43 else 44 ide_string="${ide^^}" 45 mcu_ide_string="$mcu_string\/$ide_string " 46 fi 47 sed -i "s/ $source_string /$mcu_ide_string/g" $target/* 48 sed -i "s/ThreadX $source_string /ThreadX $mcu_string\/$ide_string /g" $target/* 49 sed -i "s/$source_string/$mcu_string/g" $target/* 50 done 51done 52echo "" 53 54# Copy source files 55for ide in $source_src_ide; 56do 57 for mcu in $target_src_mcu; 58 do 59 # Copy source files 60 src=$source_folder/$ide/$src_folder 61 target=$ports_folder/$mcu/$ide/$src_folder 62 #[ -d "$target" ] || continue 63 echo "$src -> $target" 64 rm -rf $target 65 cp -rf $src $target 66 67 # String replacement 68 sed -i "s/$source_string/$target_string_pre${mcu: -2}/g" $target/* 69 70 # Copy readme files 71 src=$source_folder/$ide/$readme 72 target=$ports_folder/$mcu/$ide/$readme 73 #[ -f "$target" ] || continue 74 echo "$src -> $target" 75 rm -f $target 76 cp -f $src $target 77 78 # String replacement 79 sed -i "s/$source_string/$target_string_pre${mcu: -2}/g" $target 80 done 81done 82 83# Copy CMakeLists files 84for ide in $source_src_ide; 85do 86 for mcu in $target_src_mcu; 87 do 88 # Copy CMakeList files ac6 89 src=$source_folder/ac6/$cmake 90 target=$ports_folder/$mcu/ac6/$cmake 91 #[ -f "$target" ] || continue 92 echo "$src -> $target" 93 rm -f $target 94 cp -f $src $target 95 96 # Copy CMakeList files gnu 97 src=$source_folder/gnu/$cmake 98 target=$ports_folder/$mcu/gnu/$cmake 99 #[ -f "$target" ] || continue 100 echo "$src -> $target" 101 rm -f $target 102 cp -f $src $target 103 done 104done