File: abi_check.sh

package info (click to toggle)
dart 6.12.1%2Bdfsg4-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 57,000 kB
  • sloc: cpp: 269,461; python: 3,911; xml: 1,273; sh: 404; makefile: 30
file content (180 lines) | stat: -rwxr-xr-x 4,356 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/sh

################################################################################
# Functions
################################################################################

# Print usage
usage()
{
    echo "usage: ./abi_check.sh <old_version_number> <new_version_number>" 
    echo ""
    echo "The most commonly used commands are:"
    echo "  ./abi_check.sh 4.0.0 4.1.0  ABI check of 4.0.0 and 4.1.0"
    echo "  ./abi_check.sh 4.0.0        ABI check of 4.0.0 and current"
    echo ""
    exit 1
}

print_valid_version_numbers()
{
    echo "Valid version numbers are: "
    echo "    4.0.0"
    echo "    4.1.0"
    echo "    4.1.1"
    echo "    4.2.0"
    echo "    4.2.1"
    echo "    4.3.0"
    echo "    4.3.1"
    echo "    4.3.2"
    echo "    4.3.3"
    echo "    4.3.4"
    exit 1
}

# Match given version number and corresponding branch name in the dart 
match_version_number_and_branch_name()
{
case "$VERSION_NUMBER" in
        4.0.0)
            BRANCH_NAME="tags/v4.0"
            break;;
        4.1.0)
            BRANCH_NAME="tags/v4.1.0"
            break;;
        4.1.1)
            BRANCH_NAME="tags/v4.1.1"
            break;;
        4.2.0)
            BRANCH_NAME="tags/v4.2.0"
            break;;
        4.2.1)
            BRANCH_NAME="tags/v4.2.1"
            break;;
        4.3.0)
            BRANCH_NAME="tags/v4.3.0"
            break;;
        4.3.1)
            BRANCH_NAME="tags/v4.3.1"
            break;;
        4.3.2)
            BRANCH_NAME="tags/v4.3.2"
            break;;
        4.3.3)
            BRANCH_NAME="tags/v4.3.3"
            break;;
        4.3.4)
            BRANCH_NAME="tags/v4.3.4"
            break;;
        *)
            echo "Invalid version number: ${VERSION_NUMBER}"
            print_valid_version_numbers
            break;;
    esac

    echo "Version number: ${VERSION_NUMBER}"
    echo "Branch name: ${BRANCH_NAME}"
}

# Generate version files
gen_version_files()
{
    FILE="${BASEDIR}/abi_dart_${VERSION_NUMBER}.xml"
    /bin/cat << EOM > $FILE
<version>
    ${VERSION_NUMBER}
</version>

<headers>
    ./install/dart_${VERSION_NUMBER}/include/
</headers>

<libs>
    ./install/dart_${VERSION_NUMBER}/lib/
</libs>
EOM
}

# Clone and build the target version of DART
build_target_version_dart()
{
cd $BASEDIR/source
git clone git://github.com/dartsim/dart.git dart_${VERSION_NUMBER}
cd dart_${VERSION_NUMBER}
git checkout ${BRANCH_NAME}
cmake -DBUILD_CORE_ONLY=$BUILD_CORE_ONLY -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=${BASEDIR}/install/dart_${VERSION_NUMBER} .
make -j4 install
}

# Build the current version of DART
build_current_dart()
{
if [ ! -d "$BASEDIR/source/dart_current" ]; then
    mkdir $BASEDIR/source/dart_current 
fi
cd $BASEDIR/source/dart_current
cmake -DBUILD_CORE_ONLY=$BUILD_CORE_ONLY -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=${BASEDIR}/install/dart_current ${CURRENT_DART_DIR}
make -j4 install
}

################################################################################
# Main routine 
################################################################################

# If the number of arguments is not 1 or 2, then print usage
[ "$#" -gt 2 ] && { usage; exit 1; }
[ "$#" -lt 1 ] && { usage; exit 1; }

# Set working directory
BASEDIR="$PWD"/abi_check_work
cd ../
CURRENT_DART_DIR=$PWD
echo Current DART directory: $CURRENT_DART_DIR
echo ABI check working directory: $BASEDIR

# Create directories
if [ ! -d "$BASEDIR" ]; then
    mkdir $BASEDIR;
fi
if [ ! -d "$BASEDIR/source" ]; then
    mkdir $BASEDIR/source; 
fi
if [ ! -d "$BASEDIR/install" ]; then
    mkdir $BASEDIR/install 
fi

# Set variables
PRG=$0
OLD_VER=$1
if [ "$#" -eq 2 ]; then
    NEW_VER=$2
else
    NEW_VER=current
fi

# Build and install the old version of DART
VERSION_NUMBER=$OLD_VER
match_version_number_and_branch_name
gen_version_files
build_target_version_dart

# Build and install the new version of DART
if [ "$#" -eq 2 ]; then
    VERSION_NUMBER=$NEW_VER
    match_version_number_and_branch_name
    gen_version_files
    build_target_version_dart
else
    VERSION_NUMBER=current
    gen_version_files
    build_current_dart
fi

# Install ABI checker
sudo apt-get --yes --force-yes install abi-compliance-checker

# Checkk ABI
cd $BASEDIR
abi-compliance-checker -lib DART -old abi_dart_${OLD_VER}.xml -new abi_dart_${NEW_VER}.xml