Mercurial > hg > beaglert
changeset 203:b5d59cf94c64
Better pd_build.sh script, also wrapped in an Automator Task for MacOS
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/resources/MacOS/BelaPdBuild.app/Contents/Info.plist Fri Feb 05 23:46:11 2016 +0000 @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>AMIsApplet</key> + <true/> + <key>AMStayOpen</key> + <false/> + <key>BuildMachineOSBuild</key> + <string>15C28</string> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleDocumentTypes</key> + <array> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>*</string> + </array> + <key>CFBundleTypeName</key> + <string>Automator workflow file</string> + <key>CFBundleTypeOSTypes</key> + <array> + <string>****</string> + </array> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + </dict> + </array> + <key>CFBundleExecutable</key> + <string>Application Stub</string> + <key>CFBundleIconFile</key> + <string>AutomatorApplet</string> + <key>CFBundleIdentifier</key> + <string>com.apple.automator.BelaPdBuild</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>BelaPdBuild</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>1.2</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleSupportedPlatforms</key> + <array> + <string>MacOSX</string> + </array> + <key>CFBundleURLTypes</key> + <array/> + <key>CFBundleVersion</key> + <string>419</string> + <key>DTCompiler</key> + <string>com.apple.compilers.llvm.clang.1_0</string> + <key>DTPlatformBuild</key> + <string>7C43</string> + <key>DTPlatformVersion</key> + <string>GM</string> + <key>DTSDKBuild</key> + <string>15C28</string> + <key>DTSDKName</key> + <string>macosx10.11internal</string> + <key>DTXcode</key> + <string>0720</string> + <key>DTXcodeBuild</key> + <string>7C43</string> + <key>LSMinimumSystemVersion</key> + <string>10.5</string> + <key>LSMinimumSystemVersionByArchitecture</key> + <dict> + <key>x86_64</key> + <string>10.6</string> + </dict> + <key>LSUIElement</key> + <true/> + <key>NSAppleScriptEnabled</key> + <string>YES</string> + <key>NSMainNibFile</key> + <string>ApplicationStub</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> + <key>NSServices</key> + <array/> + <key>UTExportedTypeDeclarations</key> + <array/> + <key>UTImportedTypeDeclarations</key> + <array/> +</dict> +</plist>
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/Dutch.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/English.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/French.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/German.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/Italian.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/Japanese.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/Spanish.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/ar.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/ca.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/cs.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/da.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/el.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/es_MX.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/fi.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/he.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/hr.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/hu.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/id.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/ko.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/ms.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/no.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/pl.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/pt.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/pt_PT.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/ro.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/ru.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/sk.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/sv.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/th.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/tr.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/uk.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/vi.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/zh_CN.lproj/ApplicationStub.nib has changed
Binary file resources/MacOS/BelaPdBuild.app/Contents/Resources/zh_TW.lproj/ApplicationStub.nib has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/resources/MacOS/BelaPdBuild.app/Contents/document.wflow Fri Feb 05 23:46:11 2016 +0000 @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>AMApplicationBuild</key> + <string>419</string> + <key>AMApplicationVersion</key> + <string>2.6</string> + <key>AMDocumentVersion</key> + <string>2</string> + <key>actions</key> + <array> + <dict> + <key>action</key> + <dict> + <key>AMAccepts</key> + <dict> + <key>Container</key> + <string>List</string> + <key>Optional</key> + <true/> + <key>Types</key> + <array> + <string>com.apple.applescript.object</string> + </array> + </dict> + <key>AMActionVersion</key> + <string>1.0.2</string> + <key>AMApplication</key> + <array> + <string>Automator</string> + </array> + <key>AMParameterProperties</key> + <dict> + <key>source</key> + <dict/> + </dict> + <key>AMProvides</key> + <dict> + <key>Container</key> + <string>List</string> + <key>Types</key> + <array> + <string>com.apple.applescript.object</string> + </array> + </dict> + <key>ActionBundlePath</key> + <string>/System/Library/Automator/Run AppleScript.action</string> + <key>ActionName</key> + <string>Run AppleScript</string> + <key>ActionParameters</key> + <dict> + <key>source</key> + <string>on run {input, parameters} if input is equal to {} then display alert "Please drag a folder containing your PD patch, with all externals and auxiliary files onto this window to compile it with Heavy." else tell application "Terminal" activate do script "echo -n -e \"\\033]0;Building Heavy-Pd-Bela\\007\"; export BBB_ADDRESS=\"root@192.168.7.2\"; export BBB_SCRIPTS_PATH=\"$HOME/BeagleRT/scripts/\"; export SCRIPT_NAME=\"build_pd.sh\"; bash -c 'cd \"$BBB_SCRIPTS_PATH\"; ./\"$SCRIPT_NAME\" --watch --force --screen -i " & quoted form of (POSIX path of input) & "'; if [ $? -eq 130 ] ; then osascript -e 'tell application \"Terminal\" to close (every window whose name contains \"Building Heavy-Pd-Bela\")'; fi" end tell -- tell application "Terminal" to quit end if -- return input end run</string> + </dict> + <key>BundleIdentifier</key> + <string>com.apple.Automator.RunScript</string> + <key>CFBundleVersion</key> + <string>1.0.2</string> + <key>CanShowSelectedItemsWhenRun</key> + <false/> + <key>CanShowWhenRun</key> + <true/> + <key>Category</key> + <array> + <string>AMCategoryUtilities</string> + </array> + <key>Class Name</key> + <string>RunScriptAction</string> + <key>InputUUID</key> + <string>EF92A55A-EBA7-413C-BD41-79E5A684A273</string> + <key>Keywords</key> + <array> + <string>Run</string> + </array> + <key>OutputUUID</key> + <string>6D9DB3CD-C949-4256-847F-664D5EBC5EB9</string> + <key>UUID</key> + <string>3E1C4D48-C87F-4325-A94B-AAC1E334B30D</string> + <key>UnlocalizedApplications</key> + <array> + <string>Automator</string> + </array> + <key>arguments</key> + <dict> + <key>0</key> + <dict> + <key>default value</key> + <string>on run {input, parameters} + + (* Your script goes here *) + + return input +end run</string> + <key>name</key> + <string>source</string> + <key>required</key> + <string>0</string> + <key>type</key> + <string>0</string> + <key>uuid</key> + <string>0</string> + </dict> + </dict> + <key>conversionLabel</key> + <integer>0</integer> + <key>isViewVisible</key> + <true/> + <key>location</key> + <string>411.500000:316.000000</string> + <key>nibPath</key> + <string>/System/Library/Automator/Run AppleScript.action/Contents/Resources/Base.lproj/main.nib</string> + </dict> + <key>isViewVisible</key> + <true/> + </dict> + </array> + <key>connectors</key> + <dict/> + <key>workflowMetaData</key> + <dict> + <key>workflowTypeIdentifier</key> + <string>com.apple.Automator.application</string> + </dict> +</dict> +</plist>
--- a/scripts/build_pd.sh Fri Feb 05 18:16:34 2016 +0000 +++ b/scripts/build_pd.sh Fri Feb 05 23:46:11 2016 +0000 @@ -5,24 +5,52 @@ # # example usage: sh upload-and-compile.sh -f bwg-tests -q -e +trap "{ echo "";exit 0; }" SIGINT SIGTERM + workingdir=".." verbose="0" render="0" pdpath="" -projectpath="../projects/heavy/hvtemp" -BBB_PATH="~/BeagleRT" +WATCH="0" +FORCE="0" +#make sure the paths have the trailing / . +projectpath="../projects/heavy/hvtemp/" +BBB_PATH="~/BeagleRT/" BBB_ADDRESS="root@192.168.7.2" COMMAND_ARGS= RUN_PROJECT=1 RUN_IN_FOREGROUND=0 RUN_WITHOUT_SCREEN=1 +BELA_PYTHON27= + +if [ -z "$BELA_PYTHON27" ]; then + for PY in python python2.7 ; do + python --version 2>&1 | grep "2\.7" &> /dev/null + if [ $? -eq 0 ]; then + BELA_PYTHON27=$PY + break; + fi; + done; +fi; + +if [ -z "$BELA_PYTHON27" ]; then + echo "It looks like you might not have python2.7 installed. If you do, please specify the path + to your python2.7 executable in the environmental variable $BELA_PYTHON27" + exit 1; +fi; + function usage { - echo " - USAGE: build_pd.sh [[-i input folder containing _main.pd file ] [-o output folder for new heavy project .c files (default ../projects/heavy/hvtemp)] [-b bbb path to copy to (default ~/BeagleRT)] | [-h]] - " - echo "example: build_pd.sh -i ../projects/heavy/pd/hello-world -o ../projects/heavy/hello-world" +printf "\nUSAGE: build_pd.sh [[-i input folder containing _main.pd file ]\ + [-o output folder for new heavy project .c files (default ../projects/heavy/hvtemp)]\ + [-b bbb path to copy to (default ~/BeagleRT)] | [-h] | [-f|--force] | [-w|--watch]\n" +printf "\nexample: build_pd.sh -i ../projects/heavy/pd/hello-world -o ../projects/heavy/hello-world\n" +echo "If --watch is selected, the script will check every 1s for any file that is modified in the source folder, which triggers\ +the building process and runs the process. +If --screen is selected, the prompt returns to the user after launching BeagleRT in a screen on the target device. +If --screen and --watch are combined, while the process is running in the screen, modifications to the source files will \ +still trigger a new build." } while [ "$1" != "" ]; do @@ -30,18 +58,23 @@ -b | --bbb ) shift BBB_PATH=$1 ;; + -f | --force) FORCE="1" + ;; -i | --input ) shift pdpath=$1 ;; -o | --output ) shift projectpath=$1 ;; - -v | --verbose ) shift - verbose=1 + -v | --verbose ) verbose=1 ;; -r | --render ) shift render=1 ;; + -s | --screen ) RUN_WITHOUT_SCREEN="0" + ;; + -w | --watch ) WATCH=1 + ;; -h | --help ) usage exit ;; @@ -51,69 +84,126 @@ shift done -# remove old static files to avoid obsolete errors -rm "$projectpath"/Hv* "$projectpath"/Message* "$projectpath"/Control* "$projectpath"/Signal* &>/dev/null +function hasNotChanged(){ + if [ $WATCH -eq 0 ]; + then + echo "Files in the source folder changed since the last build, use --force to force recompiling"; + exit 0; + fi; +} -/usr/bin/python hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"/; -if [ $? -ne 0 ]; then - /usr/local/bin/python hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"/; +function checkChanged(){ + PD_BACKUP_PATH="hvresources/patch_back/" + if [ $FORCE -eq 1 ] && [ $WATCH -eq 0 ]; + then + rm -rf $PD_BACKUP_PATH; + return; + fi; + mkdir -p $PD_BACKUP_PATH; + # count files that have changed + HAS_CHANGED=$(rsync -nac --out-format="%f" "$pdpath" $PD_BACKUP_PATH | grep -v "\/\.$"| wc -l); + if [ $HAS_CHANGED -eq 0 ] && [ $FORCE -eq 0 ]; + then + hasNotChanged; + return 1; + fi; + #if we are here and $FORCE==1, it means that $WATCH==1 + # so let's make sure only the first run get forced: + FORCE=0; + echo "Files have changed" + # otherwise back up the files that have changed + rsync -vac "$pdpath" $PD_BACKUP_PATH + + return 0; +} + +function checkUploadBuildRun(){ + checkChanged || return # exits if source files have not changed + + # remove old static files to avoid obsolete errors + # use -rf to prevent warnings in case they do not exist + rm -rf "$projectpath"/Hv* "$projectpath"/Message* "$projectpath"/Control* "$projectpath"/Signal* &>/dev/null + + # invoke the online compiler + "$BELA_PYTHON27" hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"; if [ $? -ne 0 ]; then - #echo "ERROR: an error occurred while executing the uploader.py script" - echo "error" - exit 1 + #echo "ERROR: an error occurred while executing the uploader.py script" + echo "error" + exit 1 fi; -fi; -echo ""; -#echo "*|*|* Successfully uploaded and converted pd patch into super-fast optimized C code. Brought to you by Heavy! *|*|*"; -echo ""; -# check how to copy/sync render.cpp file... -if [ $render -eq 0 ]; then + echo ""; + #echo "*|*|* Successfully uploaded and converted pd patch into super-fast optimized C code. Brought to you by Heavy! *|*|*"; + echo ""; + + # check how to copy/sync render.cpp file... + if [ $render -eq 0 ]; then cp "hvresources/render.cpp" $projectpath/; -fi; + fi; -cp "hvresources/HvUtils.h" $projectpath/; + cp "hvresources/HvUtils.h" $projectpath/; -echo "updating files on board..." + echo "updating files on board..." -rsync -c -r --exclude 'HvContext*' "$projectpath"/ "$BBB_ADDRESS":"$BBB_PATH"/source; + rsync -c -rv --exclude 'HvContext*' "$projectpath"/ "$BBB_ADDRESS":"$BBB_PATH"/source; + # rsync -c -rv "$projectpath"/ "$BBB_ADDRESS":"$BBB_PATH"/source; -scp "$projectpath"/HvContext* "$BBB_ADDRESS":"$BBB_PATH"/source; + # for whatever reason these big files used to hang when transferring with rsync + scp "$projectpath"/HvContext* "$BBB_ADDRESS":"$BBB_PATH"/source; -if [ $? -ne 0 ]; then + if [ $? -ne 0 ]; then echo ""; echo ":( :( :( ERROR: while synchronizing files with the BBB. Is the board connected and the correct SD card inserted? :( :( :("; echo ""; exit 1; + fi; + # exit + #produce a list of files which content has changed (not just the date) + #TODO: could be made faster (perhaps) by backing up the folder locally instead of bbb + # UPDATED_FILES=`rsync -naic --log-format="%f" "$projectpath" "$BBB_PATH"/source | grep -v "\.$"` + # echo "UPDATEDFILES : $UPDATED_FILES" + # exit 2 + # remove old executable and heavy context .o/.d files + ssh $BBB_ADDRESS "rm -rf $BBB_PATH/BeagleRT $BBB_PATH/build/source/HvContext_bbb.d $BBB_PATH/build/source/HvContext_bbb.o $BBB_PATH/build/source/render.o $BBB_PATH/build/source/render.d"; + SCREEN_NAME=BeagleRT + KILL_RUNNING_PROCESS="bash -c 'kill -s 2 \`pidof BeagleRT\` 2>/dev/null; screen -r $SCREEN_NAME -X quit 2>/dev/null; sleep 0.5; exit 0'" #always returns true + # Make new BeagleRT executable and run + # It does not look very nice that we type the same things over and over + # but that is because each line is an ssh session in its own right + if [ $RUN_PROJECT -eq 0 ] + then + echo "Building project..." + ssh $BBB_ADDRESS "make all -C $BBB_PATH" + else + echo "Building and running project..." + if [ $RUN_WITHOUT_SCREEN -eq 1 ] + then + ssh -t $BBB_ADDRESS "make all -C $BBB_PATH && $KILL_RUNNING_PROCESS && $BBB_PATH/BeagleRT $COMMAND_ARGS" + elif [ $RUN_IN_FOREGROUND -eq 1 ] + then + # Run in screen without detaching + ssh -t $BBB_ADDRESS "make all -C $BBB_PATH && $KILL_RUNNING_PROCESS && screen -S $SCREEN_NAME $BBB_PATH/BeagleRT $COMMAND_ARGS" + else + # Run in screen and detach + ssh $BBB_ADDRESS "make all -C $BBB_PATH && $KILL_RUNNING_PROCESS && screen -dmS $SCREEN_NAME $BBB_PATH/BeagleRT $COMMAND_ARGS" + fi + fi +} #checkUploadBuildRun + +checkUploadBuildRun + +if [ $WATCH -ne 0 ]; then + WAIT_STRING="\rWaiting for changes in $pdpath" + while true; do + printf "$WAIT_STRING " + sleep 0.3 + printf "$WAIT_STRING. " + sleep 0.3 + printf "$WAIT_STRING.. " + sleep 0.3 + printf "$WAIT_STRING..." + sleep 0.3 + checkUploadBuildRun + done; fi; - -# remove old executable and heavy context .o/.d files -ssh $BBB_ADDRESS "rm $BBB_PATH/BeagleRT $BBB_PATH/build/source/HvContext_bbb.d $BBB_PATH/build/source/HvContext_bbb.o $BBB_PATH/build/source/render.o $BBB_PATH/build/source/render.d"; - -# Make new BeagleRT executable and run -if [ $RUN_PROJECT -eq 0 ] -then - echo "Building project..." - ssh $BBB_ADDRESS "make all -C $BBB_PATH" -else - echo "Building and running project..." - - if [ $RUN_WITHOUT_SCREEN -ne 0 ] - then - ssh -t $BBB_ADDRESS "make all -C $BBB_PATH && $BBB_PATH/BeagleRT $COMMAND_ARGS" - elif [ $RUN_IN_FOREGROUND -eq 0 ] - then - ssh $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS" - else - ssh -t $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT $BBB_PATH/BeagleRT $COMMAND_ARGS" - fi -fi - - - - - - - - #ssh -t root@192.168.7.2 "kill -s 2 \`pidof heavy_template\` 2>/dev/null; sleep 0.5; rm -f ~/$filename_bbb/Release/source/heavy/HvContext_bbb.? ~/$filename_bbb/Release/heavy_template && make all -C ~/$filename_bbb/Release" &>/dev/null