From: Mike Frysinger Date: Mon, 31 Oct 2011 18:53:10 +0000 (-0400) Subject: more profile updates X-Git-Url: https://git.wh0rd.org/?p=home.git;a=commitdiff_plain;h=96ad5ec34909a51d53c482e1e1ccdb8b0ff2d0c1 more profile updates --- diff --git a/.bashrc b/.bashrc index 7293877..ad9468a 100644 --- a/.bashrc +++ b/.bashrc @@ -1,15 +1,13 @@ umask 0022 -for sh in ~/.profile.d/*.sh ; do +for sh in ~/.profile.d/{.pre,*}.sh ; do . "$sh" done unset sh -for p in /sbin /usr/sbin /usr/games/bin /usr/lib*/ccache /usr/lib*/ccache/*/ ~/.bin ; do - case :$PATH: in *:$p:*) continue;; esac - [ -d "${p}" ] && PATH=${p}:$PATH -done -unset p +path_prepend /sbin /usr/sbin /usr/games/bin /usr/lib*/ccache /usr/lib*/ccache/*/ ~/.bin + +. ~/.profile.d/.post.sh s=$'\001' e=$'\002' export JTAG_PROMPT=$s''$e'jtag'$s''$e'>'$s''$e' ' diff --git a/.profile.d/.post.sh b/.profile.d/.post.sh new file mode 100644 index 0000000..573a690 --- /dev/null +++ b/.profile.d/.post.sh @@ -0,0 +1 @@ +unset path_prepend path_append diff --git a/.profile.d/.pre.sh b/.profile.d/.pre.sh new file mode 100644 index 0000000..f96e3e9 --- /dev/null +++ b/.profile.d/.pre.sh @@ -0,0 +1,16 @@ +path_prepend() { + local p + for p in "$@" ; do + if [[ :${PATH}: != *:${p}:* ]] && [[ -d ${p} ]] ; then + PATH="${p}:${PATH}" + fi + done +} +path_append() { + local p + for p in "$@" ; do + if [[ :${PATH}: != *:${p}:* ]] && [[ -d ${p} ]] ; then + PATH+=":${p}" + fi + done +} diff --git a/.profile.d/ROOT-bashrc b/.profile.d/ROOT-bashrc index 771bfd3..240b10a 100644 --- a/.profile.d/ROOT-bashrc +++ b/.profile.d/ROOT-bashrc @@ -1,4 +1,4 @@ -for sh in /home/vapier/.profile.d/*.sh ; do +for sh in /home/vapier/.profile.d/{.pre,*,.post}.sh ; do . "$sh" done unset sh diff --git a/.profile.d/bfin-alias.sh b/.profile.d/bfin-alias.sh new file mode 100644 index 0000000..8c4edf8 --- /dev/null +++ b/.profile.d/bfin-alias.sh @@ -0,0 +1,232 @@ +bfin_path() { + ( + set -C + rm -f /tmp/bfin-reset-PATH.$$ + echo "${PATH}" > /tmp/bfin-reset-PATH.$$ + ) + trap "rm -f /tmp/bfin-reset-PATH.$$" EXIT + + eval $( + local p + local quiet=false use_ccache=true + [[ $1 == -q || $1 == --quiet ]] && quiet=true && shift + [[ $1 == -nc ]] && use_ccache=false && shift + if [[ -z $* ]] ; then + if [[ -d /usr/local/src/blackfin/toolchains/current ]] ; then + set -- $(eval echo /usr/local/src/blackfin/toolchains/current/{linux-uclibc,uclinux,elf}) + else + for d in /opt/uClinux /opt/uClinux-svn ; do + [ -d "$d" ] && set -- $d + done + fi + fi + if [[ $# -eq 0 ]] ; then + echo "bfin_path: unable to locate a good toolchain" 1>&2 + echo return 1 + exit 1 + elif [[ $# -eq 1 ]] ; then + p="" + local pp ppp + for pp in elf uclinux linux-uclibc ; do + if [[ -e $1/out-${pp}/bin ]] ; then + p="out-" + elif [[ -e $1/bfin-${pp}/bin ]] ; then + p="bfin-" + else + continue + fi + ppp="${ppp},${pp}" + done + set -- $(eval echo $1/${p}{${ppp:1}}/bin) + fi + echo export _BFIN_PATH=\'$*\' + for p in "$@" ; do + p=$(readlink -f ${p}) + pushd ${p} > /dev/null || return 1 + local ccache=$(type -P ccache) + ${use_ccache} || ccache="" + if [[ -n ${ccache} ]] && [[ ! -d ccache ]] ; then + if ! mkdir -p ccache >& /dev/null ; then + ( + echo "" + echo "FAIL: ccache creation with $p; please do:" + echo " sudo mkdir '${p}/ccache'" + echo " sudo chown ${USER}:users '${p}/ccache'" + ) 1>&2 + fi + fi + if [[ -n ${ccache} ]] && [[ -d ccache ]] ; then + if [[ ! -d ccache/scripts ]] ; then + mkdir -p ccache/{output,scripts,symlinks} + cd ccache + local x xx + + cat <<-EOF > scripts/.wrapper + #!/bin/bash + x=\${0##*/} + p=\${0%/*} + p=\${p%/ccache/scripts} + export CCACHE_DIR=\${p}/ccache/output + export PATH=\${p}:\${PATH} + exec \${p}/ccache/symlinks/\${x} "\$@" + EOF + chmod a+rx scripts/.wrapper + + x=$(find .. -maxdepth 1 -name '*-gcc' -printf '%P') + xx=${x%-gcc}-ccache + cat <<-EOF > scripts/${xx} + #!/bin/bash + p=\${0%/*} + p=\${p%/ccache/scripts} + export CCACHE_DIR=\${p}/ccache/output + export PATH=\${p}:\${PATH} + exec ccache "\$@" + EOF + chmod a+rx scripts/${xx} + + for x in gcc c++ g++ ; do + for xx in $(find .. -maxdepth 1 '(' -name "*-${x}" -o -name "*-${x}-*" ')' -printf '%P ') ; do + ln scripts/.wrapper scripts/${xx} + ln -fs ${ccache} symlinks/${xx} + done + done + fi + echo export UCLINUX_USE_CCACHE=no # we handle it ourself + ${quiet} || echo "Adding ${p} (w/ccache)" 1>&2 + export PATH=${PATH}:${p}/ccache/scripts:${p} + echo export PATH=\"${PATH}\" + else + ${quiet} || echo "Adding ${p} to PATH" 1>&2 + export PATH=${PATH}:${p} + echo export PATH=\"${PATH}\" + fi + popd > /dev/null + done + ) + unset -f bfin_path + + local g + for g in bfin-{{linux-uclibc,uclinux,elf}-gdb{,tui},gdbproxy,jtag} ; do + type -P ${g} >& /dev/null && alias ${g}="${g} --quiet" + type -P ${g} >& /dev/null && alias ${g}="${g} --quiet" + done + + bfin-reset() { + export PATH=$(&1 | sed -n '/^alias bfin-/{s:^alias ::;s:=.*::;p}') ; do + unalias ${g} + done + for g in $(declare 2>&1 | awk '$0 ~ /^bfin-/ { print $1 }') ; do + unset -f ${g} + done + } + + bfin-set-gcc-ver() { + local ver=$1 + if [[ -z ${ver} || -n $2 ]] ; then + echo "Usage: bfin-set-gcc-ver " + return 1 + fi + + local b bb + for b in ${_BFIN_PATH} ; do + for bb in $(echo ${b}/*-${ver}) ; do + b=${bb%-${ver}} + if [[ ! -x ${bb} ]] ; then + echo "Not found: ${bb}" + continue + fi + rm -f "${b}" + cp -a "${b}-${ver}" "${b}" + echo "${b##*/} -> ${bb##*/}" + done + done + } + + bfin-cpu-reset() { + bfin-jtag <<-EOF + cable probe + detect + bfin emulation enter + bfin reset + bfin emulation exit + quit + EOF + } + + bfin-cpu-uboot() { + local init=$1 elf=$2 + [[ -z $elf ]] && echo "Usage: bfin-cpu-uboot " && return 1 + killall -q bfin-gdbproxy + bfin-gdbproxy -q bfin --reset & + local pid=$! + sleep 3s + bfin-elf-gdb -q -batch \ + --ex "target remote localhost:2000" \ + --ex "load $init" \ + --ex c \ + --ex load \ + --ex "call memset(&_bss_start, 0, &_bss_end - &_bss_start)" \ + --ex c \ + "$elf" + kill ${pid} + } +} + +switch_svn() { + local localserv=$(