|
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 the user can override the compiler and linker using CC/CXX/LD |
|
7 environment variables. |
|
8 """ |
|
9 |
|
10 import TestGyp |
|
11 import os |
|
12 import copy |
|
13 import sys |
|
14 |
|
15 here = os.path.dirname(os.path.abspath(__file__)) |
|
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 def CheckCompiler(test, gypfile, check_for): |
|
25 test.run_gyp(gypfile) |
|
26 test.build(gypfile) |
|
27 |
|
28 # We can't test to presence of my_ld.py in the output since |
|
29 # ninja will use CXX_target as the linker regardless |
|
30 test.must_contain_all_lines(test.stdout(), check_for) |
|
31 |
|
32 oldenv = os.environ.copy() |
|
33 try: |
|
34 # Check that CC, CXX and LD set target compiler |
|
35 os.environ['CC'] = 'python %s/my_cc.py FOO' % here |
|
36 os.environ['CXX'] = 'python %s/my_cxx.py FOO' % here |
|
37 os.environ['LD'] = 'python %s/my_ld.py FOO_LINK' % here |
|
38 CheckCompiler(test, 'compiler.gyp', |
|
39 ['my_cc.py', 'my_cxx.py', 'FOO', 'FOO_LINK']) |
|
40 finally: |
|
41 os.environ.clear() |
|
42 os.environ.update(oldenv) |
|
43 |
|
44 try: |
|
45 # Check that CC_host sets host compilee |
|
46 os.environ['CC_host'] = 'python %s/my_cc.py HOST' % here |
|
47 os.environ['CXX_host'] = 'python %s/my_cxx.py HOST' % here |
|
48 os.environ['LD_host'] = 'python %s/my_ld.py HOST_LINK' % here |
|
49 CheckCompiler(test, 'compiler-host.gyp', |
|
50 ['my_cc.py', 'my_cxx.py', 'HOST', 'HOST_LINK']) |
|
51 finally: |
|
52 os.environ.clear() |
|
53 os.environ.update(oldenv) |
|
54 |
|
55 test.pass_test() |