OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2012 Google Inc. All rights reserved. | 3 # Copyright (c) 2012 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 app bundles are built correctly. | 8 Verifies that app bundles are built correctly. |
9 """ | 9 """ |
10 | 10 |
(...skipping 14 matching lines...) Loading... |
25 test.fail_test() | 25 test.fail_test() |
26 | 26 |
27 def ls(path): | 27 def ls(path): |
28 '''Returns a list of all files in a directory, relative to the directory.''' | 28 '''Returns a list of all files in a directory, relative to the directory.''' |
29 result = [] | 29 result = [] |
30 for dirpath, _, files in os.walk(path): | 30 for dirpath, _, files in os.walk(path): |
31 for f in files: | 31 for f in files: |
32 result.append(os.path.join(dirpath, f)[len(path) + 1:]) | 32 result.append(os.path.join(dirpath, f)[len(path) + 1:]) |
33 return result | 33 return result |
34 | 34 |
| 35 def XcodeVersion(): |
| 36 stdout = subprocess.check_output(['xcodebuild', '-version']) |
| 37 version = stdout.splitlines()[0].split()[-1].replace('.', '') |
| 38 return (version + '0' * (3 - len(version))).zfill(4) |
| 39 |
35 | 40 |
36 if sys.platform == 'darwin': | 41 if sys.platform == 'darwin': |
37 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) | 42 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) |
38 | 43 |
39 test.run_gyp('test.gyp', chdir='app-bundle') | 44 test.run_gyp('test.gyp', chdir='app-bundle') |
40 | 45 |
41 test.build('test.gyp', test.ALL, chdir='app-bundle') | 46 test.build('test.gyp', test.ALL, chdir='app-bundle') |
42 | 47 |
43 # Binary | 48 # Binary |
44 test.built_file_must_exist('Test App Gyp.app/Contents/MacOS/Test App Gyp', | 49 test.built_file_must_exist('Test App Gyp.app/Contents/MacOS/Test App Gyp', |
45 chdir='app-bundle') | 50 chdir='app-bundle') |
46 | 51 |
47 # Info.plist | 52 # Info.plist |
48 info_plist = test.built_file_path('Test App Gyp.app/Contents/Info.plist', | 53 info_plist = test.built_file_path('Test App Gyp.app/Contents/Info.plist', |
49 chdir='app-bundle') | 54 chdir='app-bundle') |
50 test.must_exist(info_plist) | 55 test.must_exist(info_plist) |
51 test.must_contain(info_plist, 'com.google.Test-App-Gyp') # Variable expansion | 56 test.must_contain(info_plist, 'com.google.Test-App-Gyp') # Variable expansion |
52 test.must_not_contain(info_plist, '${MACOSX_DEPLOYMENT_TARGET}'); | 57 test.must_not_contain(info_plist, '${MACOSX_DEPLOYMENT_TARGET}'); |
53 | 58 |
54 if test.format != 'make': | 59 if test.format != 'make': |
55 # TODO: Synthesized plist entries aren't hooked up in the make generator. | 60 # TODO: Synthesized plist entries aren't hooked up in the make generator. |
56 plist = plistlib.readPlist(info_plist) | 61 plist = plistlib.readPlist(info_plist) |
57 ExpectEq(GetStdout(['sw_vers', '-buildVersion']), | 62 ExpectEq(GetStdout(['sw_vers', '-buildVersion']), |
58 plist['BuildMachineOSBuild']) | 63 plist['BuildMachineOSBuild']) |
59 ExpectEq('', plist['DTSDKName']) | 64 |
| 65 # Prior to Xcode 5.0.0, SDKROOT (and thus DTSDKName) was only defined if |
| 66 # set in the Xcode project file. Starting with that version, it is always |
| 67 # defined. |
| 68 expected = '' |
| 69 if XcodeVersion() >= '0500': |
| 70 version = GetStdout(['xcodebuild', '-version', '-sdk', '', 'SDKVersion']) |
| 71 expected = 'macosx' + version |
| 72 ExpectEq(expected, plist['DTSDKName']) |
60 sdkbuild = GetStdout( | 73 sdkbuild = GetStdout( |
61 ['xcodebuild', '-version', '-sdk', '', 'ProductBuildVersion']) | 74 ['xcodebuild', '-version', '-sdk', '', 'ProductBuildVersion']) |
62 if not sdkbuild: | 75 if not sdkbuild: |
63 # Above command doesn't work in Xcode 4.2. | 76 # Above command doesn't work in Xcode 4.2. |
64 sdkbuild = plist['BuildMachineOSBuild'] | 77 sdkbuild = plist['BuildMachineOSBuild'] |
65 ExpectEq(sdkbuild, plist['DTSDKBuild']) | 78 ExpectEq(sdkbuild, plist['DTSDKBuild']) |
66 xcode, build = GetStdout(['xcodebuild', '-version']).splitlines() | 79 xcode, build = GetStdout(['xcodebuild', '-version']).splitlines() |
67 xcode = xcode.split()[-1].replace('.', '') | 80 xcode = xcode.split()[-1].replace('.', '') |
68 xcode = (xcode + '0' * (3 - len(xcode))).zfill(4) | 81 xcode = (xcode + '0' * (3 - len(xcode))).zfill(4) |
69 build = build.split()[-1] | 82 build = build.split()[-1] |
(...skipping 27 matching lines...) Loading... |
97 set(['Contents/MacOS/Test App Gyp', | 110 set(['Contents/MacOS/Test App Gyp', |
98 'Contents/Info.plist', | 111 'Contents/Info.plist', |
99 'Contents/Resources/English.lproj/MainMenu.nib', | 112 'Contents/Resources/English.lproj/MainMenu.nib', |
100 'Contents/PkgInfo', | 113 'Contents/PkgInfo', |
101 ] + | 114 ] + |
102 [os.path.join('Contents/Resources/English.lproj', f) | 115 [os.path.join('Contents/Resources/English.lproj', f) |
103 for f in strings_files]): | 116 for f in strings_files]): |
104 test.fail_test() | 117 test.fail_test() |
105 | 118 |
106 test.pass_test() | 119 test.pass_test() |
OLD | NEW |