taste-generate-skeletons 4.08 KB
Newer Older
1
#!/bin/bash
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
2 3 4 5
# $1 may be the interfaceview in AADL (optional if a file called InterfaceView.aadl is present)
# $2 is the output directory
# this script builds a unique dataview.aadl file and calls buildsupport with --gw --aadlv2 -o $2 --keep-case

6
# Initialise the progress bar
7 8 9 10 11 12 13 14 15 16
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
}
17

Maxime Perrotin's avatar
Maxime Perrotin committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31
# 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}"


Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
32 33 34 35 36 37 38
# 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.
if [ ! -f "$1" ]
then
    if [ -f InterfaceView.aadl ]
    then
Maxime Perrotin's avatar
Maxime Perrotin committed
39
        INTERFACEVIEW=InterfaceView.aadl
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
40
    else
Maxime Perrotin's avatar
Maxime Perrotin committed
41 42
        echo -e "${ERROR} Interface view not found
        Usage: [FORCE=1] taste-generate-skeletons [InterfaceView.aadl] [output-directory]"
43
        quit 1
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
44 45 46 47 48 49 50
    fi
else
    INTERFACEVIEW="$1"
    shift
fi

grep -i taste-directives.aadl "$INTERFACEVIEW" >/dev/null && {
Maxime Perrotin's avatar
Maxime Perrotin committed
51 52
    echo -e "${ERROR} Your interface view needs to be upgraded\!"
    echo -e "        Please upgrade it with:"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
53
    echo
Maxime Perrotin's avatar
Maxime Perrotin committed
54
    echo -e "          taste-upgrade-IF-view oldIFview newIFview"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
55
    echo
Maxime Perrotin's avatar
Maxime Perrotin committed
56
    echo -e "        ...and use the newIFview instead."
57
    quit 1
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
}

# Second, check if an output directory is passed as second argument
if [ -z "$1" ] 
then 
    output_dir=. 
else 
    output_dir="$1" 
fi

AADL_PROPERTIES="$(taste-config --prefix)/share/config_ellidiss/TASTE_IV_Properties.aadl"

if [[ -f InterfaceView.md5 && -z $FORCE ]]
then
    before=$(cat InterfaceView.md5)
    after=$(md5sum "$INTERFACEVIEW")
    if [ "$before" == "$after" ]
    then
Maxime Perrotin's avatar
Maxime Perrotin committed
76 77 78
        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"
79
        quit 0
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
80 81 82
    fi
fi

Maxime Perrotin's avatar
Maxime Perrotin committed
83 84
md5sum "$INTERFACEVIEW" > InterfaceView.md5

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
85 86
# Detect models from Ellidiss tools v2, and convert them to 1.3
grep "version => \"2" "$INTERFACEVIEW" >/dev/null && {
Maxime Perrotin's avatar
Maxime Perrotin committed
87
   echo -e "${INFO} Converting interface view from V2 to V1.3"
88
   echo '0-40 Analysing Interface View' > $myfifo
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
89 90 91 92 93
   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=.
Maxime Perrotin's avatar
Maxime Perrotin committed
94
echo -e "${INFO} Collecting ASN.1 files"
95
echo '40-80 Collecting ASN.1 models' > $myfifo
96
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -j "$output_dir"/dataview-uniq.asn
Maxime Perrotin's avatar
Maxime Perrotin committed
97
echo -e "${INFO} Generating AADL data view"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
98 99
asn2aadlPlus "$output_dir"/dataview-uniq.asn "$output_dir"/dataview-uniq.aadl -aadlv2
asn2aadlPlus "$output_dir"/dataview-uniq.asn "$output_dir"/dataview-uniq-v1.aadl
100
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -k "$output_dir"/dataview-uniq.asn
Maxime Perrotin's avatar
Maxime Perrotin committed
101
echo -e "${INFO} Parsing AADL and generating skeletons with buildsupport"
102
echo '80-100 Generate code skeletons' > $myfifo
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
103
buildsupport -i "$INTERFACEVIEW" -d "$output_dir"/dataview-uniq.aadl --gw --aadlv2 -o "$output_dir" --keep-case "$AADL_PROPERTIES" "$@"
104 105
if [ $? -eq 0 ]
then
Maxime Perrotin's avatar
Maxime Perrotin committed
106
    echo -e "${INFO} Completed generation of code skeletons"
107 108
    ret=0
else
Maxime Perrotin's avatar
Maxime Perrotin committed
109
    echo -e "${ERROR} Generation of code skeletons failed"
110 111
    ret=1
fi
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
112 113 114 115
cp -f __interfaceview-v2.aadl "$INTERFACEVIEW" 2>/dev/null || :
rm -f "$output_dir"/dataview-uniq.asn "$output_dir"/dataview-uniq.aadl "$output_dir"/dataview-uniq-v1.aadl \
      "$output_dir"/__interfaceview-v2.aadl

116 117 118
echo '100 Done' > $myfifo

quit $ret
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
119 120