comparison scripts/build_project.sh @ 64:b89dd0c97a04 newapi

added Makefile, added default_main, added error checking in scripts
author Giulio Moro <giuliomoro@yahoo.it>
date Wed, 15 Jul 2015 19:59:29 +0100
parents 3ada83df91a5
children 91e1a3a220d4
comparison
equal deleted inserted replaced
63:3ada83df91a5 64:b89dd0c97a04
42 42
43 shift $((OPTIND-1)) 43 shift $((OPTIND-1))
44 44
45 # Check that we have a directory containing at least one source file 45 # Check that we have a directory containing at least one source file
46 # as an argument 46 # as an argument
47
47 if [ -z "$1" ] 48 if [ -z "$1" ]
48 then 49 then
49 usage 50 usage
50 exit 51 exit
51 fi 52 fi
52 53
53 C_FILES=$(find "$1" -maxdepth 1 -type f -name "*.c") 54 FIND_STRING="find $* -maxdepth 10000 -type f "
54 CPP_FILES=$(find "$1" -maxdepth 1 -type f -name "*.cpp") 55
55 ASM_FILES=$(find "$1" -maxdepth 1 -type f -name "*.S") 56 C_FILES=$($FIND_STRING -name "*.c")
57 CPP_FILES=$($FIND_STRING -name "*.cpp")
58 ASM_FILES=$($FIND_STRING -name "*.S")
56 59
57 if [[ -z $C_FILES ]] && [[ -z $CPP_FILES ]] && [[ -z $ASM_FILES ]] 60 if [[ -z $C_FILES ]] && [[ -z $CPP_FILES ]] && [[ -z $ASM_FILES ]]
58 then 61 then
59 echo "Please provide a directory containing .c, .cpp or .S files." 62 echo "Please provide a directory containing .c, .cpp or .S files."
60 # echo "Usage: $THIS_SCRIPT [directory-with-source-files]" 63 # echo "Usage: $THIS_SCRIPT [directory-with-source-files]"
62 exit 65 exit
63 fi 66 fi
64 67
65 # Stop BeagleRT and clean out old source files 68 # Stop BeagleRT and clean out old source files
66 echo "Stopping BeagleRT and removing old source files..." 69 echo "Stopping BeagleRT and removing old source files..."
67 ssh -t -t $BBB_ADDRESS "screen -X -S BeagleRT quit ; pkill BeagleRT ; sleep 0.5; make sourceclean -C $BBB_PATH" 70 ssh -t -t $BBB_ADDRESS "screen -X -S BeagleRT quit ; pkill BeagleRT ; make sourceclean -C $BBB_PATH"
71
72 #concatenate arguments to form path.
73 BBB_SOURCE_PATH= #initially empty, will be filled with input arguments
74 for i in "$@" #parse input arguments
75 do
76 if [ -d "$1" ] #check if the path is a folder
77 then #if it is, include all of its files
78 BBB_SOURCE_PATH+=" ${1}/* "
79 else
80 BBB_SOURCE_PATH+=" $1 "
81 fi
82 shift
83 # Copy new souce files to the board
84 done
68 85
69 # Copy new source files to the board 86 # Copy new source files to the board
70 echo "Copying new source files to BeagleBone..." 87 echo "Copying new source files to BeagleBone..."
71 scp "$1"/* "$BBB_ADDRESS:$BBB_PATH/source/" 88 scp $BBB_SOURCE_PATH "$BBB_ADDRESS:$BBB_PATH/source/"
89
90 if [ $? -ne 0 ]
91 then
92 echo "Error while copying files"
93 exit
94 fi
72 95
73 # Make new BeagleRT executable and run 96 # Make new BeagleRT executable and run
74 if [ $RUN_PROJECT -eq 0 ] 97 if [ $RUN_PROJECT -eq 0 ]
75 then 98 then
76 echo "Building project..." 99 echo "Building project..."
77 ssh $BBB_ADDRESS "make all -C $BBB_PATH" 100 ssh $BBB_ADDRESS "make all -C $BBB_PATH"
78 else 101 else
79 echo "Building and running project..." 102 echo "Building and running project..."
80 ssh $BBB_ADDRESS "make all -C $BBB_PATH ; screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS" 103 ssh $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS"
81 fi 104 fi