mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-20 22:10:03 +08:00
Allow sym_diff.py to report non-zero for non-breaking ABI changes
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292297 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -22,7 +22,8 @@ if (LIBCXX_HAS_ABILIST_CONFIGURATION)
|
|||||||
set(ABILIST_FILE "${CMAKE_CURRENT_LIST_DIR}/${TARGET_TRIPLE}.abilist")
|
set(ABILIST_FILE "${CMAKE_CURRENT_LIST_DIR}/${TARGET_TRIPLE}.abilist")
|
||||||
set(SYMDIFF_EXE "${LIBCXX_SOURCE_DIR}/utils/sym_check/sym_diff.py")
|
set(SYMDIFF_EXE "${LIBCXX_SOURCE_DIR}/utils/sym_check/sym_diff.py")
|
||||||
add_custom_target(check-cxx-abilist
|
add_custom_target(check-cxx-abilist
|
||||||
${SYMDIFF_EXE} --only-stdlib-symbols ${ABILIST_FILE} $<TARGET_SONAME_FILE:cxx_shared>
|
${SYMDIFF_EXE} --only-stdlib-symbols --strict ${ABILIST_FILE}
|
||||||
|
$<TARGET_SONAME_FILE:cxx_shared>
|
||||||
DEPENDS cxx_shared
|
DEPENDS cxx_shared
|
||||||
COMMENT "Testing ABI compatibility...")
|
COMMENT "Testing ABI compatibility...")
|
||||||
endif()
|
endif()
|
||||||
|
@@ -98,4 +98,6 @@ def report_diff(added_syms, removed_syms, changed_syms, names_only=False,
|
|||||||
report += 'ABI BREAKAGE: SYMBOLS ADDED OR REMOVED!'
|
report += 'ABI BREAKAGE: SYMBOLS ADDED OR REMOVED!'
|
||||||
else:
|
else:
|
||||||
report += 'Symbols match.'
|
report += 'Symbols match.'
|
||||||
return report, int(abi_break)
|
is_different = abi_break or bool(len(added_syms)) \
|
||||||
|
or bool(len(changed_syms))
|
||||||
|
return report, abi_break, is_different
|
||||||
|
@@ -30,6 +30,10 @@ def main():
|
|||||||
parser.add_argument('--only-stdlib-symbols', dest='only_stdlib',
|
parser.add_argument('--only-stdlib-symbols', dest='only_stdlib',
|
||||||
help="Filter all symbols not related to the stdlib",
|
help="Filter all symbols not related to the stdlib",
|
||||||
action='store_true', default=False)
|
action='store_true', default=False)
|
||||||
|
parser.add_argument('--strict', dest='strict',
|
||||||
|
help="Exit with a non-zero status if any symbols "
|
||||||
|
"differ",
|
||||||
|
action='store_true', default=False)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-o', '--output', dest='output',
|
'-o', '--output', dest='output',
|
||||||
help='The output file. stdout is used if not given',
|
help='The output file. stdout is used if not given',
|
||||||
@@ -54,16 +58,16 @@ def main():
|
|||||||
added, removed, changed = diff.diff(old_syms_list, new_syms_list)
|
added, removed, changed = diff.diff(old_syms_list, new_syms_list)
|
||||||
if args.removed_only:
|
if args.removed_only:
|
||||||
added = {}
|
added = {}
|
||||||
report, is_break = diff.report_diff(added, removed, changed,
|
report, is_break, is_different = diff.report_diff(
|
||||||
names_only=args.names_only,
|
added, removed, changed, names_only=args.names_only,
|
||||||
demangle=args.demangle)
|
demangle=args.demangle)
|
||||||
if args.output is None:
|
if args.output is None:
|
||||||
print(report)
|
print(report)
|
||||||
else:
|
else:
|
||||||
with open(args.output, 'w') as f:
|
with open(args.output, 'w') as f:
|
||||||
f.write(report + '\n')
|
f.write(report + '\n')
|
||||||
sys.exit(is_break)
|
exit_code = 1 if is_break or (args.strict and is_different) else 0
|
||||||
|
sys.exit(exit_code)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Reference in New Issue
Block a user