Changeset View
Changeset View
Standalone View
Standalone View
helpers/create-abi-dump.py
1 | #!/usr/bin/python3 | 1 | #!/usr/bin/python3 | ||
---|---|---|---|---|---|
2 | import os | 2 | import os | ||
3 | import re | 3 | import re | ||
4 | import logging | 4 | import logging | ||
5 | import pathlib | 5 | import pathlib | ||
6 | import argparse | 6 | import argparse | ||
7 | import tempfile | 7 | import tempfile | ||
8 | import subprocess | 8 | import subprocess | ||
9 | import sys | ||||
9 | from collections import defaultdict | 10 | from collections import defaultdict | ||
10 | from typing import Dict, List, Union | 11 | from typing import Dict, List, Union | ||
11 | 12 | | |||
12 | from helperslib import Packages, EnvironmentHandler | 13 | from helperslib import Packages, EnvironmentHandler | ||
13 | 14 | | |||
14 | # Make sure logging is ready to go | 15 | # Make sure logging is ready to go | ||
15 | #logging.basicConfig(level=logging.DEBUG) | 16 | #logging.basicConfig(level=logging.DEBUG) | ||
16 | 17 | | |||
▲ Show 20 Lines • Show All 266 Lines • ▼ Show 20 Line(s) | |||||
283 | # GIT_COMMIT is set by Jenkins Git plugin, so we can rely on that for most of our builds | 284 | # GIT_COMMIT is set by Jenkins Git plugin, so we can rely on that for most of our builds | ||
284 | scmRevision = '' | 285 | scmRevision = '' | ||
285 | if os.getenv('GIT_COMMIT') != '': | 286 | if os.getenv('GIT_COMMIT') != '': | ||
286 | scmRevision = os.getenv('GIT_COMMIT') | 287 | scmRevision = os.getenv('GIT_COMMIT') | ||
287 | 288 | | |||
288 | if not scmRevision: | 289 | if not scmRevision: | ||
289 | scmRevision = subprocess.check_output(["git", "log", "--format=%H", "-n 1", "HEAD"]).strip().decode() | 290 | scmRevision = subprocess.check_output(["git", "log", "--format=%H", "-n 1", "HEAD"]).strip().decode() | ||
290 | 291 | | |||
292 | # Check every libraries ABI and do not fail, if one is not fine. | ||||
293 | # Safe the overall retval state | ||||
294 | retval = 0 | ||||
295 | | ||||
291 | # Now we generate the ABI dumps for every library we have found | 296 | # Now we generate the ABI dumps for every library we have found | ||
292 | for library in foundLibraries: | 297 | for library in foundLibraries: | ||
293 | # Create the ABI Dump for this library | 298 | try: | ||
294 | library.createABIDump( runtimeEnvironment=buildEnvironment ) | 299 | # Create the ABI Dump for this library | ||
295 | 300 | library.createABIDump( runtimeEnvironment=buildEnvironment ) | |||
296 | # Determine where the ABI Dump archive is located | 301 | | ||
297 | # This location is controlled by abi-compliance-checker, but follows a predictable pattern | 302 | # Determine where the ABI Dump archive is located | ||
298 | fileName = "abi_dumps/{name}/{version}/ABI.dump".format(name=library.name,version=library.version) | 303 | # This location is controlled by abi-compliance-checker, but follows a predictable pattern | ||
299 | 304 | fileName = "abi_dumps/{name}/{version}/ABI.dump".format(name=library.name,version=library.version) | |||
300 | extraMetadata = { | 305 | | ||
301 | "SONAME": max([t['SONAME'] for t in library.targets.values()]), # use max because there may be more than one lib inside | 306 | extraMetadata = { | ||
302 | "version": library.version, | 307 | "SONAME": max([t['SONAME'] for t in library.targets.values()]), # use max because there may be more than one lib inside | ||
303 | "libname": library.name, | 308 | "version": library.version, | ||
304 | "targets": list(library.targets), | 309 | "libname": library.name, | ||
305 | "project": arguments.project, | 310 | "targets": list(library.targets), | ||
306 | "branchGroup": arguments.branchGroup, | 311 | "project": arguments.project, | ||
307 | "platform": arguments.platform, | 312 | "branchGroup": arguments.branchGroup, | ||
308 | } | 313 | "platform": arguments.platform, | ||
309 | packageName = "{name}_{scmRevision}_{platform}".format(name=library.name, scmRevision=scmRevision) | 314 | } | ||
310 | ourArchive.storePackage(packageName, fileName, scmRevision, extraMetadata) | 315 | packageName = "{name}_{scmRevision}_{platform}".format(name=library.name, scmRevision=scmRevision) | ||
316 | ourArchive.storePackage(packageName, fileName, scmRevision, extraMetadata) | ||||
317 | except subprocess.CalledProcessError as e: | ||||
318 | retval = e.returncode | ||||
319 | logging.error("abi-complience-checker exited with {retval}".format(retval=retval)) | ||||
320 | | ||||
321 | # We had an issue with one of the ABIs | ||||
322 | if retval != 0: | ||||
323 | sys.exit(retval) |