Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: test/ios/gyptest-archs.py

Issue 138533006: Improve ninja's Xcode emulation (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: Expand $(ARCHS_STANDARD) for all toolset, both "host" and "target" Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2013 Google Inc. All rights reserved. 3 # Copyright (c) 2013 Google Inc. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """ 7 """
8 Verifies that device and simulator bundles are built correctly. 8 Verifies that device and simulator bundles are built correctly.
9 """ 9 """
10 10
11 import collections
11 import plistlib 12 import plistlib
12 import TestGyp 13 import TestGyp
13 import os 14 import os
15 import re
14 import struct 16 import struct
15 import subprocess 17 import subprocess
16 import sys 18 import sys
17 import tempfile 19 import tempfile
18 20
19 21
20 def CheckFileType(file, expected): 22 def BuildExpected(file, archs):
23 if len(archs) == 1:
24 return 'Non-fat file: %s is architecture: %s' % (file, archs[0])
25 return 'Architectures in the fat file: %s are: %s' % (file, ' '.join(archs))
26
27
28 def CheckFileType(test, file, archs):
21 proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE) 29 proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE)
22 o = proc.communicate()[0].strip() 30 o = proc.communicate()[0].strip()
23 assert not proc.returncode 31 assert not proc.returncode
24 if not expected in o: 32 if len(archs) == 1:
25 print 'File: Expected %s, got %s' % (expected, o) 33 pattern = re.compile('^Non-fat file: (.*) is architecture: (.*)$')
34 else:
35 pattern = re.compile('^Architectures in the fat file: (.*) are: (.*)$')
36 match = pattern.match(o)
37 if match is None:
38 print 'Ouput does not match expected pattern: %s' % (pattern.pattern)
26 test.fail_test() 39 test.fail_test()
40 else:
41 found_file, found_archs = match.groups()
42 if found_file != file or set(found_archs.split()) != set(archs):
43 print 'Expected file %s with arch %s, got %s with arch %s' % (
44 file, ' '.join(archs), found_file, ' '.join(found_archs))
45 test.fail_test()
27 46
28 47
29 def XcodeVersion(): 48 def XcodeVersion():
30 xcode, build = GetStdout(['xcodebuild', '-version']).splitlines() 49 xcode, build = GetStdout(['xcodebuild', '-version']).splitlines()
31 xcode = xcode.split()[-1].replace('.', '') 50 xcode = xcode.split()[-1].replace('.', '')
32 xcode = (xcode + '0' * (3 - len(xcode))).zfill(4) 51 xcode = (xcode + '0' * (3 - len(xcode))).zfill(4)
33 return xcode 52 return xcode
34 53
35 54
36 def GetStdout(cmdlist): 55 def GetStdout(cmdlist):
37 proc = subprocess.Popen(cmdlist, stdout=subprocess.PIPE) 56 proc = subprocess.Popen(cmdlist, stdout=subprocess.PIPE)
38 o = proc.communicate()[0].strip() 57 o = proc.communicate()[0].strip()
39 assert not proc.returncode 58 assert not proc.returncode
40 return o 59 return o
41 60
42 61
43 if sys.platform == 'darwin': 62 if sys.platform == 'darwin':
44 test = TestGyp.TestGyp() 63 test = TestGyp.TestGyp()
64 if test.format == 'ninja' or test.format == 'xcode':
65 test_cases = [
66 ('Default', 'Test No Archs', ['i386']),
67 ('Default', 'Test Arch 32-bits', ['i386']),
68 ('Default', 'Test Arch 64-bits', ['x86_64']),
69 ('Default', 'Test Multi Archs', ['i386', 'x86_64']),
70 ('Default-iphoneos', 'Test No Archs', ['armv7']),
71 ('Default-iphoneos', 'Test Arch 32-bits', ['armv7']),
72 ('Default-iphoneos', 'Test Arch 64-bits', ['arm64']),
73 ('Default-iphoneos', 'Test Multi Archs', ['armv7', 'arm64']),
74 ]
45 75
46 test.run_gyp('test-archs.gyp', chdir='app-bundle') 76 xcode_version = XcodeVersion()
47 test.set_configuration('Default') 77 test.run_gyp('test-archs.gyp', chdir='app-bundle')
78 for configuration, name, archs in test_cases:
79 is_64_bit_build = ('arm64' in archs or 'x86_64' in archs)
80 is_device_build = configuration.endswith('-iphoneos')
48 81
49 # TODO(sdefresne): add 'Test Archs x86_64' once bots have been updated to 82 kwds = collections.defaultdict(list)
50 # a SDK version that supports "x86_64" architecture. 83 if test.format == 'xcode' and is_device_build:
51 filenames = ['Test No Archs', 'Test Archs i386'] 84 configuration, sdk = configuration.split('-')
52 if XcodeVersion() >= '0500': 85 kwds['arguments'].extend(['-sdk', sdk])
53 filenames.append('Test Archs x86_64')
54 86
55 for filename in filenames: 87 # TODO(sdefresne): remove those special-cases once the bots have been
56 target = filename.replace(' ', '_').lower() 88 # updated to use a more recent version of Xcode.
57 test.build('test-archs.gyp', target, chdir='app-bundle') 89 if xcode_version < '0500':
58 result_file = test.built_file_path( 90 if is_64_bit_build:
59 '%s.bundle/%s' % (filename, filename), chdir='app-bundle') 91 continue
60 test.must_exist(result_file) 92 if test.format == 'xcode':
93 arch = 'i386'
94 if is_device_build:
95 arch = 'armv7'
96 kwds['arguments'].extend(['-arch', arch])
61 97
62 expected = 'i386' 98 test.set_configuration(configuration)
63 if 'x86_64' in filename: 99 product = name.replace(' ', '')
justincohen 2014/02/10 21:41:33 Why not just rename the products to not have space
sdefresne 2014/02/11 16:30:45 Done.
64 expected = 'x86_64' 100 filename = '%s.bundle/%s' % (product, product)
65 CheckFileType(result_file, expected) 101 target = name.replace(' ', '_').replace('-', '_').lower()
102 test.build('test-archs.gyp', target, chdir='app-bundle', **kwds)
103 result_file = test.built_file_path(filename, chdir='app-bundle')
66 104
67 test.pass_test() 105 test.must_exist(result_file)
106 CheckFileType(test, result_file, archs)
107
108 test.pass_test()
OLDNEW
« pylib/gyp/xcode_emulation.py ('K') | « test/ios/app-bundle/test-archs.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698