sbsv2/raptor/python/raptor_buildplatform.py
author timothy.murphy@nokia.com
Fri, 12 Feb 2010 14:57:02 +0200
branchfix
changeset 204 a19456c07783
parent 5 593a8820b912
permissions -rw-r--r--
fix: failure of make engine test when a make engine alias contains a modifier. There can be more than one variant per alias via "." e.g. make.extrastuff where make and extrastuff are variants.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
     1
#
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
     2
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
     3
# All rights reserved.
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
     4
# This component and the accompanying materials are made available
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
     6
# which accompanies this distribution, and is available
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
     8
#
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
     9
# Initial Contributors:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    11
#
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    12
# Contributors:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    13
#
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    14
# Description: 
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    15
# Classes, methods and regex available for use in log filters
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    16
#
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    17
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    18
# This particular file is preliminary and under development.
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    19
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    20
class BuildPlatform(object):
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    21
	""" A build platform is a set of configurations which share
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    22
	the same metadata. In other words, a set of configurations
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    23
	for which the bld.inf and MMP files pre-process to exactly
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    24
	the same text."""
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    25
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    26
	def __init__(self, build):
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    27
		evaluator = build.GetEvaluator(None, buildConfig)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    28
		self.selfform= evaluator.CheckedGet("TRADITIONAL_PLATFORM")
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    29
		epocroot = evaluator.CheckedGet("EPOCROOT")
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    30
		self.epocroot = generic_path.Path(epocroot)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    31
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    32
		sbs_build_dir = evaluator.CheckedGet("SBS_BUILD_DIR")
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    33
		self.sbs_build_dir = generic_path.Path(sbs_build_dir)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    34
		flm_export_dir = evaluator.CheckedGet("FLM_EXPORT_DIR")
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    35
		self.flm_export_dir = generic_path.Path(flm_export_dir)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    36
		self.cacheid = flm_export_dir
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    37
		if raptor_utilities.getOSPlatform().startswith("win"):
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    38
			self.platmacros = evaluator.CheckedGet( "PLATMACROS.WINDOWS")
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    39
		else:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    40
			self.platmacros = evaluator.CheckedGet( "PLATMACROS.LINUX")
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    41
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    42
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    43
		# is this a feature variant config or an ordinary variant
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    44
		fv = evaluator.Get("FEATUREVARIANTNAME")
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    45
		if fv:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    46
			variantHdr = evaluator.CheckedGet("VARIANT_HRH")
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    47
			variantHRH = generic_path.Path(variantHdr)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    48
			self.isfeaturevariant = True
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    49
		else:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    50
			variantCfg = evaluator.CheckedGet("VARIANT_CFG")
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    51
			variantCfg = generic_path.Path(variantCfg)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    52
			if not variantCfg in variantCfgs:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    53
				# get VARIANT_HRH from the variant.cfg file
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    54
				varCfg = getVariantCfgDetail(self.epocroot, variantCfg)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    55
				variantCfgs[variantCfg] = varCfg['VARIANT_HRH']
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    56
				# we expect to always build ABIv2
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    57
				if not 'ENABLE_ABIV2_MODE' in varCfg:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    58
					build.Warn("missing flag ENABLE_ABIV2_MODE in %s file. ABIV1 builds are not supported.",
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    59
										   str(variantCfg))
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    60
			variantHRH = variantCfgs[variantCfg]
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    61
			self.isfeaturevariant = False
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    62
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    63
			self.variant_hrh = variantHRH
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    64
			build.Info("'%s' uses variant hrh file '%s'", buildConfig.name, variantHRH)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    65
			self.systeminclude = evaluator.CheckedGet("SYSTEMINCLUDE")
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    66
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    67
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    68
			# find all the interface names we need
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    69
			ifaceTypes = evaluator.CheckedGet("INTERFACE_TYPES")
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    70
			interfaces = ifaceTypes.split()
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    71
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    72
			for iface in interfaces:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    73
				detail[iface] = evaluator.CheckedGet("INTERFACE." + iface)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    74
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    75
			# not test code unless positively specified
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    76
			self.testcode = evaluator.CheckedGet("TESTCODE", "")
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    77
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    78
			# make a key that identifies this platform uniquely
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    79
			# - used to tell us whether we have done the pre-processing
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    80
			# we need already using another platform with compatible values.
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    81
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    82
			key = str(self.variant_hrh) \
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    83
				+ str(self.epocroot) \
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    84
			+ self.systeminclude \
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    85
			+ self.platform
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    86
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    87
			# Keep a short version of the key for use in filenames.
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    88
			uniq = hashlib.md5()
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    89
			uniq.update(key)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    90
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    91
			plat.key = key
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    92
			plat.key_md5 = "p_" + uniq.hexdigest()
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    93
			del uniq
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    94
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    95
	def __hash__(self):
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    96
		return hash(self.platform) + hash(self.epocroot) + hash(self.variant_hrh) + hash(self.systeminclude) + hash(self.testcode)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    97
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    98
	def __cmp__(self,other):
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
    99
		return cmp(self.hash(), other.hash())
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   100
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   101
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   102
	@classmethod 
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   103
	def fromConfigs(configsToBuild, build):
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   104
		""" Group the list of configurations into "build platforms"."""
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   105
		platforms = Set()
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   106
		
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   107
		for buildConfig in configsToBuild:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   108
			# get everything we need to know about the configuration
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   109
			plat = BuildPlatform(build = build)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   110
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   111
			# compare this configuration to the ones we have already seen
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   112
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   113
			# Is this an unseen export platform?
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   114
			# concatenate all the values we care about in a fixed order
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   115
			# and use that as a signature for the exports.
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   116
			items = ['EPOCROOT', 'VARIANT_HRH', 'SYSTEMINCLUDE', 'TESTCODE', 'export']
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   117
			export = ""
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   118
			for i in  items:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   119
				if i in detail:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   120
					export += i + str(detail[i])
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   121
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   122
			if export in exports:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   123
				# add this configuration to an existing export platform
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   124
				index = exports[export]
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   125
				self.ExportPlatforms[index]['configs'].append(buildConfig)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   126
			else:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   127
				# create a new export platform with this configuration
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   128
				exports[export] = len(self.ExportPlatforms)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   129
				exp = copy.copy(detail)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   130
				exp['PLATFORM'] = 'EXPORT'
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   131
				exp['configs']  = [buildConfig]
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   132
				self.ExportPlatforms.append(exp)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   133
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   134
			# Is this an unseen build platform?
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   135
			# concatenate all the values we care about in a fixed order
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   136
			# and use that as a signature for the platform.
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   137
			items = ['PLATFORM', 'EPOCROOT', 'VARIANT_HRH', 'SYSTEMINCLUDE', 'TESTCODE']
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   138
			if raptor_utilities.getOSPlatform().startswith("win"):
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   139
				items.append('PLATMACROS.WINDOWS')
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   140
			else:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   141
				items.append('PLATMACROS.LINUX')
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   142
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   143
			items.extend(interfaces)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   144
			platform = ""
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   145
			for i in  items:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   146
				if i in detail:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   147
					platform += i + str(detail[i])
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   148
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   149
			if platform in platforms:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   150
				# add this configuration to an existing build platform
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   151
				index = platforms[platform]
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   152
				BuildPlatforms[index]['configs'].append(buildConfig)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   153
			else:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   154
				# create a new build platform with this configuration
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   155
				platforms[platform] = len(self.BuildPlatforms)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   156
				plat.configs = [buildConfig]
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   157
				BuildPlatforms.append(detail)
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents:
diff changeset
   158