bug 664197 - support universal builds in mozinfo/writemozinfo. r=jhammel

--HG--
extra : rebase_source : 13faa21a59805f879568c764cce61e8520749246
This commit is contained in:
Ted Mielczarek 2011-06-28 07:55:56 -04:00
parent a45ca344fa
commit c092cc9149
4 changed files with 66 additions and 22 deletions

View File

@ -73,18 +73,16 @@ class unknown(object):
unknown = unknown() # singleton
# get system information
info = {'os': unknown,
'processor': unknown,
'version': unknown,
'bits': unknown }
(system, node, release, version, machine, processor) = platform.uname()
(bits, linkage) = platform.architecture()
# get os information and related data
if system in ["Microsoft", "Windows"]:
info['os'] = 'win'
info['os'] = 'win'
# There is a Python bug on Windows to determine platform values
# http://bugs.python.org/issue7860
if "PROCESSOR_ARCHITEW6432" in os.environ:
@ -107,6 +105,7 @@ elif system == "Darwin":
elif sys.platform in ('solaris', 'sunos5'):
info['os'] = 'unix'
version = sys.platform
info['version'] = version # os version
# processor type and bits
if processor in ["i386", "i686"]:
@ -120,26 +119,48 @@ elif processor == "AMD64":
elif processor == "Power Macintosh":
processor = "ppc"
bits = re.search('(\d+)bit', bits).group(1)
info.update({'version': version,
'processor': processor,
info.update({'processor': processor,
'bits': int(bits),
})
def update(new_info):
"""update the info"""
info.update(new_info)
globals().update(info)
update({})
# standard value of choices, for easy inspection
choices = {'os': ['linux', 'win', 'mac', 'unix'],
'bits': [32, 64],
'processor': ['x86', 'x86_64', 'ppc']}
def sanitize(info):
"""Do some sanitization of input values, primarily
to handle universal Mac builds."""
if "processor" in info and info["processor"] == "universal-x86-x86_64":
# If we're running on OS X 10.6 or newer, assume 64-bit
if release[:4] >= "10.6":
info["processor"] = "x86_64"
info["bits"] = 64
else:
info["processor"] = "x86"
info["bits"] = 32
# method for updating information
def update(new_info):
"""update the info"""
info.update(new_info)
sanitize(info)
globals().update(info)
# convenience data for os access
for os_name in choices['os']:
globals()['is' + os_name.title()] = info['os'] == os_name
# unix is special
if isLinux:
globals()['isUnix'] = True
update({})
# exports
__all__ = info.keys()
__all__ += ['info', 'unknown', 'main', 'choices']
__all__ += ['is' + os_name.title() for os_name in choices['os']]
__all__ += ['info', 'unknown', 'main', 'choices', 'update']
def main(args=None):

View File

@ -61,6 +61,25 @@ class TestBuildDict(unittest.TestCase):
self.assertEqual('cocoa', d['toolkit'])
self.assertEqual(64, d['bits'])
def testMacUniversal(self):
d = build_dict({'OS_TARGET':'Darwin',
'TARGET_CPU':'i386',
'MOZ_WIDGET_TOOLKIT':'cocoa',
'UNIVERSAL_BINARY': '1'})
self.assertEqual('mac', d['os'])
self.assertEqual('universal-x86-x86_64', d['processor'])
self.assertEqual('cocoa', d['toolkit'])
self.assertFalse('bits' in d)
d = build_dict({'OS_TARGET':'Darwin',
'TARGET_CPU':'x86_64',
'MOZ_WIDGET_TOOLKIT':'cocoa',
'UNIVERSAL_BINARY': '1'})
self.assertEqual('mac', d['os'])
self.assertEqual('universal-x86-x86_64', d['processor'])
self.assertEqual('cocoa', d['toolkit'])
self.assertFalse('bits' in d)
def testAndroid(self):
d = build_dict({'OS_TARGET':'Android',
'TARGET_CPU':'arm',

View File

@ -37,12 +37,16 @@ def build_dict(env=os.environ):
# processor
p = env["TARGET_CPU"]
# do some slight massaging for some values
#TODO: retain specific values in case someone wants them?
if p.startswith("arm"):
p = "arm"
elif re.match("i[3-9]86", p):
p = "x86"
# for universal mac builds, put in a special value
if d["os"] == "mac" and "UNIVERSAL_BINARY" in env and env["UNIVERSAL_BINARY"] == "1":
p = "universal-x86-x86_64"
else:
# do some slight massaging for some values
#TODO: retain specific values in case someone wants them?
if p.startswith("arm"):
p = "arm"
elif re.match("i[3-9]86", p):
p = "x86"
d["processor"] = p
# hardcoded list of 64-bit CPUs
if p in ["x86_64", "ppc64"]:

View File

@ -9326,7 +9326,7 @@ AC_OUTPUT($MAKEFILES)
# Generate a JSON config file for unittest harnesses etc to read
# build configuration details from in a standardized way.
OS_TARGET=${OS_TARGET} TARGET_CPU=${TARGET_CPU} MOZ_DEBUG=${MOZ_DEBUG} \
MOZ_WIDGET_TOOLKIT=${MOZ_WIDGET_TOOLKIT} \
MOZ_WIDGET_TOOLKIT=${MOZ_WIDGET_TOOLKIT} UNIVERSAL_BINARY=${UNIVERSAL_BINARY} \
$PYTHON ${_topsrcdir}/config/writemozinfo.py ./mozinfo.json.tmp
if cmp -s ./mozinfo.json.tmp ./mozinfo.json; then
rm ./mozinfo.json.tmp