OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2014 Google Inc. All rights reserved. | 3 # Copyright (c) 2014 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 'LD' in make_global_settings. | 8 Verifies 'LD' in make_global_settings. |
9 """ | 9 """ |
10 | 10 |
11 import os | 11 import os |
12 import sys | 12 import sys |
13 import TestGyp | 13 import TestGyp |
14 | 14 |
15 def resolve_path(test, path): | 15 def resolve_path(test, path): |
16 if path is None: | 16 if path is None: |
17 return None | 17 return None |
18 elif test.format == 'make': | 18 elif test.format == 'make': |
19 return '$(abspath %s)' % path | 19 return '$(abspath %s)' % path |
20 elif test.format == 'ninja': | 20 elif test.format in ['ninja', 'xcode-ninja']: |
21 return os.path.join('..', '..', path) | 21 return os.path.join('..', '..', path) |
22 else: | 22 else: |
23 test.fail_test() | 23 test.fail_test() |
24 | 24 |
25 | 25 |
26 def verify_ld_target(test, ld=None, rel_path=False): | 26 def verify_ld_target(test, ld=None, rel_path=False): |
27 if rel_path: | 27 if rel_path: |
28 ld_expected = resolve_path(test, ld) | 28 ld_expected = resolve_path(test, ld) |
29 else: | 29 else: |
30 ld_expected = ld | 30 ld_expected = ld |
31 # Resolve default values | 31 # Resolve default values |
32 if ld_expected is None: | 32 if ld_expected is None: |
33 if test.format == 'make': | 33 if test.format == 'make': |
34 # Make generator hasn't set the default value for LD. | 34 # Make generator hasn't set the default value for LD. |
35 # You can remove the following assertion as long as it doesn't | 35 # You can remove the following assertion as long as it doesn't |
36 # break existing projects. | 36 # break existing projects. |
37 test.must_not_contain('Makefile', 'LD ?= ') | 37 test.must_not_contain('Makefile', 'LD ?= ') |
38 return | 38 return |
39 elif test.format == 'ninja': | 39 elif test.format in ['ninja', 'xcode-ninja']: |
40 if sys.platform == 'win32': | 40 if sys.platform == 'win32': |
41 ld_expected = 'link.exe' | 41 ld_expected = 'link.exe' |
42 else: | 42 else: |
43 ld_expected = '$cc' | 43 ld_expected = '$cc' |
44 if test.format == 'make': | 44 if test.format == 'make': |
45 test.must_contain('Makefile', 'LD ?= %s' % ld_expected) | 45 test.must_contain('Makefile', 'LD ?= %s' % ld_expected) |
46 elif test.format == 'ninja': | 46 elif test.format in ['ninja', 'xcode-ninja']: |
47 test.must_contain('out/Default/build.ninja', 'ld = %s' % ld_expected) | 47 test.must_contain('out/Default/build.ninja', 'ld = %s' % ld_expected) |
48 else: | 48 else: |
49 test.fail_test() | 49 test.fail_test() |
50 | 50 |
51 | 51 |
52 def verify_ld_host(test, ld=None, rel_path=False): | 52 def verify_ld_host(test, ld=None, rel_path=False): |
53 if rel_path: | 53 if rel_path: |
54 ld_expected = resolve_path(test, ld) | 54 ld_expected = resolve_path(test, ld) |
55 else: | 55 else: |
56 ld_expected = ld | 56 ld_expected = ld |
57 # Resolve default values | 57 # Resolve default values |
58 if ld_expected is None: | 58 if ld_expected is None: |
59 if test.format == 'make': | 59 if test.format == 'make': |
60 # Make generator hasn't set the default value for LD.host. | 60 # Make generator hasn't set the default value for LD.host. |
61 # You can remove the following assertion as long as it doesn't | 61 # You can remove the following assertion as long as it doesn't |
62 # break existing projects. | 62 # break existing projects. |
63 test.must_not_contain('Makefile', 'LD.host ?= ') | 63 test.must_not_contain('Makefile', 'LD.host ?= ') |
64 return | 64 return |
65 elif test.format == 'ninja': | 65 elif test.format in ['ninja', 'xcode-ninja']: |
66 if sys.platform == 'win32': | 66 if sys.platform == 'win32': |
67 ld_expected = '$ld' | 67 ld_expected = '$ld' |
68 else: | 68 else: |
69 ld_expected = '$cc_host' | 69 ld_expected = '$cc_host' |
70 if test.format == 'make': | 70 if test.format == 'make': |
71 test.must_contain('Makefile', 'LD.host ?= %s' % ld_expected) | 71 test.must_contain('Makefile', 'LD.host ?= %s' % ld_expected) |
72 elif test.format == 'ninja': | 72 elif test.format in ['ninja', 'xcode-ninja']: |
73 test.must_contain('out/Default/build.ninja', 'ld_host = %s' % ld_expected) | 73 test.must_contain('out/Default/build.ninja', 'ld_host = %s' % ld_expected) |
74 else: | 74 else: |
75 test.fail_test() | 75 test.fail_test() |
76 | 76 |
77 | 77 |
78 test_format = ['ninja'] | 78 test_format = ['ninja'] |
79 if sys.platform in ('linux2', 'darwin'): | 79 if sys.platform in ('linux2', 'darwin'): |
80 test_format += ['make'] | 80 test_format += ['make'] |
81 | 81 |
82 test = TestGyp.TestGyp(formats=test_format) | 82 test = TestGyp.TestGyp(formats=test_format) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 test.run_gyp('make_global_settings_ld.gyp') | 121 test.run_gyp('make_global_settings_ld.gyp') |
122 if test.format == 'make': | 122 if test.format == 'make': |
123 test.must_not_contain('Makefile', 'my_ld_target2') | 123 test.must_not_contain('Makefile', 'my_ld_target2') |
124 test.must_not_contain('Makefile', 'my_ld_host2') | 124 test.must_not_contain('Makefile', 'my_ld_host2') |
125 elif test.format == 'ninja': | 125 elif test.format == 'ninja': |
126 test.must_not_contain('out/Default/build.ninja', 'my_ld_target2') | 126 test.must_not_contain('out/Default/build.ninja', 'my_ld_target2') |
127 test.must_not_contain('out/Default/build.ninja', 'my_ld_host2') | 127 test.must_not_contain('out/Default/build.ninja', 'my_ld_host2') |
128 | 128 |
129 | 129 |
130 test.pass_test() | 130 test.pass_test() |
OLD | NEW |