|
1 #!/usr/bin/env python |
|
2 # Copyright (c) 2012 Google Inc. All rights reserved. |
|
3 # Use of this source code is governed by a BSD-style license that can be |
|
4 # found in the LICENSE file. |
|
5 """ |
|
6 Verifies that make_global_settings can be used to override the |
|
7 compiler settings. |
|
8 """ |
|
9 |
|
10 import TestGyp |
|
11 import os |
|
12 import copy |
|
13 import sys |
|
14 from string import Template |
|
15 |
|
16 |
|
17 if sys.platform == 'win32': |
|
18 # cross compiling not support by ninja on windows |
|
19 # and make not supported on windows at all. |
|
20 sys.exit(0) |
|
21 |
|
22 test = TestGyp.TestGyp(formats=['ninja', 'make']) |
|
23 |
|
24 gypfile = 'compiler-global-settings.gyp' |
|
25 |
|
26 replacements = { 'PYTHON': '/usr/bin/python', 'PWD': os.getcwd()} |
|
27 |
|
28 # Process the .in gyp file to produce the final gyp file |
|
29 # since we need to include absolute paths in the make_global_settings |
|
30 # section. |
|
31 replacements['TOOLSET'] = 'target' |
|
32 s = Template(open(gypfile + '.in').read()) |
|
33 output = open(gypfile, 'w') |
|
34 output.write(s.substitute(replacements)) |
|
35 output.close() |
|
36 |
|
37 test.run_gyp(gypfile) |
|
38 test.build(gypfile) |
|
39 test.must_contain_all_lines(test.stdout(), ['my_cc.py', 'my_cxx.py', 'FOO']) |
|
40 |
|
41 # Same again but with the host toolset. |
|
42 replacements['TOOLSET'] = 'host' |
|
43 s = Template(open(gypfile + '.in').read()) |
|
44 output = open(gypfile, 'w') |
|
45 output.write(s.substitute(replacements)) |
|
46 output.close() |
|
47 |
|
48 test.run_gyp(gypfile) |
|
49 test.build(gypfile) |
|
50 test.must_contain_all_lines(test.stdout(), ['my_cc.py', 'my_cxx.py', 'BAR']) |
|
51 |
|
52 test.pass_test() |