From 1f43677f895a88ae880b35f9b18cc7e6869d0ca6 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 6 Oct 2016 15:30:24 +0100 Subject: tools: intel_aubdump: pass configuration through file descriptor This makes parsing options less complicated and easier to extend. v2: Fix device id parsing (atoi -> sscanf) (Sirisha) Combine with previous commit moving init function (Sirisha) v3: Fix behavior change between bash 4.3 & 4.4 in <<< with \n characters (Lionel) Signed-off-by: Lionel Landwerlin Reviewed-by: Sirisha Gandikota --- tools/intel_aubdump.in | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'tools/intel_aubdump.in') diff --git a/tools/intel_aubdump.in b/tools/intel_aubdump.in index feee23a4..18fd03b9 100644 --- a/tools/intel_aubdump.in +++ b/tools/intel_aubdump.in @@ -21,29 +21,38 @@ EOF exit 0 } -verbose=0 -device=0 +args="" +command="" +file="" + +function add_arg() { + arg=$1 + args="$args$arg\n" +} while true; do case "$1" in -o) file=$2 + add_arg "file=${f:-$(basename ${f}).aub}" shift 2 ;; -v) - verbose=1 + add_arg "verbose=1" shift 1 ;; -o*) file=${1##-o} + add_arg "file=${file:-$(basename ${file}).aub}" shift ;; --output=*) file=${1##--output=} + add_arg "file=${file:-$(basename ${file}).aub}" shift ;; --device=*) - device=${1##--device=} + add_arg "device=${1##--device=}" shift ;; --help) @@ -66,12 +75,13 @@ done [ -z $1 ] && show_help -file=${file:-$(basename $1).aub} +[ -z $file ] && add_arg "file=intel.aub" prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ LD_PRELOAD=${libdir}/intel_aubdump.so${LD_PPRELOAD:+:${LD_PRELOAD}} \ - INTEL_AUBDUMP_ARGS="verbose=$verbose;file=$file;device=$device" \ - exec -- "$@" + exec -- "$@" 3<