comparison scripts/build_project.sh @ 266:156191dffa8c prerelease

build_projecy.sh: copy files by default to projects/scriptUploadedProject, uses new Makefile
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 17 May 2016 14:07:01 +0100
parents 60ccd1fe5a58
children 428f13c2cb49
comparison
equal deleted inserted replaced
265:4989afa8e994 266:156191dffa8c
4 # optionally runs it. Pass a directory path in the first argument. 4 # optionally runs it. Pass a directory path in the first argument.
5 # The source files in this directory are copied to the board and compiled. 5 # The source files in this directory are copied to the board and compiled.
6 6
7 # set defaults unless variables are already set 7 # set defaults unless variables are already set
8 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2" 8 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
9 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/" 9 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/BeagleRT/"
10 [ -z "$BBB_SCREEN_NAME" ] && BBB_SCREEN_NAME="BeagleRT"
10 [ -z "$RUN_PROJECT" ] && RUN_PROJECT=1 11 [ -z "$RUN_PROJECT" ] && RUN_PROJECT=1
11 [ -z "$COMMAND_ARGS" ] && COMMAND_ARGS= 12 [ -z "$COMMAND_ARGS" ] && COMMAND_ARGS=
12 [ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1 13 [ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1
13 [ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0 14 [ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0
14 [ -z "$SCREEN_NAME" ] && SCREEN_NAME=Bela
15 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/" 15 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/"
16 [ -x "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME="scriptUploadedProject" 16 [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME="scriptUploadedProject"
17 17
18 function usage 18 function usage
19 { 19 {
20 THIS_SCRIPT=`basename "$0"` 20 THIS_SCRIPT=`basename "$0"`
21 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-nfF] <directory-with-source-files>" 21 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-nfF] <directory-with-source-files>"
79 # echo "Usage: $THIS_SCRIPT [directory-with-source-files]" 79 # echo "Usage: $THIS_SCRIPT [directory-with-source-files]"
80 usage 80 usage
81 exit 81 exit
82 fi 82 fi
83 83
84 BBB_PROJECT_FOLDER=$BBB_PROJECT_HOME"/"$BBB_PROJECT_NAME"/"
85 BBB_NETWORK_TARGET_FOLDER=$BBB_ADDRESS:$BBB_PROJECT_FOLDER
86
84 # Stop BeagleRT and clean out old source files 87 # Stop BeagleRT and clean out old source files
85 echo "Stopping running program..." 88 echo "Stopping running program..."
86 # sets the date, stops the running process 89 # sets the date, stops the running process
87 ssh $BBB_ADDRESS "date -s '`date`' > /dev/null; screen -X -S '"$SCREEN_NAME"' quit &>/dev/null;" 90 ssh $BBB_ADDRESS "date -s '`date`' > /dev/null; mkdir -p $BBB_PROJECT_FOLDER; screen -X -S '"$BBB_SCREEN_NAME"' quit &>/dev/null;"
88 91
89 #concatenate arguments to form path. 92 #concatenate arguments to form path.
90 HOST_SOURCE_PATH= #initially empty, will be filled with input arguments 93 HOST_SOURCE_PATH= #initially empty, will be filled with input arguments
91 for i in "$@" #parse input arguments 94 for i in "$@" #parse input arguments
92 do 95 do
99 echo "Copying new source files to BeagleBone..." 102 echo "Copying new source files to BeagleBone..."
100 if [ -z `which rsync` ]; 103 if [ -z `which rsync` ];
101 then 104 then
102 #if rsync is not available, brutally clean the destination folder 105 #if rsync is not available, brutally clean the destination folder
103 #and copy over all the files again and recompile them 106 #and copy over all the files again and recompile them
104 ssh bbb "make -C $BBB_BELA_HOME sourceclean"; 107 ssh bbb "make -C $BBB_BELA_HOME sourceclean PROJECT=$BBB_PROJECT_NAME";
105 scp $HOST_SOURCE_PATH "$BBB_ADDRESS:$BBB_BELA_HOME/source/" 108 scp $HOST_SOURCE_PATH "$BBB_NETWORK_TARGET_FOLDER"
106 else 109 else
107 #rsync --delete makes sure it removes files that are not in the origin folder 110 #rsync --delete makes sure it removes files that are not in the origin folder
108 rsync -av --delete-after $HOST_SOURCE_PATH "$BBB_ADDRESS:$BBB_BELA_HOME/source/" 111 rsync -av --delete-after --exclude=build $HOST_SOURCE_PATH "$BBB_NETWORK_TARGET_FOLDER"
109 fi; 112 fi;
110 113
111 if [ $? -ne 0 ] 114 if [ $? -ne 0 ]
112 then 115 then
113 echo "Error while copying files" 116 echo "Error while copying files"
116 119
117 # Make new BeagleRT executable and run 120 # Make new BeagleRT executable and run
118 if [ $RUN_PROJECT -eq 0 ] 121 if [ $RUN_PROJECT -eq 0 ]
119 then 122 then
120 echo "Building project..." 123 echo "Building project..."
121 ssh $BBB_ADDRESS "make all -C $BBB_BELA_HOME" 124 ssh $BBB_ADDRESS "make all -C $BBB_BELA_HOME PROJECT=$BBB_PROJECT_NAME"
122 else 125 else
123 echo "Building and running project..." 126 echo "Building and running project..."
124 127
125 if [ $RUN_WITHOUT_SCREEN -ne 0 ] 128 if [ $RUN_WITHOUT_SCREEN -ne 0 ]
126 then 129 then
127 ssh -t $BBB_ADDRESS "cd $BBB_BELA_HOME && make all && cd source && ../BeagleRT $COMMAND_ARGS" 130 ssh -t $BBB_ADDRESS "cd $BBB_BELA_HOME && make all && cd source && $BBB_PROJECT_FOLDER/$BBB_PROJECT_NAME $COMMAND_ARGS"
128 elif [ $RUN_IN_FOREGROUND -eq 0 ] 131 elif [ $RUN_IN_FOREGROUND -eq 0 ]
129 then 132 then
130 ssh $BBB_ADDRESS "cd $BBB_BELA_HOME && make all && cd source && screen -S $SCREEN_NAME -d -m ../BeagleRT $COMMAND_ARGS" 133 ssh $BBB_ADDRESS "cd $BBB_BELA_HOME && make all PROJECT=$BBB_PROJECT_NAME && cd source && screen -S $BBB_SCREEN_NAME -d -m $BBB_PROJECT_FOLDER/$BBB_PROJECT_NAME $COMMAND_ARGS"
131 else 134 else
132 ssh -t $BBB_ADDRESS "cd $BBB_BELA_HOME && make all && cd source && screen -S $SCREEN_NAME ../BeagleRT $COMMAND_ARGS" 135 ssh -t $BBB_ADDRESS "cd $BBB_BELA_HOME && make all PROJECT=$BBB_PROJECT_NAME && cd source && screen -S $BBB_SCREEN_NAME $BBB_PROJECT_FOLDER/$BBB_PROJECT_NAME $COMMAND_ARGS"
133 fi 136 fi
134 fi 137 fi