2018-03-01 15:53:49 +01:00
|
|
|
#!/usr/bin/env python3
|
2018-04-06 12:23:22 +02:00
|
|
|
"""
|
|
|
|
This file is part of Mbed TLS (https://tls.mbed.org)
|
|
|
|
|
|
|
|
Copyright (c) 2018, Arm Limited, All Rights Reserved
|
|
|
|
|
|
|
|
Purpose
|
|
|
|
|
|
|
|
This script is a small wrapper around the abi-compliance-checker and
|
|
|
|
abi-dumper tools, applying them to compare the ABI and API of the library
|
|
|
|
files from two different Git revisions within an Mbed TLS repository.
|
2019-02-21 14:09:26 +01:00
|
|
|
The results of the comparison are either formatted as HTML and stored at
|
2019-03-05 16:21:32 +01:00
|
|
|
a configurable location, or are given as a brief list of problems.
|
2019-02-21 14:09:26 +01:00
|
|
|
Returns 0 on success, 1 on ABI/API non-compliance, and 2 if there is an error
|
|
|
|
while running the script. Note: must be run from Mbed TLS root.
|
2018-04-06 12:23:22 +02:00
|
|
|
"""
|
2018-03-01 15:53:49 +01:00
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import traceback
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
import tempfile
|
2019-02-25 12:35:05 +01:00
|
|
|
import fnmatch
|
2018-03-01 15:53:49 +01:00
|
|
|
|
2019-02-21 14:09:26 +01:00
|
|
|
import xml.etree.ElementTree as ET
|
|
|
|
|
2018-03-01 15:53:49 +01:00
|
|
|
|
2019-03-05 17:25:38 +01:00
|
|
|
class RepoVersion(object):
|
|
|
|
|
|
|
|
def __init__(self, version, repository, revision,
|
|
|
|
crypto_repository, crypto_revision):
|
|
|
|
"""Class containing details for a particular revision.
|
|
|
|
|
|
|
|
version: either 'old' or 'new'
|
|
|
|
repository: repository for git revision
|
|
|
|
revision: git revision for comparison
|
|
|
|
crypto_repository: repository for git revision of crypto submodule
|
|
|
|
crypto_revision: git revision of crypto submodule
|
|
|
|
"""
|
|
|
|
self.version = version
|
|
|
|
self.repository = repository
|
|
|
|
self.revision = revision
|
|
|
|
self.crypto_repository = crypto_repository
|
|
|
|
self.crypto_revision = crypto_revision
|
|
|
|
self.abi_dumps = {}
|
|
|
|
self.modules = {}
|
|
|
|
|
|
|
|
|
2018-03-01 15:53:49 +01:00
|
|
|
class AbiChecker(object):
|
2019-02-25 20:36:52 +01:00
|
|
|
"""API and ABI checker."""
|
2018-03-01 15:53:49 +01:00
|
|
|
|
2019-03-08 12:30:04 +01:00
|
|
|
def __init__(self, verbose, old_version, new_version, report_dir,
|
2019-03-05 17:25:38 +01:00
|
|
|
keep_all_reports, brief, skip_file=None):
|
2019-02-25 20:36:52 +01:00
|
|
|
"""Instantiate the API/ABI checker.
|
|
|
|
|
2019-03-05 17:25:38 +01:00
|
|
|
old_version: RepoVersion containing details to compare against
|
|
|
|
new_version: RepoVersion containing details to check
|
2019-02-25 20:36:52 +01:00
|
|
|
report_dir: directory for output files
|
|
|
|
keep_all_reports: if false, delete old reports
|
2019-02-21 14:09:26 +01:00
|
|
|
brief: if true, output shorter report to stdout
|
2019-02-20 16:01:56 +01:00
|
|
|
skip_file: path to file containing symbols and types to skip
|
2019-02-25 20:36:52 +01:00
|
|
|
"""
|
2018-03-01 15:53:49 +01:00
|
|
|
self.repo_path = "."
|
|
|
|
self.log = None
|
2019-03-08 12:30:04 +01:00
|
|
|
self.verbose = verbose
|
2019-03-05 17:30:39 +01:00
|
|
|
self._setup_logger()
|
2018-03-01 15:53:49 +01:00
|
|
|
self.report_dir = os.path.abspath(report_dir)
|
|
|
|
self.keep_all_reports = keep_all_reports
|
2019-02-25 18:01:55 +01:00
|
|
|
self.can_remove_report_dir = not (os.path.isdir(self.report_dir) or
|
|
|
|
keep_all_reports)
|
2019-03-05 17:25:38 +01:00
|
|
|
self.old_version = old_version
|
|
|
|
self.new_version = new_version
|
2019-02-20 16:01:56 +01:00
|
|
|
self.skip_file = skip_file
|
2019-02-21 14:09:26 +01:00
|
|
|
self.brief = brief
|
2018-03-01 15:53:49 +01:00
|
|
|
self.git_command = "git"
|
|
|
|
self.make_command = "make"
|
|
|
|
|
2019-02-25 20:36:52 +01:00
|
|
|
@staticmethod
|
|
|
|
def check_repo_path():
|
2018-03-15 11:12:06 +01:00
|
|
|
current_dir = os.path.realpath('.')
|
|
|
|
root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
|
|
|
if current_dir != root_dir:
|
2018-03-01 15:53:49 +01:00
|
|
|
raise Exception("Must be run from Mbed TLS root")
|
|
|
|
|
2019-03-05 17:30:39 +01:00
|
|
|
def _setup_logger(self):
|
2018-03-01 15:53:49 +01:00
|
|
|
self.log = logging.getLogger()
|
2019-03-08 12:30:04 +01:00
|
|
|
if self.verbose:
|
|
|
|
self.log.setLevel(logging.DEBUG)
|
|
|
|
else:
|
|
|
|
self.log.setLevel(logging.INFO)
|
2018-03-01 15:53:49 +01:00
|
|
|
self.log.addHandler(logging.StreamHandler())
|
|
|
|
|
2019-02-25 20:36:52 +01:00
|
|
|
@staticmethod
|
|
|
|
def check_abi_tools_are_installed():
|
2018-03-01 15:53:49 +01:00
|
|
|
for command in ["abi-dumper", "abi-compliance-checker"]:
|
|
|
|
if not shutil.which(command):
|
|
|
|
raise Exception("{} not installed, aborting".format(command))
|
|
|
|
|
2019-03-05 17:30:39 +01:00
|
|
|
def _get_clean_worktree_for_git_revision(self, version):
|
2019-03-05 17:25:38 +01:00
|
|
|
"""Make a separate worktree with version.revision checked out.
|
2019-02-25 20:36:52 +01:00
|
|
|
Do not modify the current worktree."""
|
2018-03-01 15:53:49 +01:00
|
|
|
git_worktree_path = tempfile.mkdtemp()
|
2019-03-05 17:25:38 +01:00
|
|
|
if version.repository:
|
2019-03-08 12:30:04 +01:00
|
|
|
self.log.debug(
|
2019-02-19 17:59:33 +01:00
|
|
|
"Checking out git worktree for revision {} from {}".format(
|
2019-03-05 17:25:38 +01:00
|
|
|
version.revision, version.repository
|
2019-02-19 17:59:33 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
fetch_process = subprocess.Popen(
|
2019-03-05 17:25:38 +01:00
|
|
|
[self.git_command, "fetch",
|
|
|
|
version.repository, version.revision],
|
2019-02-19 17:59:33 +01:00
|
|
|
cwd=self.repo_path,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT
|
|
|
|
)
|
|
|
|
fetch_output, _ = fetch_process.communicate()
|
2019-03-08 12:30:04 +01:00
|
|
|
self.log.debug(fetch_output.decode("utf-8"))
|
2019-02-19 17:59:33 +01:00
|
|
|
if fetch_process.returncode != 0:
|
|
|
|
raise Exception("Fetching revision failed, aborting")
|
|
|
|
worktree_rev = "FETCH_HEAD"
|
|
|
|
else:
|
2019-03-08 12:30:04 +01:00
|
|
|
self.log.debug("Checking out git worktree for revision {}".format(
|
2019-03-05 17:25:38 +01:00
|
|
|
version.revision
|
|
|
|
))
|
|
|
|
worktree_rev = version.revision
|
2018-03-01 15:53:49 +01:00
|
|
|
worktree_process = subprocess.Popen(
|
2019-02-19 17:59:33 +01:00
|
|
|
[self.git_command, "worktree", "add", "--detach",
|
|
|
|
git_worktree_path, worktree_rev],
|
2018-03-01 15:53:49 +01:00
|
|
|
cwd=self.repo_path,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT
|
|
|
|
)
|
|
|
|
worktree_output, _ = worktree_process.communicate()
|
2019-03-08 12:30:04 +01:00
|
|
|
self.log.debug(worktree_output.decode("utf-8"))
|
2018-03-01 15:53:49 +01:00
|
|
|
if worktree_process.returncode != 0:
|
|
|
|
raise Exception("Checking out worktree failed, aborting")
|
|
|
|
return git_worktree_path
|
|
|
|
|
2019-03-05 17:30:39 +01:00
|
|
|
def _update_git_submodules(self, git_worktree_path, version):
|
2018-11-02 17:35:09 +01:00
|
|
|
process = subprocess.Popen(
|
|
|
|
[self.git_command, "submodule", "update", "--init", '--recursive'],
|
|
|
|
cwd=git_worktree_path,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT
|
|
|
|
)
|
|
|
|
output, _ = process.communicate()
|
2019-03-08 12:30:04 +01:00
|
|
|
self.log.debug(output.decode("utf-8"))
|
2018-11-02 17:35:09 +01:00
|
|
|
if process.returncode != 0:
|
|
|
|
raise Exception("git submodule update failed, aborting")
|
2019-03-05 16:23:25 +01:00
|
|
|
if not (os.path.exists(os.path.join(git_worktree_path, "crypto"))
|
2019-03-05 17:25:38 +01:00
|
|
|
and version.crypto_revision):
|
2019-03-05 16:23:25 +01:00
|
|
|
return
|
|
|
|
|
2019-03-05 17:25:38 +01:00
|
|
|
if version.crypto_repository:
|
2019-03-08 12:12:19 +01:00
|
|
|
fetch_process = subprocess.Popen(
|
|
|
|
[self.git_command, "fetch", version.crypto_repository,
|
|
|
|
version.crypto_revision],
|
2019-03-05 16:23:25 +01:00
|
|
|
cwd=os.path.join(git_worktree_path, "crypto"),
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT
|
|
|
|
)
|
2019-03-08 12:12:19 +01:00
|
|
|
fetch_output, _ = fetch_process.communicate()
|
2019-03-08 12:30:04 +01:00
|
|
|
self.log.debug(fetch_output.decode("utf-8"))
|
2019-03-08 12:12:19 +01:00
|
|
|
if fetch_process.returncode != 0:
|
|
|
|
raise Exception("git fetch failed, aborting")
|
|
|
|
crypto_rev = "FETCH_HEAD"
|
|
|
|
else:
|
|
|
|
crypto_rev = version.crypto_revision
|
|
|
|
|
|
|
|
checkout_process = subprocess.Popen(
|
|
|
|
[self.git_command, "checkout", crypto_rev],
|
|
|
|
cwd=os.path.join(git_worktree_path, "crypto"),
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT
|
|
|
|
)
|
|
|
|
checkout_output, _ = checkout_process.communicate()
|
2019-03-08 12:30:04 +01:00
|
|
|
self.log.debug(checkout_output.decode("utf-8"))
|
2019-03-08 12:12:19 +01:00
|
|
|
if checkout_process.returncode != 0:
|
|
|
|
raise Exception("git checkout failed, aborting")
|
2018-11-02 17:35:09 +01:00
|
|
|
|
2019-03-05 17:30:39 +01:00
|
|
|
def _build_shared_libraries(self, git_worktree_path, version):
|
2019-02-25 20:36:52 +01:00
|
|
|
"""Build the shared libraries in the specified worktree."""
|
2018-03-01 15:53:49 +01:00
|
|
|
my_environment = os.environ.copy()
|
|
|
|
my_environment["CFLAGS"] = "-g -Og"
|
|
|
|
my_environment["SHARED"] = "1"
|
2019-02-25 12:35:05 +01:00
|
|
|
my_environment["USE_CRYPTO_SUBMODULE"] = "1"
|
2018-03-01 15:53:49 +01:00
|
|
|
make_process = subprocess.Popen(
|
2019-02-28 12:52:39 +01:00
|
|
|
[self.make_command, "lib"],
|
2018-03-01 15:53:49 +01:00
|
|
|
env=my_environment,
|
|
|
|
cwd=git_worktree_path,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT
|
|
|
|
)
|
|
|
|
make_output, _ = make_process.communicate()
|
2019-03-08 12:30:04 +01:00
|
|
|
self.log.debug(make_output.decode("utf-8"))
|
2019-02-25 12:35:05 +01:00
|
|
|
for root, dirs, files in os.walk(git_worktree_path):
|
|
|
|
for file in fnmatch.filter(files, "*.so"):
|
2019-03-05 17:25:38 +01:00
|
|
|
version.modules[os.path.splitext(file)[0]] = (
|
2019-02-27 17:53:40 +01:00
|
|
|
os.path.join(root, file)
|
2019-02-25 12:35:05 +01:00
|
|
|
)
|
2018-03-01 15:53:49 +01:00
|
|
|
if make_process.returncode != 0:
|
|
|
|
raise Exception("make failed, aborting")
|
|
|
|
|
2019-03-05 17:30:39 +01:00
|
|
|
def _get_abi_dumps_from_shared_libraries(self, git_worktree_path,
|
|
|
|
version):
|
2019-02-25 20:36:52 +01:00
|
|
|
"""Generate the ABI dumps for the specified git revision.
|
|
|
|
It must be checked out in git_worktree_path and the shared libraries
|
|
|
|
must have been built."""
|
2019-03-05 17:25:38 +01:00
|
|
|
for mbed_module, module_path in version.modules.items():
|
2018-03-01 15:53:49 +01:00
|
|
|
output_path = os.path.join(
|
2019-04-04 15:39:33 +02:00
|
|
|
self.report_dir, "{}-{}-{}.dump".format(
|
|
|
|
mbed_module, version.revision, version.version
|
2019-02-27 17:53:40 +01:00
|
|
|
)
|
2018-03-01 15:53:49 +01:00
|
|
|
)
|
|
|
|
abi_dump_command = [
|
|
|
|
"abi-dumper",
|
2019-02-25 12:35:05 +01:00
|
|
|
module_path,
|
2018-03-01 15:53:49 +01:00
|
|
|
"-o", output_path,
|
2019-03-05 17:25:38 +01:00
|
|
|
"-lver", version.revision
|
2018-03-01 15:53:49 +01:00
|
|
|
]
|
|
|
|
abi_dump_process = subprocess.Popen(
|
|
|
|
abi_dump_command,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT
|
|
|
|
)
|
|
|
|
abi_dump_output, _ = abi_dump_process.communicate()
|
2019-03-08 12:30:04 +01:00
|
|
|
self.log.debug(abi_dump_output.decode("utf-8"))
|
2018-03-01 15:53:49 +01:00
|
|
|
if abi_dump_process.returncode != 0:
|
|
|
|
raise Exception("abi-dumper failed, aborting")
|
2019-03-05 17:25:38 +01:00
|
|
|
version.abi_dumps[mbed_module] = output_path
|
2018-03-01 15:53:49 +01:00
|
|
|
|
2019-03-05 17:30:39 +01:00
|
|
|
def _cleanup_worktree(self, git_worktree_path):
|
2019-02-25 20:36:52 +01:00
|
|
|
"""Remove the specified git worktree."""
|
2018-03-01 15:53:49 +01:00
|
|
|
shutil.rmtree(git_worktree_path)
|
|
|
|
worktree_process = subprocess.Popen(
|
|
|
|
[self.git_command, "worktree", "prune"],
|
|
|
|
cwd=self.repo_path,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT
|
|
|
|
)
|
|
|
|
worktree_output, _ = worktree_process.communicate()
|
2019-03-08 12:30:04 +01:00
|
|
|
self.log.debug(worktree_output.decode("utf-8"))
|
2018-03-01 15:53:49 +01:00
|
|
|
if worktree_process.returncode != 0:
|
|
|
|
raise Exception("Worktree cleanup failed, aborting")
|
|
|
|
|
2019-03-05 17:30:39 +01:00
|
|
|
def _get_abi_dump_for_ref(self, version):
|
2019-02-25 20:36:52 +01:00
|
|
|
"""Generate the ABI dumps for the specified git revision."""
|
2019-03-05 17:30:39 +01:00
|
|
|
git_worktree_path = self._get_clean_worktree_for_git_revision(version)
|
|
|
|
self._update_git_submodules(git_worktree_path, version)
|
|
|
|
self._build_shared_libraries(git_worktree_path, version)
|
|
|
|
self._get_abi_dumps_from_shared_libraries(git_worktree_path, version)
|
|
|
|
self._cleanup_worktree(git_worktree_path)
|
2018-03-01 15:53:49 +01:00
|
|
|
|
2019-03-05 17:30:39 +01:00
|
|
|
def _remove_children_with_tag(self, parent, tag):
|
2019-02-21 14:09:26 +01:00
|
|
|
children = parent.getchildren()
|
|
|
|
for child in children:
|
|
|
|
if child.tag == tag:
|
|
|
|
parent.remove(child)
|
|
|
|
else:
|
2019-03-05 17:30:39 +01:00
|
|
|
self._remove_children_with_tag(child, tag)
|
2019-02-21 14:09:26 +01:00
|
|
|
|
2019-03-05 17:30:39 +01:00
|
|
|
def _remove_extra_detail_from_report(self, report_root):
|
2019-02-21 14:09:26 +01:00
|
|
|
for tag in ['test_info', 'test_results', 'problem_summary',
|
|
|
|
'added_symbols', 'removed_symbols', 'affected']:
|
2019-03-05 17:30:39 +01:00
|
|
|
self._remove_children_with_tag(report_root, tag)
|
2019-02-21 14:09:26 +01:00
|
|
|
|
|
|
|
for report in report_root:
|
|
|
|
for problems in report.getchildren()[:]:
|
|
|
|
if not problems.getchildren():
|
|
|
|
report.remove(problems)
|
|
|
|
|
2018-03-01 15:53:49 +01:00
|
|
|
def get_abi_compatibility_report(self):
|
2019-02-25 20:36:52 +01:00
|
|
|
"""Generate a report of the differences between the reference ABI
|
|
|
|
and the new ABI. ABI dumps from self.old_rev and self.new_rev must
|
|
|
|
be available."""
|
2018-03-01 15:53:49 +01:00
|
|
|
compatibility_report = ""
|
|
|
|
compliance_return_code = 0
|
2019-03-05 17:25:38 +01:00
|
|
|
shared_modules = list(set(self.old_version.modules.keys()) &
|
|
|
|
set(self.new_version.modules.keys()))
|
2019-02-27 17:53:40 +01:00
|
|
|
for mbed_module in shared_modules:
|
2018-03-01 15:53:49 +01:00
|
|
|
output_path = os.path.join(
|
|
|
|
self.report_dir, "{}-{}-{}.html".format(
|
2019-03-05 17:25:38 +01:00
|
|
|
mbed_module, self.old_version.revision,
|
|
|
|
self.new_version.revision
|
2018-03-01 15:53:49 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
abi_compliance_command = [
|
|
|
|
"abi-compliance-checker",
|
|
|
|
"-l", mbed_module,
|
2019-03-05 17:25:38 +01:00
|
|
|
"-old", self.old_version.abi_dumps[mbed_module],
|
|
|
|
"-new", self.new_version.abi_dumps[mbed_module],
|
2018-03-01 15:53:49 +01:00
|
|
|
"-strict",
|
2019-02-21 14:09:26 +01:00
|
|
|
"-report-path", output_path,
|
2018-03-01 15:53:49 +01:00
|
|
|
]
|
2019-02-20 16:01:56 +01:00
|
|
|
if self.skip_file:
|
|
|
|
abi_compliance_command += ["-skip-symbols", self.skip_file,
|
|
|
|
"-skip-types", self.skip_file]
|
2019-02-21 14:09:26 +01:00
|
|
|
if self.brief:
|
|
|
|
abi_compliance_command += ["-report-format", "xml",
|
|
|
|
"-stdout"]
|
2018-03-01 15:53:49 +01:00
|
|
|
abi_compliance_process = subprocess.Popen(
|
|
|
|
abi_compliance_command,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT
|
|
|
|
)
|
|
|
|
abi_compliance_output, _ = abi_compliance_process.communicate()
|
|
|
|
if abi_compliance_process.returncode == 0:
|
|
|
|
compatibility_report += (
|
|
|
|
"No compatibility issues for {}\n".format(mbed_module)
|
|
|
|
)
|
2019-02-21 14:09:26 +01:00
|
|
|
if not (self.keep_all_reports or self.brief):
|
2018-03-01 15:53:49 +01:00
|
|
|
os.remove(output_path)
|
|
|
|
elif abi_compliance_process.returncode == 1:
|
2019-02-21 14:09:26 +01:00
|
|
|
if self.brief:
|
|
|
|
self.log.info(
|
|
|
|
"Compatibility issues found for {}".format(mbed_module)
|
|
|
|
)
|
|
|
|
report_root = ET.fromstring(abi_compliance_output.decode("utf-8"))
|
2019-03-05 17:30:39 +01:00
|
|
|
self._remove_extra_detail_from_report(report_root)
|
2019-02-21 14:09:26 +01:00
|
|
|
self.log.info(ET.tostring(report_root).decode("utf-8"))
|
|
|
|
else:
|
|
|
|
compliance_return_code = 1
|
|
|
|
self.can_remove_report_dir = False
|
|
|
|
compatibility_report += (
|
|
|
|
"Compatibility issues found for {}, "
|
|
|
|
"for details see {}\n".format(mbed_module, output_path)
|
|
|
|
)
|
2018-03-01 15:53:49 +01:00
|
|
|
else:
|
|
|
|
raise Exception(
|
|
|
|
"abi-compliance-checker failed with a return code of {},"
|
|
|
|
" aborting".format(abi_compliance_process.returncode)
|
|
|
|
)
|
2019-03-05 17:25:38 +01:00
|
|
|
os.remove(self.old_version.abi_dumps[mbed_module])
|
|
|
|
os.remove(self.new_version.abi_dumps[mbed_module])
|
2019-02-25 18:01:55 +01:00
|
|
|
if self.can_remove_report_dir:
|
2018-03-01 15:53:49 +01:00
|
|
|
os.rmdir(self.report_dir)
|
|
|
|
self.log.info(compatibility_report)
|
|
|
|
return compliance_return_code
|
|
|
|
|
|
|
|
def check_for_abi_changes(self):
|
2019-02-25 20:36:52 +01:00
|
|
|
"""Generate a report of ABI differences
|
|
|
|
between self.old_rev and self.new_rev."""
|
2018-03-01 15:53:49 +01:00
|
|
|
self.check_repo_path()
|
|
|
|
self.check_abi_tools_are_installed()
|
2019-03-05 17:30:39 +01:00
|
|
|
self._get_abi_dump_for_ref(self.old_version)
|
|
|
|
self._get_abi_dump_for_ref(self.new_version)
|
2018-03-01 15:53:49 +01:00
|
|
|
return self.get_abi_compatibility_report()
|
|
|
|
|
|
|
|
|
|
|
|
def run_main():
|
|
|
|
try:
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description=(
|
2018-04-16 13:02:29 +02:00
|
|
|
"""This script is a small wrapper around the
|
|
|
|
abi-compliance-checker and abi-dumper tools, applying them
|
|
|
|
to compare the ABI and API of the library files from two
|
|
|
|
different Git revisions within an Mbed TLS repository.
|
2019-02-21 14:09:26 +01:00
|
|
|
The results of the comparison are either formatted as HTML and
|
2019-03-05 16:21:32 +01:00
|
|
|
stored at a configurable location, or are given as a brief list
|
|
|
|
of problems. Returns 0 on success, 1 on ABI/API non-compliance,
|
|
|
|
and 2 if there is an error while running the script.
|
|
|
|
Note: must be run from Mbed TLS root."""
|
2018-03-01 15:53:49 +01:00
|
|
|
)
|
|
|
|
)
|
2019-03-08 12:30:04 +01:00
|
|
|
parser.add_argument(
|
|
|
|
"-v", "--verbose", action="store_true",
|
|
|
|
help="set verbosity level",
|
|
|
|
)
|
2018-03-01 15:53:49 +01:00
|
|
|
parser.add_argument(
|
2018-04-16 13:02:29 +02:00
|
|
|
"-r", "--report-dir", type=str, default="reports",
|
2018-03-01 15:53:49 +01:00
|
|
|
help="directory where reports are stored, default is reports",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
2018-04-16 13:02:29 +02:00
|
|
|
"-k", "--keep-all-reports", action="store_true",
|
2018-03-01 15:53:49 +01:00
|
|
|
help="keep all reports, even if there are no compatibility issues",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
2019-03-01 10:54:44 +01:00
|
|
|
"-o", "--old-rev", type=str, help="revision for old version.",
|
|
|
|
required=True,
|
2018-03-01 15:53:49 +01:00
|
|
|
)
|
2019-02-25 12:35:05 +01:00
|
|
|
parser.add_argument(
|
2019-03-01 10:54:44 +01:00
|
|
|
"-or", "--old-repo", type=str, help="repository for old version."
|
2019-02-25 12:35:05 +01:00
|
|
|
)
|
2018-03-01 15:53:49 +01:00
|
|
|
parser.add_argument(
|
2019-03-01 10:54:44 +01:00
|
|
|
"-oc", "--old-crypto-rev", type=str,
|
|
|
|
help="revision for old crypto submodule."
|
2018-03-01 15:53:49 +01:00
|
|
|
)
|
2019-02-25 12:35:05 +01:00
|
|
|
parser.add_argument(
|
2019-03-01 10:54:44 +01:00
|
|
|
"-ocr", "--old-crypto-repo", type=str,
|
|
|
|
help="repository for old crypto submodule."
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-n", "--new-rev", type=str, help="revision for new version",
|
|
|
|
required=True,
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-nr", "--new-repo", type=str, help="repository for new version."
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-nc", "--new-crypto-rev", type=str,
|
|
|
|
help="revision for new crypto version"
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-ncr", "--new-crypto-repo", type=str,
|
|
|
|
help="repository for new crypto submodule."
|
2019-02-25 12:35:05 +01:00
|
|
|
)
|
2019-02-20 16:01:56 +01:00
|
|
|
parser.add_argument(
|
|
|
|
"-s", "--skip-file", type=str,
|
|
|
|
help="path to file containing symbols and types to skip"
|
|
|
|
)
|
2019-02-21 14:09:26 +01:00
|
|
|
parser.add_argument(
|
|
|
|
"-b", "--brief", action="store_true",
|
|
|
|
help="output only the list of issues to stdout, instead of a full report",
|
|
|
|
)
|
2018-03-01 15:53:49 +01:00
|
|
|
abi_args = parser.parse_args()
|
2019-03-05 17:25:38 +01:00
|
|
|
old_version = RepoVersion("old", abi_args.old_repo, abi_args.old_rev,
|
|
|
|
abi_args.old_crypto_repo, abi_args.old_crypto_rev)
|
|
|
|
new_version = RepoVersion("new", abi_args.new_repo, abi_args.new_rev,
|
|
|
|
abi_args.new_crypto_repo, abi_args.new_crypto_rev)
|
2018-03-01 15:53:49 +01:00
|
|
|
abi_check = AbiChecker(
|
2019-03-08 12:30:04 +01:00
|
|
|
abi_args.verbose, old_version, new_version, abi_args.report_dir,
|
2019-03-05 17:25:38 +01:00
|
|
|
abi_args.keep_all_reports, abi_args.brief, abi_args.skip_file
|
2018-03-01 15:53:49 +01:00
|
|
|
)
|
|
|
|
return_code = abi_check.check_for_abi_changes()
|
|
|
|
sys.exit(return_code)
|
2018-03-15 11:12:06 +01:00
|
|
|
except Exception:
|
|
|
|
traceback.print_exc()
|
2018-03-01 15:53:49 +01:00
|
|
|
sys.exit(2)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
run_main()
|