comparison scripts/build_project.sh @ 439:e49ae69acbe8 prerelease

Rebuilt run_pd_libpd.sh. Minor fixes, adjusted verbosity
author Giulio Moro <giuliomoro@yahoo.it>
date Sat, 18 Jun 2016 04:19:17 +0100
parents ad3f61134bb4
children a9af964ac18a
comparison
equal deleted inserted replaced
438:ad3f61134bb4 439:e49ae69acbe8
29 If the argument -n is passed, the output will not be run after compiling. 29 If the argument -n is passed, the output will not be run after compiling.
30 The -c option passes command-line arguments to 30 The -c option passes command-line arguments to
31 the Bela program; enclose the argument string in quotes. 31 the Bela program; enclose the argument string in quotes.
32 32
33 -p arg : sets the name of the project to run (default: $BBB_PROJECT_NAME ) 33 -p arg : sets the name of the project to run (default: $BBB_PROJECT_NAME )
34 34 -r arg : additional folder which contents will be copied to the destination folder. Use this, e.g.: for audio files or Pd/pyo sources
35
35 By default, the project runs in the foreground of the current terminal, 36 By default, the project runs in the foreground of the current terminal,
36 within a screen session that can be detached later. The -f argument runs 37 within a screen session that can be detached later. The -f argument runs
37 the project in the foreground of the current terminal, without screen, so 38 the project in the foreground of the current terminal, without screen, so
38 the output can be piped to another destination. The -b argument runs it 39 the output can be piped to another destination. The -b argument runs it
39 in a screen in the background, so no output is shown. The -m argument allows 40 in a screen in the background, so no output is shown. The -m argument allows
42 pre-built objects, or all the pre-built objects, respectively." 43 pre-built objects, or all the pre-built objects, respectively."
43 } 44 }
44 45
45 OPTIND=1 46 OPTIND=1
46 47
47 while getopts "bc:m:nfFhp:" opt; do 48 while getopts "bc:m:nfFhp:r:b" opt; do
48 case $opt in 49 case $opt in
49 c) COMMAND_ARGS=$OPTARG 50 c) COMMAND_ARGS=$OPTARG
50 ;; 51 ;;
51 b) RUN_IN_FOREGROUND=0 52 b) RUN_IN_FOREGROUND=0
52 ;; 53 ;;
54 ;; 55 ;;
55 n) RUN_PROJECT=0 56 n) RUN_PROJECT=0
56 ;; 57 ;;
57 p) BBB_PROJECT_NAME=$OPTARG 58 p) BBB_PROJECT_NAME=$OPTARG
58 ;; 59 ;;
60 r) ADDITIONAL_PATH=$OPTARG
61 ;;
59 m) BBB_MAKEFILE_OPTIONS=$OPTARG 62 m) BBB_MAKEFILE_OPTIONS=$OPTARG
60 ;; 63 ;;
61 h|\?) usage 64 h|\?) usage
62 exit 1 65 exit 1
63 esac 66 esac
64 done 67 done
65 68
66 shift $((OPTIND-1)) 69 shift $((OPTIND-1))
70
71 #Only include all the files if the provided path is not empty
72 [ -z "$ADDITIONAL_PATH" ] || ADDITIONAL_PATH="$ADDITIONAL_PATH/*"
67 73
68 # Check that we have a directory containing at least one source file 74 # Check that we have a directory containing at least one source file
69 # as an argument 75 # as an argument
70 76
71 if [ -z "$1" ] 77 if [ -z "$1" ]
78 84
79 C_FILES=$($FIND_STRING -name "*.c") 85 C_FILES=$($FIND_STRING -name "*.c")
80 CPP_FILES=$($FIND_STRING -name "*.cpp") 86 CPP_FILES=$($FIND_STRING -name "*.cpp")
81 ASM_FILES=$($FIND_STRING -name "*.S") 87 ASM_FILES=$($FIND_STRING -name "*.S")
82 88
83 if [ -z $C_FILES ] && [ -z $CPP_FILES ] && [ -z $ASM_FILES ] 89 if [ -z "$C_FILES" ] && [ -z "$CPP_FILES" ] && [ -z "$ASM_FILES" ]
84 then 90 then
85 echo "Please provide a directory containing .c, .cpp or .S files." 91 echo "Please provide a directory containing .c, .cpp or .S files."
86 # echo "Usage: $THIS_SCRIPT [directory-with-source-files]" 92 # echo "Usage: $THIS_SCRIPT [directory-with-source-files]"
87 usage 93 usage
88 exit 94 exit
91 BBB_PROJECT_FOLDER=$BBB_PROJECT_HOME"/"$BBB_PROJECT_NAME #make sure there is no trailing slash here 97 BBB_PROJECT_FOLDER=$BBB_PROJECT_HOME"/"$BBB_PROJECT_NAME #make sure there is no trailing slash here
92 BBB_NETWORK_TARGET_FOLDER=$BBB_ADDRESS:$BBB_PROJECT_FOLDER 98 BBB_NETWORK_TARGET_FOLDER=$BBB_ADDRESS:$BBB_PROJECT_FOLDER
93 99
94 echo "Stopping running process..." 100 echo "Stopping running process..."
95 # sets the date and stop running process 101 # sets the date and stop running process
96 ssh $BBB_ADDRESS "date -s '`date`' > /dev/null; mkdir -p $BBB_PROJECT_FOLDER; make --no-print-directory -C $BBB_BELA_HOME stop" 102 ssh $BBB_ADDRESS "date -s '`date`' > /dev/null; mkdir -p $BBB_PROJECT_FOLDER; make QUIET=true --no-print-directory -C $BBB_BELA_HOME stop"
97 103
98 #concatenate arguments to form path. 104 #concatenate arguments to form path.
99 HOST_SOURCE_PATH= #initially empty, will be filled with input arguments 105 HOST_SOURCE_PATH= #initially empty, will be filled with input arguments
100 for i in "$@" #parse input arguments 106 for i in "$@" #parse input arguments
101 do 107 do
104 # Copy new souce files to the board 110 # Copy new souce files to the board
105 done 111 done
106 112
107 # Copy new source files to the board 113 # Copy new source files to the board
108 echo "Copying new source files to BeagleBone..." 114 echo "Copying new source files to BeagleBone..."
109 if [ -z `which rsync` ]; 115 if [ -z "`which rsync`" ];
110 then 116 then
111 #if rsync is not available, brutally clean the destination folder 117 #if rsync is not available, brutally clean the destination folder
112 #and copy over all the files again and recompile them 118 #and copy over all the files again and recompile them
113 ssh bbb "make --no-print-directory -C $BBB_BELA_HOME sourceclean PROJECT=$BBB_PROJECT_NAME"; 119 ssh bbb "make --no-print-directory -C $BBB_BELA_HOME sourceclean PROJECT=$BBB_PROJECT_NAME";
114 scp $HOST_SOURCE_PATH "$BBB_NETWORK_TARGET_FOLDER" 120 scp -r $HOST_SOURCE_PATH $ADDITIONAL_PATH "$BBB_NETWORK_TARGET_FOLDER"
115 else 121 else
116 #rsync 122 #rsync
117 # --delete makes sure it removes files that are not in the origin folder 123 # --delete makes sure it removes files that are not in the origin folder
118 # -c evaluates changes using md5 checksum instead of file date, so we don't care about time skews 124 # -c evaluates changes using md5 checksum instead of file date, so we don't care about time skews
119 # --no-t makes sure file timestamps are not preserved, so that the Makefile will not think that targets are up to date when replacing files on the BBB 125 # --no-t makes sure file timestamps are not preserved, so that the Makefile will not think that targets are up to date when replacing files on the BBB
120 # with older files from the host. This will solve 99% of the issues with Makefile thinking a target is up to date when it is not. 126 # with older files from the host. This will solve 99% of the issues with Makefile thinking a target is up to date when it is not.
121 127 rsync -ac --out-format=" %n" --no-t --delete-after --exclude=$BBB_PROJECT_NAME --exclude=build $HOST_SOURCE_PATH"/" $ADDITIONAL_PATH "$BBB_NETWORK_TARGET_FOLDER/" #trailing slashes used here make sure rsync does not create another folder inside the target folder
122 rsync -avc --no-t --delete-after --exclude=$BBB_PROJECT_NAME --exclude=build $HOST_SOURCE_PATH"/" "$BBB_NETWORK_TARGET_FOLDER/" #trailing slashes used here make sure rsync does not create another folder inside the target folder
123 fi; 128 fi;
124 129
125 if [ $? -ne 0 ] 130 if [ $? -ne 0 ]
126 then 131 then
127 echo "Error while copying files" 132 echo "Error while copying files"
128 exit 133 exit
129 fi 134 fi
130 135
131 # Make new Bela executable and run 136 # Make new Bela executable and run
132 MAKE_COMMAND="make --no-print-directory -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS' $BBB_MAKEFILE_OPTIONS" 137 MAKE_COMMAND="make --no-print-directory QUIET=true -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS' $BBB_MAKEFILE_OPTIONS"
133 if [ $RUN_PROJECT -eq 0 ] 138 if [ $RUN_PROJECT -eq 0 ]
134 then 139 then
135 echo "Building project..." 140 echo "Building project..."
136 ssh $BBB_ADDRESS "$MAKE_COMMAND" 141 ssh $BBB_ADDRESS "$MAKE_COMMAND"
137 else 142 else