taste-generate-skeletons 4.09 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
Maxime Perrotin's avatar
Maxime Perrotin committed
7
8
9
10
11
myfifo=/tmp/$$$RANDOM
mkfifo $myfifo
tail -f $myfifo | taste-progress-dialog.py &

function quit {
12
    echo '100 Done' > $myfifo
Maxime Perrotin's avatar
Maxime Perrotin committed
13
14
15
16
17
    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
}
18

Maxime Perrotin's avatar
Maxime Perrotin committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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
33
34
35
36
37
38
39
# 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
40
        INTERFACEVIEW=InterfaceView.aadl
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
41
    else
Maxime Perrotin's avatar
Maxime Perrotin committed
42
43
        echo -e "${ERROR} Interface view not found
        Usage: [FORCE=1] taste-generate-skeletons [InterfaceView.aadl] [output-directory]"
Maxime Perrotin's avatar
Maxime Perrotin committed
44
        quit 1
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
45
46
47
48
49
50
51
    fi
else
    INTERFACEVIEW="$1"
    shift
fi

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

# 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
77
78
79
        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"
Maxime Perrotin's avatar
Maxime Perrotin committed
80
        quit 0
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
81
82
83
    fi
fi

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

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

Maxime Perrotin's avatar
Maxime Perrotin committed
117
118

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