Mercurial > hg > beaglert
comparison scripts/build_project.sh @ 58:3ffafa57302c newapi
Added scripts for building on board
author | andrewm |
---|---|
date | Wed, 15 Jul 2015 15:49:00 +0100 |
parents | |
children | ad6b2767beaf |
comparison
equal
deleted
inserted
replaced
57:72726dd4f66c | 58:3ffafa57302c |
---|---|
1 #!/bin/bash | |
2 # | |
3 # This script compiles a BeagleRT project on the BeagleBone Black and | |
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. | |
6 | |
7 BBB_ADDRESS="root@192.168.7.2" | |
8 BBB_PATH="~/BeagleRT" | |
9 RUN_PROJECT=1 | |
10 | |
11 function usage | |
12 { | |
13 THIS_SCRIPT=`basename "$0"` | |
14 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-n] <directory-with-source-files>" | |
15 echo " | |
16 This script copies a directory of source files to the BeagleBone, compiles | |
17 and runs it. The BeagleRT core files should have first been copied over | |
18 using the setup_board.sh script supplied with BeagleRT. | |
19 | |
20 The source directory should contain at least one .c, .cpp or .S file. | |
21 If the argument -n is passed, the output will not be run after compiling. | |
22 The argument -b will change the local path on the BeagleBone where the | |
23 BeagleRT files are found." | |
24 } | |
25 | |
26 OPTIND=1 | |
27 | |
28 while getopts "b:nh" opt; do | |
29 case $opt in | |
30 b) BBB_PATH=$OPTARG | |
31 ;; | |
32 n) RUN_PROJECT=0 | |
33 ;; | |
34 h|\?) usage | |
35 exit 1 | |
36 esac | |
37 done | |
38 | |
39 shift $((OPTIND-1)) | |
40 | |
41 # Check that we have a directory containing at least one source file | |
42 # as an argument | |
43 if [ -z "$1" ] | |
44 then | |
45 usage | |
46 exit | |
47 fi | |
48 | |
49 C_FILES=$(find "$1" -maxdepth 1 -type f -name "*.c") | |
50 CPP_FILES=$(find "$1" -maxdepth 1 -type f -name "*.cpp") | |
51 ASM_FILES=$(find "$1" -maxdepth 1 -type f -name "*.S") | |
52 | |
53 if [[ -z $C_FILES ]] && [[ -z $CPP_FILES ]] && [[ -z $ASM_FILES ]] | |
54 then | |
55 echo "Please provide a directory containing .c, .cpp or .S files." | |
56 # echo "Usage: $THIS_SCRIPT [directory-with-source-files]" | |
57 usage | |
58 exit | |
59 fi | |
60 | |
61 # Stop BeagleRT and clean out old source files | |
62 echo "Stopping BeagleRT and removing old source files..." | |
63 ssh -t -t $BBB_ADDRESS "kill -s 2 \`pidof BeagleRT\` 2>/dev/null; sleep 0.5; make sourceclean -C $BBB_PATH" | |
64 | |
65 # Copy new source files to the board | |
66 echo "Copying new source files to BeagleBone..." | |
67 scp "$1"/* "$BBB_ADDRESS:$BBB_PATH/source/" | |
68 | |
69 # Make new BeagleRT executable and run | |
70 if [ $RUN_PROJECT -eq 0 ] | |
71 then | |
72 echo "Building project..." | |
73 ssh $BBB_ADDRESS "make all -C $BBB_PATH" | |
74 else | |
75 echo "Building and running project..." | |
76 ssh $BBB_ADDRESS "make all -C $BBB_PATH ; screen -d -m $BBB_PATH/BeagleRT" | |
77 fi |