Added run-task and run-flow functions
This commit is contained in:
parent
cb1c7a8030
commit
bfb03af2c8
36
openfpga.sh
36
openfpga.sh
|
@ -6,7 +6,9 @@
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
|
|
||||||
export OPENFPGA_PATH="$(pwd)"
|
export OPENFPGA_PATH="$(pwd)"
|
||||||
|
export OPENFPGA_SCRIPT_PATH="$(pwd)/openfpga_flow/scripts"
|
||||||
export OPENFPGA_TASK_PATH="$(pwd)/openfpga_flow/tasks"
|
export OPENFPGA_TASK_PATH="$(pwd)/openfpga_flow/tasks"
|
||||||
|
if [ -z $PYTHON_EXEC ]; then export PYTHON_EXEC="python3"; fi
|
||||||
|
|
||||||
# This function checks the path and
|
# This function checks the path and
|
||||||
# raises warning if the command is not executing
|
# raises warning if the command is not executing
|
||||||
|
@ -17,6 +19,14 @@ check_execution_path (){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run-task () {
|
||||||
|
$PYTHON_EXEC $OPENFPGA_SCRIPT_PATH/run_fpga_task.py "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
run-flow () {
|
||||||
|
$PYTHON_EXEC $OPENFPGA_SCRIPT_PATH/run_fpga_flow.py "$@"
|
||||||
|
}
|
||||||
|
|
||||||
# lists all the configure task in task directory
|
# lists all the configure task in task directory
|
||||||
list-tasks () {
|
list-tasks () {
|
||||||
check_execution_path "$(pwd)"
|
check_execution_path "$(pwd)"
|
||||||
|
@ -35,22 +45,30 @@ goto-task () {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
goto_path=$OPENFPGA_TASK_PATH/$1
|
goto_path=$OPENFPGA_TASK_PATH/$1
|
||||||
run_num="latest"
|
run_num=""
|
||||||
if [ ! -d $goto_path ]; then echo "Task directory not found"; return; fi
|
if [ ! -d $goto_path ]; then echo "Task directory not found"; return; fi
|
||||||
if [[ $2 == '^[0-9]+$' ]] ; then
|
if [[ "$2" =~ '^[0-9]+$' ]] ; then
|
||||||
echo "Second argumetn provided"
|
if ! [[ $2 == '0' ]] ; then run_num="$(printf run%03d $2)"; else run_num="latest"; fi
|
||||||
if ! [[ $2 == '0' ]] ; then run_num="$(printf run%03d $2)" else run_num="latest" fi
|
if [ ! -d "$goto_path/$run_num" ]; then run_num="latest"; fi
|
||||||
if [ ! -d "$goto_path/$run_num" ]; then run_num="latest" fi
|
|
||||||
fi
|
fi
|
||||||
if [ ! -d $goto_path/$run_num ]; then
|
if [ ! -d $goto_path/$run_num ]; then
|
||||||
echo "\e[33mTask run directory not found -" $goto_path/$run_num "\e[0m";
|
echo "\e[33mTask run directory not found -" $goto_path/$run_num "\e[0m"
|
||||||
else
|
else
|
||||||
|
echo "Switching current dirctory to" $goto_path/$run_num
|
||||||
cd $goto_path/$run_num
|
cd $goto_path/$run_num
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clears enviroment variables and fucntions
|
# Clears enviroment variables and fucntions
|
||||||
unset_openfpga (){
|
unset-openfpga (){
|
||||||
unset -v OPENFPGA_PATH
|
unset -v OPENFPGA_PATH
|
||||||
unset -f list-tasks goto-task goto-root >/dev/null 2>&1
|
unset -f list-tasks run-task run-flow goto-task goto-root >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Allow autocompletion of task
|
||||||
|
if [[ $(ps -p $$ -oargs=) == *"zsh"* ]]; then
|
||||||
|
autoload -U +X bashcompinit; bashcompinit;
|
||||||
|
fi
|
||||||
|
TaskList=$(ls -tdalh ${OPENFPGA_TASK_PATH}/* | awk '{system("basename " $9)}' | awk '{printf("%s ",$1)}')
|
||||||
|
complete -W "${TaskList}" goto-task
|
||||||
|
complete -W "${TaskList}" run-task
|
Loading…
Reference in New Issue