1#!/bin/bash 2 3# There is only one tx_port.h file that covers three architectures: M3/M4/M7 and four tools: ac5/ac6/gnu/iar. 4# This file is in threadx/ports_module/armv7-m/inc. We are going to ignore GHS. 5 6set -e 7 8ports_folder="ports_arch/ARMv7-M/threadx" 9ports_file_list="tx_thread_context_restore tx_thread_context_save tx_thread_interrupt_control tx_thread_interrupt_disable tx_thread_interrupt_restore tx_thread_stack_build tx_thread_system_return tx_timer_interrupt" 10ports_module_folder="ports_module" 11source_folder="ports_arch/ARMv7-M/threadx_modules" 12target_mcu="cortex_m3 cortex_m4 cortex_m7" 13source_inc_folder="$source_folder/inc" 14target_inc_folder="inc" 15target_ide="ac5 ac6 gnu iar" 16source_common_folder="common/module_manager/src" 17target_common_folder="module_manager" 18source_string="Cortex-Mx" 19target_string_pre="Cortex-M" 20 21 22cd $(dirname `realpath $0`)/.. 23 24# Copy IDE specific files 25for mcu in $target_mcu; 26do 27 for ide in $target_ide; 28 do 29 for d in $(ls $source_folder/$ide); 30 do 31 # Copy specific files 32 source=$source_folder/$ide/$d 33 target=$ports_module_folder/$mcu/$ide/$d 34 echo "$source -> $target" 35 rm -rf $target 36 cp -rf $source $target 37 38 # String replacement 39 find $target -type f -exec sed -i "s/$source_string/$target_string_pre${mcu: -1}/g" {} \; 40 done 41 42 # copy common inc directory containing unified tx_port.h 43 target=$ports_module_folder/$mcu/$ide/$target_inc_folder 44 echo "$source_inc_folder -> $target" 45 cp -rf $source_inc_folder/* $target 46 find $target -type f -exec sed -i "s/$source_string/$target_string_pre${mcu: -1}/g" {} \; 47 48 # Copy common files 49 source=$source_folder/$source_common_folder; 50 target=$ports_module_folder/$mcu/$ide/$target_common_folder 51 echo "$source -> $target" 52 cp -rf $source $target 53 54 source=$ports_folder/$ide/src; 55 echo "$source -> $target" 56 for f in $ports_file_list; 57 do 58 cp $source/$f.* $target/src 59 done 60 61 # String replacement 62 find $target -type f -exec sed -i "s/$source_string/$target_string_pre${mcu: -1}/g" {} \; 63 done 64done