aboutsummaryrefslogtreecommitdiff
path: root/diff-abi.sh
blob: 7e0e860d19a72be90de4c1423e35866178752361 (plain)
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
#!/bin/bash

ROOT_DIR=$(readlink -f $(dirname $0))

source ${ROOT_DIR}/helper/generic
export CONFIGURE_FLAGS=""

export GIT_BRANCH="${GIT_BRANCH:-master}"
export COMPARE_BRANCH="${COMPARE_BRANCH:-api-next}"
export GENERIC_SRCDIR="${GENERIC_SRCDIR:-${SRCDIR}/odp}"
export GENERIC_BUILDDIR="${GENERIC_BUILDDIR:-${BUILDDIR}/odp_diff}"
export COMPARE_BUILDDIR="${COMPARE_BUILDDIR:-${BUILDDIR}/odp_diff_2}"
export CLEANUP="${CLEANUP:-1}"
export COMPARE_URL="${COMPARE_URL:-""}"
PLATFORM=${PLATFORM:-linux-generic}
DETAILED_DIFF=${DETAILED_DIFF:-0}
DETAILED_DIFF_FLAGS=""

ABI_LOGDIR="${LOGDIR}/diff-abi"
LOGFILE_BASENAME="${LOGFILE_BASENAME:-default}"
LOGFILE="${ABI_LOGDIR}/${LOGFILE_BASENAME}-$(date "+%Y%m%d_%H%M")"
mkdir -p ${ABI_LOGDIR}

publishing=${ROOT_DIR}/publishing
mkdir -p ${publishing}

trap cleanup_exit INT TERM EXIT

cleanup_exit()
{
    if [[ ${CLEANUP} -eq 1 ]]; then
        rm -rf ${GENERIC_BUILDDIR}
        rm -rf ${COMPARE_BUILDDIR}
        rm -rf compat_reports* ABI-*.dump
        rm -rf ${ABI_LOGDIR}
        ${PLATFORM_SHORT}_cleanup
    fi
}

usage() {
    echo -e "$0 makes use of the following environment variables,"
    echo -e "\tGIT_URL:\t which ODP git repo to use, default: ${GIT_URL}"
    echo -e "\tGIT_BRANCH:\t which branch to checkout and test, default: ${GIT_BRANCH}"
    echo -e "\tCOMPARE_URL:\t which ODP git repo to use, default: NONE"
    echo -e "\tCOMPARE_BRANCH:\t which branch to checkout and test, default: master"
    echo -e "\tCLEANUP:\t to save workspace set CLEANUP=0, default: 1"
    echo -e "\tDETAILED_DIFF:\t to see a detailed list set DETAILED_DIFF=1, default: 0"
    ${PLATFORM_SHORT}_usage
}

abi_build() {
    # $1 BUILDDIR
    # $2 generic or compare
    pushd ${1} >>${LOGFILE}-${2}-abi_build.log 2>&1
    ./bootstrap >>${LOGFILE}-${2}-abi_build.log 2>&1
    ./configure ${CONFIGURE_FLAGS} --prefix=${1}/install CFLAGS="-g -O0" >>${LOGFILE}-${2}-abi_build.log 2>&1
    make install -j >>${LOGFILE}-${2}-abi_build.log 2>&1
    version_name=$(${1}/scripts/git_hash.sh ${1})
    popd >>${LOGFILE}-${2}-abi_build.log 2>&1
    echo ${version_name}
}

abi_dumper() {
    # $1 BUILDDIR
    # $2 URL
    # $3 BRANCH
    # $4 generic or compare
    base_name=${ROOT_DIR}/ABI-$(basename ${2})-${3}
    for lib in $(find ${1}/install/lib/ -type l -name 'libodp*so'); do
        abi-dumper -sort -lver ${3} ${lib} -o ${base_name}-$(basename ${lib})-${4}.dump >>${LOGFILE}-${4}-abi_dumper.log 2>&1

    done
    echo ${base_name}
}

prepare_platform

if [[ "x$1" = "x-h" || "x$1" = "x--help" ]]; then
    usage
    exit 0
fi

display_os

if [ ${DETAILED_DIFF} -eq 1 ]; then
    DETAILED_DIFF_FLAGS="--detailed --brief"
fi

${PLATFORM_SHORT}_get

# Default compare branch and repo, if you don't set anything you will default
# to api-next and upstream repo odp (linux-generic)
if [ -z ${COMPARE_URL} ]; then
    COMPARE_URL=${GIT_URL}
fi

#create a name to represent the repos being compared, the branches are noted separately
URL1=$(echo ${GIT_URL} |sed 's|.*\/\/||' |sed 's|/|_|g' |sed 's|.git$||')
URL2=$(echo ${COMPARE_URL} |sed 's|.*\/\/||' |sed 's|/|_|g' |sed 's|.git$||')
URL="${URL1}-${URL2}"
echo "${URL}"

if [ ! -d "$GENERIC_BUILDDIR" ]; then
    setup_builddir ${GENERIC_SRCDIR} ${GIT_URL} ${GIT_BRANCH} ${GENERIC_BUILDDIR}
fi

if [ ! -d "$COMPARE_BUILDDIR" ]; then
    setup_builddir ${GENERIC_SRCDIR} ${COMPARE_URL} ${COMPARE_BRANCH} ${COMPARE_BUILDDIR}
fi

generic_version_name=$(abi_build ${GENERIC_BUILDDIR} "generic")
generic_base_name=$(abi_dumper ${GENERIC_BUILDDIR} ${GIT_URL} ${GIT_BRANCH} "generic")


if [[ -d ${COMPARE_BUILDDIR}/platform/linux-dpdk ]]; then
    source ${ROOT_DIR}/helper/platform/dpdk
    dpdk_prepare >>${LOGFILE}-${4}-prepare.log 2>&1
    dpdk_get >>${LOGFILE}-${4}-prepare.log 2>&1
    dpdk_build >>${LOGFILE}-${4}-prepare.log 2>&1
    ## CONFIGURE_FLAGS
fi

compare_version_name=$(abi_build ${COMPARE_BUILDDIR} "compare")
compare_base_name=$(abi_dumper ${COMPARE_BUILDDIR} ${COMPARE_URL} ${COMPARE_BRANCH} "compare")
#compare_base_name=${ROOT_DIR}/ABI-$(basename ${COMPARE_URL})-${COMPARE_BRANCH}
#abi_dumper ${COMPARE_BUILDDIR} ${COMPARE_BRANCH} ${compare_base_name} "compare"


publishing_dir="${publishing}/diff-abi"

rm -rf ${publishing_dir}
mkdir -p ${publishing_dir}

abi-compliance-checker -l ${URL} -old $(ls ${generic_base_name}-libodphelper*.dump) -new $(ls ${compare_base_name}-libodphelper*.dump)
mv compat_reports/${URL}/${GIT_BRANCH}_to_${COMPARE_BRANCH}/compat_report.html ${publishing_dir}/libodphelper-compat_report.html

abi-compliance-checker -l ${URL} -old $(ls ${generic_base_name}-libodp-*.dump) -new $(ls ${compare_base_name}-libodp-*.dump)
mv compat_reports/${URL}/${GIT_BRANCH}_to_${COMPARE_BRANCH}/compat_report.html ${publishing_dir}/libodp-compat_report.html

echo "moved report to ${publishing_dir}/libodp-compat_report.html"

## vim: set sw=4 sts=4 et foldmethod=syntax : ##