diff options
-rw-r--r-- | abi/README.md | 9 | ||||
-rwxr-xr-x | build_abi.sh | 85 |
2 files changed, 80 insertions, 14 deletions
diff --git a/abi/README.md b/abi/README.md index b8002e0..967eb2a 100644 --- a/abi/README.md +++ b/abi/README.md @@ -54,3 +54,12 @@ follows: The report created is tool specific, but generally lists ABI changes detected that affect the Kernel's module interface. + +Updating ABI dumps +------------------ +To update the ABI dump, `build_abi.sh` can be invoked with the `--update` flag. +It will update the corresponding abi.xml file that is defined via the +build.config. It might be useful to invoke the script also with +`--print-report` to print the differences the update cleans up. That +information is useful in the commit message when updating the abi.xml in the +source control. diff --git a/build_abi.sh b/build_abi.sh index b5c7566..b3c1b46 100755 --- a/build_abi.sh +++ b/build_abi.sh @@ -25,6 +25,47 @@ export ROOT_DIR=$(readlink -f $(dirname $0)/..) +function show_help { + echo "USAGE: $0 [-u|--update] [-n|--nodiff]" + echo + echo " -u | --update Update the abi.xml in the source directory" + echo " -n | --nodiff Do not generate a ABI report with abidiff" + echo " -r | --print-report Print ABI report in case of differences" +} + +UPDATE=0 +DIFF=1 +PRINT_REPORT=0 + +ARGS=() +for i in "$@" +do +case $i in + -u|--update) + UPDATE=1 + shift # past argument=value + ;; + -n|--nodiff) + DIFF=0 + shift # past argument=value + ;; + -r|--print-report) + PRINT_REPORT=1 + shift # past argument=value + ;; + -h|--help) + show_help + exit 0 + ;; + *) + ARGS+=("$1") + shift + ;; +esac +done + +set -- "${ARGS[@]}" + set -e set -a @@ -85,20 +126,36 @@ ln -sf ${abi_out_file} ${DIST_DIR}/abi.xml echo "========================================================" echo " ABI dump has been created at ${DIST_DIR}/${abi_out_file}" +rc=0 if [ -n "$ABI_DEFINITION" ]; then - echo "========================================================" - echo " Comparing ABI against expected definition ($ABI_DEFINITION)" - abi_report=${DIST_DIR}/abi.report - set +e - ${ROOT_DIR}/build/abi/diff_abi --baseline $KERNEL_DIR/$ABI_DEFINITION \ - --new ${DIST_DIR}/${abi_out_file} \ - --report ${abi_report} - rc=$? - set -e - echo "========================================================" - echo " ABI report has been created at ${abi_report}" - if [ $rc -ne 0 ] ; then - echo " ABI DIFFERENCES HAVE BEEN DETECTED! (RC=$rc)" - exit $rc + if [ $DIFF -eq 1 ]; then + echo "========================================================" + echo " Comparing ABI against expected definition ($ABI_DEFINITION)" + abi_report=${DIST_DIR}/abi.report + set +e + ${ROOT_DIR}/build/abi/diff_abi --baseline $KERNEL_DIR/$ABI_DEFINITION \ + --new ${DIST_DIR}/${abi_out_file} \ + --report ${abi_report} + rc=$? + set -e + echo "========================================================" + echo " ABI report has been created at ${abi_report}" + + if [ $rc -ne 0 ]; then + echo " ABI DIFFERENCES HAVE BEEN DETECTED! (RC=$rc)" + fi + + if [ $PRINT_REPORT -eq 1 ] && [ $rc -ne 0 ] ; then + echo "========================================================" + cat ${abi_report} + fi + fi + if [ $UPDATE -eq 1 ] ; then + echo "========================================================" + echo " Updating expected ABI definition ($ABI_DEFINITION)" + cp -v ${DIST_DIR}/${abi_out_file} $KERNEL_DIR/$ABI_DEFINITION fi fi + +exit $rc + |