diff options
author | Matthias Maennich <maennich@google.com> | 2019-08-19 15:21:37 +0100 |
---|---|---|
committer | Matthias Maennich <maennich@google.com> | 2019-08-19 17:06:39 +0000 |
commit | 697275e9e6e1ddf9286b162a3798519f7d06adc6 (patch) | |
tree | 23b77ae2204162798263a4f2ff467384534df52a | |
parent | 4d44b554f5627e43208b368c38736c1fa167e9c1 (diff) |
build_abi: add options to help maintaining the abi.xml
Add the options
-u | --update Update the abi.xml in the source directory
-n | --nodiff Do not generate a ABI report with abidiff
-r | --print-report Print ABI report in case of differences
This allows the following example usages (besides others):
- Update the ABI and print the reported differences
That is useful to take the report for the commit message when
updating the abi.xml.
$ build/build_abi.sh -r -u
- Update the ABI and ignore any difference
If you are not interested in the report or any existing difference,
but just want to update the abi.xml.
$ build/build_abi.sh -u -n
Change-Id: Ifc97b7043da6e93b90e670bab2f89796aff655ac
Signed-off-by: Matthias Maennich <maennich@google.com>
-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 + |