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 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 ld_expected = '$(LD)' | 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 |
| 62 # break existing projects. |
| 63 test.must_not_contain('Makefile', 'LD.host ?= ') |
| 64 return |
61 elif test.format == 'ninja': | 65 elif test.format == 'ninja': |
62 if sys.platform == 'win32': | 66 if sys.platform == 'win32': |
63 # TODO(yukawa): Make sure if this is an expected result or not. | 67 ld_expected = '$ld' |
64 ld_expected = 'ld' | |
65 else: | 68 else: |
66 ld_expected = '$ld' | 69 ld_expected = '$cc_host' |
67 if test.format == 'make': | 70 if test.format == 'make': |
68 test.must_contain('Makefile', 'LD.host ?= %s' % ld_expected) | 71 test.must_contain('Makefile', 'LD.host ?= %s' % ld_expected) |
69 elif test.format == 'ninja': | 72 elif test.format == 'ninja': |
70 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) |
71 else: | 74 else: |
72 test.fail_test() | 75 test.fail_test() |
73 | 76 |
74 | 77 |
75 test_format = ['ninja'] | 78 test_format = ['ninja'] |
76 if sys.platform in ('linux2', 'darwin'): | 79 if sys.platform in ('linux2', 'darwin'): |
77 test_format += ['make'] | 80 test_format += ['make'] |
78 | 81 |
79 test = TestGyp.TestGyp(formats=test_format) | 82 test = TestGyp.TestGyp(formats=test_format) |
80 | 83 |
81 # Check default values | 84 # Check default values |
82 test.run_gyp('make_global_settings_ld.gyp') | 85 test.run_gyp('make_global_settings_ld.gyp') |
83 verify_ld_target(test) | 86 verify_ld_target(test) |
84 | 87 |
85 | 88 |
| 89 # Check default values with GYP_CROSSCOMPILE enabled. |
| 90 with TestGyp.LocalEnv({'GYP_CROSSCOMPILE': '1'}): |
| 91 test.run_gyp('make_global_settings_ld.gyp') |
| 92 verify_ld_target(test) |
| 93 verify_ld_host(test) |
| 94 |
| 95 |
86 # Test 'LD' in 'make_global_settings'. | 96 # Test 'LD' in 'make_global_settings'. |
87 test.run_gyp('make_global_settings_ld.gyp', '-Dcustom_ld_target=my_ld') | 97 with TestGyp.LocalEnv({'GYP_CROSSCOMPILE': '1'}): |
| 98 test.run_gyp('make_global_settings_ld.gyp', '-Dcustom_ld_target=my_ld') |
88 # TODO(yukawa): Support 'LD' in Ninja generator | 99 # TODO(yukawa): Support 'LD' in Ninja generator |
89 if test.format == 'make': | 100 if test.format == 'make': |
90 verify_ld_target(test, ld='my_ld', rel_path=True) | 101 verify_ld_target(test, ld='my_ld', rel_path=True) |
91 | 102 |
92 | 103 |
93 # Test 'LD'/'LD.host' in 'make_global_settings'. | 104 # Test 'LD'/'LD.host' in 'make_global_settings'. |
94 test.run_gyp('make_global_settings_ld.gyp', | 105 with TestGyp.LocalEnv({'GYP_CROSSCOMPILE': '1'}): |
95 '-Dcustom_ld_target=my_ld_target1', | 106 test.run_gyp('make_global_settings_ld.gyp', |
96 '-Dcustom_ld_host=my_ld_host1') | 107 '-Dcustom_ld_target=my_ld_target1', |
| 108 '-Dcustom_ld_host=my_ld_host1') |
97 # TODO(yukawa): Support 'LD'/'LD.host' in Ninja generator | 109 # TODO(yukawa): Support 'LD'/'LD.host' in Ninja generator |
98 if test.format == 'make': | 110 if test.format == 'make': |
99 verify_ld_target(test, ld='my_ld_target1', rel_path=True) | 111 verify_ld_target(test, ld='my_ld_target1', rel_path=True) |
100 verify_ld_host(test, ld='my_ld_host1', rel_path=True) | 112 verify_ld_host(test, ld='my_ld_host1', rel_path=True) |
101 | 113 |
102 | 114 |
103 # Unlike other environment variables such as $AR/$AR_host, $CC/$CC_host, | 115 # Unlike other environment variables such as $AR/$AR_host, $CC/$CC_host, |
104 # and $CXX/$CXX_host, neither Make generator nor Ninja generator recognizes | 116 # and $CXX/$CXX_host, neither Make generator nor Ninja generator recognizes |
105 # $LD/$LD_host environment variables as of r1935. This may or may not be | 117 # $LD/$LD_host environment variables as of r1935. This may or may not be |
106 # intentional, but here we leave a test case to verify this behavior just for | 118 # intentional, but here we leave a test case to verify this behavior just for |
107 # the record. | 119 # the record. |
108 # If you want to support $LD/$LD_host, please revise the following test case as | 120 # If you want to support $LD/$LD_host, please revise the following test case as |
109 # well as the generator. | 121 # well as the generator. |
110 with TestGyp.LocalEnv({'LD': 'my_ld_target2', | 122 with TestGyp.LocalEnv({'GYP_CROSSCOMPILE': '1', |
| 123 'LD': 'my_ld_target2', |
111 'LD_host': 'my_ld_host2'}): | 124 'LD_host': 'my_ld_host2'}): |
112 test.run_gyp('make_global_settings_ld.gyp') | 125 test.run_gyp('make_global_settings_ld.gyp') |
113 if test.format == 'make': | 126 if test.format == 'make': |
114 test.must_not_contain('Makefile', 'my_ld_target2') | 127 test.must_not_contain('Makefile', 'my_ld_target2') |
115 test.must_not_contain('Makefile', 'my_ld_host2') | 128 test.must_not_contain('Makefile', 'my_ld_host2') |
116 elif test.format == 'ninja': | 129 elif test.format == 'ninja': |
117 test.must_not_contain('out/Default/build.ninja', 'my_ld_target2') | 130 test.must_not_contain('out/Default/build.ninja', 'my_ld_target2') |
118 test.must_not_contain('out/Default/build.ninja', 'my_ld_host2') | 131 test.must_not_contain('out/Default/build.ninja', 'my_ld_host2') |
119 | 132 |
120 | 133 |
121 test.pass_test() | 134 test.pass_test() |
OLD | NEW |