Changeset View
Changeset View
Standalone View
Standalone View
helpers/create-abi-dump.py
Show First 20 Lines • Show All 269 Lines • ▼ Show 20 Line(s) | 269 | for line in log.readlines(): | |||
---|---|---|---|---|---|
270 | match = cmakeConfig.match(line) | 270 | match = cmakeConfig.match(line) | ||
271 | if match: | 271 | if match: | ||
272 | foundLibrary = Library( match.group(2) ) | 272 | foundLibrary = Library( match.group(2) ) | ||
273 | foundLibraries.append(foundLibrary) | 273 | foundLibraries.append(foundLibrary) | ||
274 | 274 | | |||
275 | # Initialize the archive manager | 275 | # Initialize the archive manager | ||
276 | ourArchive = Packages.Archive(arguments.environment, 'ABIReference', usingCache = False) | 276 | ourArchive = Packages.Archive(arguments.environment, 'ABIReference', usingCache = False) | ||
277 | 277 | | |||
278 | # Determine which SCM revision we are storing | ||||
279 | # This will be embedded into the package metadata which might help someone doing some debugging | ||||
280 | # GIT_COMMIT is set by Jenkins Git plugin, so we can rely on that for most of our builds | ||||
281 | scmRevision = '' | ||||
282 | if os.getenv('GIT_COMMIT') != '': | ||||
283 | scmRevision = os.getenv('GIT_COMMIT') | ||||
bcooksley: In a Jenkins Pipeline environment I believe this environment variable is never set, so to get… | |||||
I just copied that part from capture-workspace.py and capture-install.py, so properly they are needed to be updated too. knauss: I just copied that part from capture-workspace.py and capture-install.py, so properly they are… | |||||
Yeah, at the moment our tooling doesn't rely on that metadata, but if we do need to make use of it in the future then we will need to fix that. bcooksley: Yeah, at the moment our tooling doesn't rely on that metadata, but if we do need to make use of… | |||||
284 | | ||||
285 | if not scmRevision: | ||||
286 | scmRevision = subprocess.check_output(["git", "log", "--format=%H", "-n 1", "HEAD"]).strip().decode() | ||||
287 | | ||||
278 | # Now we generate the ABI dumps for every library we have found | 288 | # Now we generate the ABI dumps for every library we have found | ||
279 | for library in foundLibraries: | 289 | for library in foundLibraries: | ||
280 | # Create the ABI Dump for this library | 290 | # Create the ABI Dump for this library | ||
281 | library.createABIDump( runtimeEnvironment=buildEnvironment ) | 291 | library.createABIDump( runtimeEnvironment=buildEnvironment ) | ||
282 | 292 | | |||
283 | # Determine where the ABI Dump archive is located | 293 | # Determine where the ABI Dump archive is located | ||
284 | # This location is controlled by abi-compliance-checker, but follows a predictable pattern | 294 | # This location is controlled by abi-compliance-checker, but follows a predictable pattern | ||
285 | fileName = "abi_dumps/{name}/{version}/ABI.dump".format(name=library.name,version=library.version) | 295 | fileName = "abi_dumps/{name}/{version}/ABI.dump".format(name=library.name,version=library.version) | ||
286 | 296 | | |||
287 | # Determine the internal version of the library we have found | 297 | extraMetadata = { | ||
288 | # This is based off the CMake package metadata we read in above | 298 | "SONAME": max([t['SONAME'] for t in lib.targets.values()]), # use max because there may be more than one lib inside | ||
289 | scmRevision = max([t['SONAME'] for t in library.targets.values()]) # a more hackish way, to save the SONAME in the metadata | 299 | "version": lib.version, | ||
290 | 300 | "libname": lib.name, | |||
291 | # Create a name for this entry in the Package archive and store it there | 301 | "targets": lib.targets.keys(), | ||
292 | packageName = "{name}_{scmRevision}".format(name=library.name, scmRevision=scmRevision) | 302 | } | ||
293 | ourArchive.storePackage(packageName, fileName, scmRevision) | 303 | packageName = "{name}_{scmRevision}".format(name=lib.name, scmRevision=scmRevision) | ||
304 | ourArchive.storePackage(packageName, fileName, scmRevision, extraMetadata) |
In a Jenkins Pipeline environment I believe this environment variable is never set, so to get the hash you'll need to shell out to Git unfortunately (git describe HEAD or git log --format=%H -n 1 HEAD are your friends here)