1 #!/bin/bash 2 # Suggested setup to use the script: 3 # (on the root of the project) 4 # $ NOCONFIGURE=1 ./autogen.sh && mkdir build && cd build 5 # $ ../configure --with-freetype --with-glib --with-gobject --with-cairo 6 # $ make -j5 && cd .. 7 # $ src/dev-run.sh [FONT-FILE] [TEXT] 8 # 9 # Or, using cmake: 10 # $ cmake -DHB_CHECK=ON -Bbuild -H. -GNinja && ninja -Cbuild 11 # $ src/dev-run.sh [FONT-FILE] [TEXT] 12 # 13 # If you want to open the result rendering using a GUI app, 14 # $ src/dev-run.sh open [FONT-FILE] [TEXT] 15 # 16 # And if you are using iTerm2, you can use the script like this, 17 # $ src/dev-run.sh img [FONT-FILE] [TEXT] 18 # 19 20 [ $# = 0 ] && echo Usage: "src/dev-run.sh [FONT-FILE] [TEXT]" && exit 21 command -v entr >/dev/null 2>&1 || { echo >&2 "This script needs `entr` be installed"; exit 1; } 22 23 24 GDB=gdb 25 # if gdb doesn't exist, hopefully lldb exist 26 command -v $GDB >/dev/null 2>&1 || export GDB="lldb" 27 28 29 [ $1 = "open" ] && openimg=1 && shift 30 OPEN=xdg-open 31 [ "$(uname)" == "Darwin" ] && OPEN=open 32 33 34 [ $1 = "img" ] && img=1 && shift 35 # http://iterm2.com/documentation-images.html 36 osc="\033]" 37 if [[ $TERM == screen* ]]; then osc="\033Ptmux;\033\033]"; fi 38 st="\a" 39 if [[ $TERM == screen* ]]; then st="\a"; fi 40 41 42 tmp=tmp.png 43 [ -f 'build/build.ninja' ] && CMAKENINJA=TRUE 44 # or "fswatch -0 . -e build/ -e .git" 45 find src/ | entr printf '\0' | while read -d ""; do 46 clear 47 yes = | head -n`tput cols` | tr -d '\n' 48 if [[ $CMAKENINJA ]]; then 49 ninja -Cbuild hb-shape hb-view && { 50 build/hb-shape $@ 51 if [ $openimg ]; then 52 build/hb-view $@ -O png -o $tmp 53 $OPEN $tmp 54 elif [ $img ]; then 55 build/hb-view $@ -O png -o $tmp 56 printf "\n${osc}1337;File=;inline=1:`cat $tmp | base64`${st}\n" 57 else 58 build/hb-view $@ 59 fi 60 } 61 else 62 make -Cbuild/src -j5 -s lib && { 63 build/util/hb-shape $@ 64 if [ $openimg ]; then 65 build/util/hb-view $@ -O png -o $tmp 66 $OPEN $tmp 67 elif [ $img ]; then 68 build/util/hb-view $@ -O png -o $tmp 69 printf "\n${osc}1337;File=;inline=1:`cat $tmp | base64`${st}\n" 70 else 71 build/util/hb-view $@ 72 fi 73 } 74 fi 75 done 76 77 read -n 1 -p "[C]heck, [D]ebug, [R]estart, [Q]uit? " answer 78 case "$answer" in 79 c|C ) 80 if [[ $CMAKENINJA ]]; then 81 CTEST_OUTPUT_ON_FAILURE=1 CTEST_PARALLEL_LEVEL=5 ninja -Cbuild test 82 else 83 make -Cbuild -j5 check && .ci/fail.sh 84 fi 85 ;; 86 d|D ) 87 if [[ $CMAKENINJA ]]; then 88 echo "Not supported on cmake builds yet" 89 else 90 build/libtool --mode=execute $GDB -- build/util/hb-shape $@ 91 fi 92 ;; 93 r|R ) 94 src/dev-run.sh $@ 95 ;; 96 * ) 97 exit 98 ;; 99 esac 100