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

Improve helper scripts

parent 83f82b2a
#!/bin/bash
# TASTE Concurrency View Creator
( cat ) | taste-progress-dialog.py &
log_pid=$!
# 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
}
# 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="${COLORON}[ERROR]${COLOROFF}"
ERROR="${REDCOLORON}[ERROR]${COLOROFF}"
error=0
NB_ARGS=3
......@@ -24,38 +35,37 @@ if [ $# -eq $AUTO ]
then
if [[ -f InterfaceView.aadl && -f DeploymentView.aadl && -f DataView.aadl ]]
then
echo 'Using InterfaceView.aadl, DeploymentView.aadl, DataView.aadl (defaults)'
echo -e "${INFO} Using InterfaceView.aadl, DeploymentView.aadl, DataView.aadl (defaults)"
INTERFACEVIEW=InterfaceView.aadl
DEPLOYMENTVIEW=DeploymentView.aadl
DATAVIEW=DataView.aadl
else
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
else
# Check if there are 3 parameters and that the files are all present
if [[ $# -eq $NB_ARGS && -f "$1" && -f "$2" && -f "$3" ]]
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"
DEPLOYMENTVIEW="$2"
DATAVIEW="$3"
else
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
# Check if models are from V2 and convert to V1_3 accordingly
V2=0
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"
TASTE --load-interface-view InterfaceView.aadl --export-interface-view-to-1_3 __iv_1_3.aadl
INTERFACEVIEW=__iv_1_3.aadl
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
DEPLOYMENTVIEW=__dv_1_3.aadl
V2=1
......@@ -66,10 +76,8 @@ if [ $error -eq 1 ]
then
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"
echo '100 Error' > /proc/$log_pid/fd/0
# Must kill the cat command still running in the background to release TASTE GUI
kill $(pstree -p $(jobs -x echo %1) | grep cat | cut -d \( -f 3 | cut -d \) -f 1)
exit -1
echo '100 Error' > $myfifo
quit 1
fi
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
OCARINA_COMPONENTS="$(taste-config --prefix)/share/ocarina/AADLv2/ocarina_components.aadl"
# 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)
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
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -k "$tempdir"/dataview-uniq.asn
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}
-c ${DEPLOYMENTVIEW}
-d ${DATAVIEW}
......@@ -111,10 +119,8 @@ else
${CMD}
"
echo -e "${ERROR} Buildsupport reported errors - Fix your models before you can edit the Concurrency View"
echo '100 Error' > /proc/$log_pid/fd/0
# Must kill the cat command still running in the background to release TASTE GUI
kill $(pstree -p $(jobs -x echo %1) | grep cat | cut -d \( -f 3 | cut -d \) -f 1)
exit -2
echo '100 Error' > $myfifo
quit 2
fi
echo 'Running the Concurrency View editor from TASTE
......@@ -135,8 +141,6 @@ else
mv "$tempdir"/ConcurrencyView .
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
kill $(pstree -p $(jobs -x echo %1) | grep cat | cut -d \( -f 3 | cut -d \) -f 1)
exit 0
quit 0
......@@ -9,13 +9,26 @@ mkfifo $myfifo
tail -f $myfifo | taste-progress-dialog.py &
function quit {
echo '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)
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)
# 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.
......@@ -25,8 +38,8 @@ then
then
INTERFACEVIEW=InterfaceView.aadl
else
echo '[ERROR] Interface view not found
Usage: [FORCE=1] taste-generate-skeletons [InterfaceView.aadl] [output-directory]'
echo -e "${ERROR} Interface view not found
Usage: [FORCE=1] taste-generate-skeletons [InterfaceView.aadl] [output-directory]"
quit 1
fi
else
......@@ -35,12 +48,12 @@ else
fi
grep -i taste-directives.aadl "$INTERFACEVIEW" >/dev/null && {
echo Your interface view needs to be upgraded\!
echo Please upgrade it with:
echo -e "${ERROR} Your interface view needs to be upgraded\!"
echo -e " Please upgrade it with:"
echo
echo " taste-upgrade-IF-view oldIFview newIFview"
echo -e " taste-upgrade-IF-view oldIFview newIFview"
echo
echo ...and use the newIFview instead.
echo -e " ...and use the newIFview instead."
quit 1
}
......@@ -60,10 +73,9 @@ then
after=$(md5sum "$INTERFACEVIEW")
if [ "$before" == "$after" ]
then
echo 'Interface View has not changed, nothing to do
If you want to force generation of the skeletons anyway, type:
$ FORCE=1 taste-generate-skeletons
'
echo -e "${INFO} Interface View has not changed since last call"
echo -e "${INFO} If you want to force generation of the skeletons anyway, type:"
echo -e "${INFO} $ FORCE=1 taste-generate-skeletons"
quit 0
fi
fi
......@@ -72,28 +84,29 @@ md5sum "$INTERFACEVIEW" > InterfaceView.md5
# Detect models from Ellidiss tools v2, and convert them to 1.3
grep "version => \"2" "$INTERFACEVIEW" >/dev/null && {
echo '[INFO] Converting interface view from V2 to V1.3'
echo '20 Analyse Interface View' > $myfifo
echo -e "${INFO} Converting interface view from V2 to V1.3"
echo '20 Analysing Interface View' > $myfifo
cp -f "$INTERFACEVIEW" "$output_dir"/__interfaceview-v2.aadl
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=.
echo '[INFO] Collecting ASN.1 files'
echo '40 Collect and process ASN.1 models' > $myfifo
echo -e "${INFO} Collecting ASN.1 files"
echo '40 Collecting ASN.1 models' > $myfifo
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-v1.aadl
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
buildsupport -i "$INTERFACEVIEW" -d "$output_dir"/dataview-uniq.aadl --gw --aadlv2 -o "$output_dir" --keep-case "$AADL_PROPERTIES" "$@"
if [ $? -eq 0 ]
then
echo '100 Done' > $myfifo
echo -e "${INFO} Completed generation of code skeletons"
ret=0
else
echo -e "${ERROR} Generation of code skeletons failed"
ret=1
fi
cp -f __interfaceview-v2.aadl "$INTERFACEVIEW" 2>/dev/null || :
......
......@@ -2,6 +2,18 @@
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
COLORON="\e[1m\e[32m"
REDCOLORON="\e[1m\e[31m"
......@@ -25,7 +37,7 @@ do
if [ ! -f "$f" ]
then
echo -e "${INFO} File not found: ${f}"
exit 1
quit 1
else
echo -e "${INFO} Using file: ${f}"
filename=$(readlink -e "$f")
......@@ -50,7 +62,7 @@ then
else
>&2 echo -e "${ERROR} No data view found"
echo -e "${INFO} Usage: taste-update-data-view <set of ASN.1 files>"
exit 1
quit 1
fi
if [ -f DataView.acn ]
then
......@@ -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
# due to multiple calls to the ASN.1 compiler
#asn2aadlPlus $DATAVIEW "$AADL" -aadlv2 2>&1 | uniq >&2
echo '50 Updating data view' > $myfifo
asn2aadlPlus $DATAVIEW "$AADL" -aadlv2 2>&1 > >(uniq >&2)
echo '100 Completed' > $myfifo
if [ "$?" = "1" ]
then
>&2 echo -e "${ERROR} Impossible to convert the dataview from ASN.1 to AADL"
echo -e "${INFO} Command: asn2aadlPlus ${DATAVIEW} ${AADL} -aadlv2"
exit 1
quit 1
else
echo -e "${INFO} All OK"
exit 0
quit 0
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