Commit 3a914e10 authored by Maxime Perrotin's avatar Maxime Perrotin

Improve helper scripts

parent 83f82b2a
#!/bin/bash #!/bin/bash
# TASTE Concurrency View Creator # TASTE Concurrency View Creator
( cat ) | taste-progress-dialog.py & # Initialise the progress bar
log_pid=$! myfifo=/tmp/$$$RANDOM
mkfifo $myfifo
tail -f $myfifo | taste-progress-dialog.py &
function quit {
rm $myfifo
tailps=$(pstree -p $$ | grep tail | python -c "import sys, re; print re.search(r'tail\((.*)\)', [x for x in sys.stdin][0]).group(1)")
kill $tailps || xterm -e "echo Internal Error, unable to kill subprocess. Open a terminal and type 'pkill tail' to (hopefully) recover"
exit $1
}
# Logging with colors (only in a terminal) # Logging with colors (only in a terminal)
if [ -t 1 ] ; then if [ -t 1 ] ; then
COLORON="\e[1m\e[32m" COLORON="\e[1m\e[32m"
REDCOLORON="\e[1m\e[31m"
COLOROFF="\e[0m" COLOROFF="\e[0m"
else else
COLORON="" COLORON=""
REDCOLORON=""
COLOROFF="" COLOROFF=""
fi fi
INFO="${COLORON}[INFO]${COLOROFF}" INFO="${COLORON}[INFO]${COLOROFF}"
ERROR="${COLORON}[ERROR]${COLOROFF}" ERROR="${REDCOLORON}[ERROR]${COLOROFF}"
error=0 error=0
NB_ARGS=3 NB_ARGS=3
...@@ -24,38 +35,37 @@ if [ $# -eq $AUTO ] ...@@ -24,38 +35,37 @@ if [ $# -eq $AUTO ]
then then
if [[ -f InterfaceView.aadl && -f DeploymentView.aadl && -f DataView.aadl ]] if [[ -f InterfaceView.aadl && -f DeploymentView.aadl && -f DataView.aadl ]]
then then
echo 'Using InterfaceView.aadl, DeploymentView.aadl, DataView.aadl (defaults)' echo -e "${INFO} Using InterfaceView.aadl, DeploymentView.aadl, DataView.aadl (defaults)"
INTERFACEVIEW=InterfaceView.aadl INTERFACEVIEW=InterfaceView.aadl
DEPLOYMENTVIEW=DeploymentView.aadl DEPLOYMENTVIEW=DeploymentView.aadl
DATAVIEW=DataView.aadl DATAVIEW=DataView.aadl
else else
error=1 error=1
echo 'Error: Missing files (need InterfaceView.aadl, DeploymentView.aadl, DataView.aadl)' echo -e "${ERROR} Missing files (need InterfaceView.aadl, DeploymentView.aadl, DataView.aadl)"
fi fi
else else
# Check if there are 3 parameters and that the files are all present # Check if there are 3 parameters and that the files are all present
if [[ $# -eq $NB_ARGS && -f "$1" && -f "$2" && -f "$3" ]] if [[ $# -eq $NB_ARGS && -f "$1" && -f "$2" && -f "$3" ]]
then then
echo 'Loading interface, deployment and data views: "$1" "$2" "$3"' echo -e "${INFO} Loading interface, deployment and data views: $1 $2 $3"
INTERFACEVIEW="$1" INTERFACEVIEW="$1"
DEPLOYMENTVIEW="$2" DEPLOYMENTVIEW="$2"
DATAVIEW="$3" DATAVIEW="$3"
else else
error=1 error=1
echo 'Error: specified files missing or wrong number of parameters' echo -e "${ERROR} Specified files missing or wrong number of parameters"
fi fi
fi fi
# Check if models are from V2 and convert to V1_3 accordingly # Check if models are from V2 and convert to V1_3 accordingly
V2=0 V2=0
grep "version => \"2" InterfaceView.aadl >/dev/null && { grep "version => \"2" InterfaceView.aadl >/dev/null && {
echo '20 Analyse Interface View' > /proc/$log_pid/fd/0 echo '20 Analyse Interface View' > $myfifo
echo -e "${INFO} Converting interface view from V2 to V1.3" echo -e "${INFO} Converting interface view from V2 to V1.3"
TASTE --load-interface-view InterfaceView.aadl --export-interface-view-to-1_3 __iv_1_3.aadl TASTE --load-interface-view InterfaceView.aadl --export-interface-view-to-1_3 __iv_1_3.aadl
INTERFACEVIEW=__iv_1_3.aadl INTERFACEVIEW=__iv_1_3.aadl
echo -e "${INFO} Converting deployment view from V2 to V1.3" echo -e "${INFO} Converting deployment view from V2 to V1.3"
echo '40 Analyse Deployment View' > /proc/$log_pid/fd/0 echo '40 Analyse Deployment View' > $myfifo
TASTE --load-deployment-view "$DEPLOYMENTVIEW" --export-deployment-view-to-1_3 __dv_1_3.aadl TASTE --load-deployment-view "$DEPLOYMENTVIEW" --export-deployment-view-to-1_3 __dv_1_3.aadl
DEPLOYMENTVIEW=__dv_1_3.aadl DEPLOYMENTVIEW=__dv_1_3.aadl
V2=1 V2=1
...@@ -66,10 +76,8 @@ if [ $error -eq 1 ] ...@@ -66,10 +76,8 @@ if [ $error -eq 1 ]
then then
echo -e "${ERROR} If you are using custom names for interface, deployment and data views, please specify them in order: echo -e "${ERROR} If you are using custom names for interface, deployment and data views, please specify them in order:
Usage: taste-edit-concurrency-view InterfaceView.aadl DeploymentView.aadl DataView.aadl" Usage: taste-edit-concurrency-view InterfaceView.aadl DeploymentView.aadl DataView.aadl"
echo '100 Error' > /proc/$log_pid/fd/0 echo '100 Error' > $myfifo
# Must kill the cat command still running in the background to release TASTE GUI quit 1
kill $(pstree -p $(jobs -x echo %1) | grep cat | cut -d \( -f 3 | cut -d \) -f 1)
exit -1
fi fi
AADL_PROPERTIES="$(taste-config --prefix)/share/config_ellidiss/TASTE_IV_Properties.aadl " AADL_PROPERTIES="$(taste-config --prefix)/share/config_ellidiss/TASTE_IV_Properties.aadl "
...@@ -77,13 +85,13 @@ AADL_PROPERTIES+="$(taste-config --prefix)/share/config_ellidiss/TASTE_DV_Proper ...@@ -77,13 +85,13 @@ AADL_PROPERTIES+="$(taste-config --prefix)/share/config_ellidiss/TASTE_DV_Proper
OCARINA_COMPONENTS="$(taste-config --prefix)/share/ocarina/AADLv2/ocarina_components.aadl" OCARINA_COMPONENTS="$(taste-config --prefix)/share/ocarina/AADLv2/ocarina_components.aadl"
# Tempdir will not be deleted - OS shall make the cleanup (likely at reboot) # Tempdir will not be deleted - OS shall make the cleanup (likely at reboot)
echo '60 Parse Data View' > /proc/$log_pid/fd/0 echo '60 Parse Data View' > $myfifo
tempdir=$(mktemp -d) tempdir=$(mktemp -d)
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -j "$tempdir"/dataview-uniq.asn mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -j "$tempdir"/dataview-uniq.asn
asn2aadlPlus "$tempdir"/dataview-uniq.asn "$tempdir"/dataview-uniq.aadl -aadlv2 asn2aadlPlus "$tempdir"/dataview-uniq.asn "$tempdir"/dataview-uniq.aadl -aadlv2
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -k "$tempdir"/dataview-uniq.asn mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -k "$tempdir"/dataview-uniq.asn
DATAVIEW="$tempdir"/dataview-uniq.aadl DATAVIEW="$tempdir"/dataview-uniq.aadl
echo '80 Generate Concurrency View' > /proc/$log_pid/fd/0 echo '80 Generate Concurrency View' > $myfifo
CMD="buildsupport -i ${INTERFACEVIEW} CMD="buildsupport -i ${INTERFACEVIEW}
-c ${DEPLOYMENTVIEW} -c ${DEPLOYMENTVIEW}
-d ${DATAVIEW} -d ${DATAVIEW}
...@@ -111,10 +119,8 @@ else ...@@ -111,10 +119,8 @@ else
${CMD} ${CMD}
" "
echo -e "${ERROR} Buildsupport reported errors - Fix your models before you can edit the Concurrency View" echo -e "${ERROR} Buildsupport reported errors - Fix your models before you can edit the Concurrency View"
echo '100 Error' > /proc/$log_pid/fd/0 echo '100 Error' > $myfifo
# Must kill the cat command still running in the background to release TASTE GUI quit 2
kill $(pstree -p $(jobs -x echo %1) | grep cat | cut -d \( -f 3 | cut -d \) -f 1)
exit -2
fi fi
echo 'Running the Concurrency View editor from TASTE echo 'Running the Concurrency View editor from TASTE
...@@ -135,8 +141,6 @@ else ...@@ -135,8 +141,6 @@ else
mv "$tempdir"/ConcurrencyView . mv "$tempdir"/ConcurrencyView .
fi fi
echo '100 Done' > /proc/$log_pid/fd/0 echo '100 Done' > $myfifo
# Must kill the cat command still running in the background to release TASTE GUI quit 0
kill $(pstree -p $(jobs -x echo %1) | grep cat | cut -d \( -f 3 | cut -d \) -f 1)
exit 0
...@@ -9,13 +9,26 @@ mkfifo $myfifo ...@@ -9,13 +9,26 @@ mkfifo $myfifo
tail -f $myfifo | taste-progress-dialog.py & tail -f $myfifo | taste-progress-dialog.py &
function quit { function quit {
echo 'QUIT'
rm $myfifo rm $myfifo
tailps=$(pstree -p $$ | grep tail | python -c "import sys, re; print re.search(r'tail\((.*)\)', [x for x in sys.stdin][0]).group(1)") tailps=$(pstree -p $$ | grep tail | python -c "import sys, re; print re.search(r'tail\((.*)\)', [x for x in sys.stdin][0]).group(1)")
kill $tailps || xterm -e "echo Internal Error, unable to kill subprocess. Open a terminal and type 'pkill tail' to (hopefully) recover" kill $tailps || xterm -e "echo Internal Error, unable to kill subprocess. Open a terminal and type 'pkill tail' to (hopefully) recover"
exit $1 exit $1
} }
# Logging with colors (only in a terminal)
if [ -t 1 ] ; then
COLORON="\e[1m\e[32m"
REDCOLORON="\e[1m\e[31m"
COLOROFF="\e[0m"
else
COLORON=""
REDCOLORON=""
COLOROFF=""
fi
INFO="${COLORON}[INFO]${COLOROFF}"
ERROR="${REDCOLORON}[ERROR]${COLOROFF}"
# First check if an existing file is given as first argument (interface view) # First check if an existing file is given as first argument (interface view)
# If not, check for the presence of a file called "InterfaceView.aadl". # If not, check for the presence of a file called "InterfaceView.aadl".
# If no file is present or given, return an error with the command line. # If no file is present or given, return an error with the command line.
...@@ -25,8 +38,8 @@ then ...@@ -25,8 +38,8 @@ then
then then
INTERFACEVIEW=InterfaceView.aadl INTERFACEVIEW=InterfaceView.aadl
else else
echo '[ERROR] Interface view not found echo -e "${ERROR} Interface view not found
Usage: [FORCE=1] taste-generate-skeletons [InterfaceView.aadl] [output-directory]' Usage: [FORCE=1] taste-generate-skeletons [InterfaceView.aadl] [output-directory]"
quit 1 quit 1
fi fi
else else
...@@ -35,12 +48,12 @@ else ...@@ -35,12 +48,12 @@ else
fi fi
grep -i taste-directives.aadl "$INTERFACEVIEW" >/dev/null && { grep -i taste-directives.aadl "$INTERFACEVIEW" >/dev/null && {
echo Your interface view needs to be upgraded\! echo -e "${ERROR} Your interface view needs to be upgraded\!"
echo Please upgrade it with: echo -e " Please upgrade it with:"
echo echo
echo " taste-upgrade-IF-view oldIFview newIFview" echo -e " taste-upgrade-IF-view oldIFview newIFview"
echo echo
echo ...and use the newIFview instead. echo -e " ...and use the newIFview instead."
quit 1 quit 1
} }
...@@ -60,10 +73,9 @@ then ...@@ -60,10 +73,9 @@ then
after=$(md5sum "$INTERFACEVIEW") after=$(md5sum "$INTERFACEVIEW")
if [ "$before" == "$after" ] if [ "$before" == "$after" ]
then then
echo 'Interface View has not changed, nothing to do echo -e "${INFO} Interface View has not changed since last call"
If you want to force generation of the skeletons anyway, type: echo -e "${INFO} If you want to force generation of the skeletons anyway, type:"
$ FORCE=1 taste-generate-skeletons echo -e "${INFO} $ FORCE=1 taste-generate-skeletons"
'
quit 0 quit 0
fi fi
fi fi
...@@ -72,28 +84,29 @@ md5sum "$INTERFACEVIEW" > InterfaceView.md5 ...@@ -72,28 +84,29 @@ md5sum "$INTERFACEVIEW" > InterfaceView.md5
# Detect models from Ellidiss tools v2, and convert them to 1.3 # Detect models from Ellidiss tools v2, and convert them to 1.3
grep "version => \"2" "$INTERFACEVIEW" >/dev/null && { grep "version => \"2" "$INTERFACEVIEW" >/dev/null && {
echo '[INFO] Converting interface view from V2 to V1.3' echo -e "${INFO} Converting interface view from V2 to V1.3"
echo '20 Analyse Interface View' > $myfifo echo '20 Analysing Interface View' > $myfifo
cp -f "$INTERFACEVIEW" "$output_dir"/__interfaceview-v2.aadl cp -f "$INTERFACEVIEW" "$output_dir"/__interfaceview-v2.aadl
TASTE --load-interface-view "$output_dir"/__interfaceview-v2.aadl --export-interface-view-to-1_3 "$INTERFACEVIEW" TASTE --load-interface-view "$output_dir"/__interfaceview-v2.aadl --export-interface-view-to-1_3 "$INTERFACEVIEW"
}; };
mkdir -p "$output_dir" 2>/dev/null && shift || output_dir=. mkdir -p "$output_dir" 2>/dev/null && shift || output_dir=.
echo '[INFO] Collecting ASN.1 files' echo -e "${INFO} Collecting ASN.1 files"
echo '40 Collect and process ASN.1 models' > $myfifo echo '40 Collecting ASN.1 models' > $myfifo
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -j "$output_dir"/dataview-uniq.asn mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -j "$output_dir"/dataview-uniq.asn
echo '[INFO] Generating AADL data view' echo -e "${INFO} Generating AADL data view"
asn2aadlPlus "$output_dir"/dataview-uniq.asn "$output_dir"/dataview-uniq.aadl -aadlv2 asn2aadlPlus "$output_dir"/dataview-uniq.asn "$output_dir"/dataview-uniq.aadl -aadlv2
asn2aadlPlus "$output_dir"/dataview-uniq.asn "$output_dir"/dataview-uniq-v1.aadl asn2aadlPlus "$output_dir"/dataview-uniq.asn "$output_dir"/dataview-uniq-v1.aadl
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -k "$output_dir"/dataview-uniq.asn mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -k "$output_dir"/dataview-uniq.asn
echo '[INFO] Parsing AADL and generating skeletons with buildsupport' echo -e "${INFO} Parsing AADL and generating skeletons with buildsupport"
echo '80 Generate code skeletons' > $myfifo echo '80 Generate code skeletons' > $myfifo
buildsupport -i "$INTERFACEVIEW" -d "$output_dir"/dataview-uniq.aadl --gw --aadlv2 -o "$output_dir" --keep-case "$AADL_PROPERTIES" "$@" buildsupport -i "$INTERFACEVIEW" -d "$output_dir"/dataview-uniq.aadl --gw --aadlv2 -o "$output_dir" --keep-case "$AADL_PROPERTIES" "$@"
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
echo '100 Done' > $myfifo echo -e "${INFO} Completed generation of code skeletons"
ret=0 ret=0
else else
echo -e "${ERROR} Generation of code skeletons failed"
ret=1 ret=1
fi fi
cp -f __interfaceview-v2.aadl "$INTERFACEVIEW" 2>/dev/null || : cp -f __interfaceview-v2.aadl "$INTERFACEVIEW" 2>/dev/null || :
......
...@@ -2,6 +2,18 @@ ...@@ -2,6 +2,18 @@
echo TASTE Data View Convertor - From ASN.1 to AADLV2 echo TASTE Data View Convertor - From ASN.1 to AADLV2
# Initialise the progress bar
myfifo=/tmp/$$$RANDOM
mkfifo $myfifo
tail -f $myfifo | taste-progress-dialog.py &
function quit {
rm $myfifo
tailps=$(pstree -p $$ | grep tail | python -c "import sys, re; print re.search(r'tail\((.*)\)', [x for x in sys.stdin][0]).group(1)")
kill $tailps || xterm -e "echo Internal Error, unable to kill subprocess. Open a terminal and type 'pkill tail' to (hopefully) recover"
exit $1
}
if [ -t 1 ] ; then if [ -t 1 ] ; then
COLORON="\e[1m\e[32m" COLORON="\e[1m\e[32m"
REDCOLORON="\e[1m\e[31m" REDCOLORON="\e[1m\e[31m"
...@@ -25,7 +37,7 @@ do ...@@ -25,7 +37,7 @@ do
if [ ! -f "$f" ] if [ ! -f "$f" ]
then then
echo -e "${INFO} File not found: ${f}" echo -e "${INFO} File not found: ${f}"
exit 1 quit 1
else else
echo -e "${INFO} Using file: ${f}" echo -e "${INFO} Using file: ${f}"
filename=$(readlink -e "$f") filename=$(readlink -e "$f")
...@@ -50,7 +62,7 @@ then ...@@ -50,7 +62,7 @@ then
else else
>&2 echo -e "${ERROR} No data view found" >&2 echo -e "${ERROR} No data view found"
echo -e "${INFO} Usage: taste-update-data-view <set of ASN.1 files>" echo -e "${INFO} Usage: taste-update-data-view <set of ASN.1 files>"
exit 1 quit 1
fi fi
if [ -f DataView.acn ] if [ -f DataView.acn ]
then then
...@@ -79,15 +91,17 @@ DATAVIEW+=" $(taste-config --prefix)/share/taste-types/taste-types.asn" ...@@ -79,15 +91,17 @@ DATAVIEW+=" $(taste-config --prefix)/share/taste-types/taste-types.asn"
# can asn2aadlPlus with a call to uniq to filter out duplicate outputs # can asn2aadlPlus with a call to uniq to filter out duplicate outputs
# due to multiple calls to the ASN.1 compiler # due to multiple calls to the ASN.1 compiler
#asn2aadlPlus $DATAVIEW "$AADL" -aadlv2 2>&1 | uniq >&2 #asn2aadlPlus $DATAVIEW "$AADL" -aadlv2 2>&1 | uniq >&2
echo '50 Updating data view' > $myfifo
asn2aadlPlus $DATAVIEW "$AADL" -aadlv2 2>&1 > >(uniq >&2) asn2aadlPlus $DATAVIEW "$AADL" -aadlv2 2>&1 > >(uniq >&2)
echo '100 Completed' > $myfifo
if [ "$?" = "1" ] if [ "$?" = "1" ]
then then
>&2 echo -e "${ERROR} Impossible to convert the dataview from ASN.1 to AADL" >&2 echo -e "${ERROR} Impossible to convert the dataview from ASN.1 to AADL"
echo -e "${INFO} Command: asn2aadlPlus ${DATAVIEW} ${AADL} -aadlv2" echo -e "${INFO} Command: asn2aadlPlus ${DATAVIEW} ${AADL} -aadlv2"
exit 1 quit 1
else else
echo -e "${INFO} All OK" echo -e "${INFO} All OK"
exit 0 quit 0
fi fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment